00001 /* 00002 * WOscLib, an object oriented OSC library. 00003 * Copyright (C) 2005 Uli Clemens Franke, Weiss Engineering LTD, Switzerland. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 * 00019 * For details see lgpl.txt 00020 * 00021 * Weiss Engineering LTD. 00022 * Florastrass 42 00023 * 8610 Uster 00024 * Switzerland 00025 * 00026 * uli.franke@weiss.ch 00027 */ 00028 00029 /** WOscNetReturn header file. 00030 * \file 00031 * 00032 * $Author: cls-nebadje $ ( \ref _UcfWOscLib ) 00033 * $Date: 2006-08-12 20:02:28 $ 00034 * $Revision: 1.4 $ 00035 * 00036 * Copyright (c) Weiss Engineering Ltd 00037 * 00038 */ 00039 00040 #ifndef __WOSCNETRETURN_H__ 00041 #define __WOSCNETRETURN_H__ 00042 00043 #include "WOscLib.h" 00044 00045 /** System independent network-address base-class. Required to 00046 * pass a return address of the client which send the message 00047 * to the method handling the message. Inherit a new class from 00048 * this base class and your system-specific network address-class. 00049 * 00050 * All address-object-references passed to networkReceive of WOscReceiver 00051 * (and inherited classes) will be managed and deleted internally. 00052 * 00053 * \remarks 00054 * Due to the priority queue and nested OSC-bundles which are inserted into it, 00055 * estimations about the lifetime of an address-object are difficult to make. 00056 * Each OSC-bundle received from a network (or similar) interface and its inner 00057 * bundles have the same return-address. but since inner bundles (bundles in bundles) 00058 * can have larger time-tags than the outer bundle, the return address has to be 00059 * preserved. This would make a memory-management on bundle-level complicated. 00060 * This library delegates this task to a lower level: To the elements, which get 00061 * queued in a priority queue (i.e. bundles) and a special return-address base-class. 00062 * 00063 * WOscNetReturn features a garbage-collector like memory-management which keeps the 00064 * object alive as long there are parents. Each parent has to register and unregister 00065 * itself by calling addParent() and removeParent() resp.. 00066 * 00067 * If the last object unregisters itself, the object gets deleted. 00068 * 00069 * In this library the WOscQueueItem and WOscReceiver are the only users of objects 00070 * of this kind. 00071 * 00072 * All return-address management in this library is handled through references, thus 00073 * the library does not have to be recompiled or even changed when using external 00074 *internet-(or similar for different transport layers) addresses. Simply inherit. 00075 * 00076 * \see 00077 * WOscReceiver::networkReceive(const char* const data, int dataLen, WOscNetReturn* networkReturnAddress) , 00078 * WOscQueueItem::WOscQueueItem(WOscTimeTag& timeTag, WOscNetReturn* ra) , 00079 * WOscQueueItem::~WOscQueueItem() and the examples. 00080 */ 00081 class WOSC_EXPORT WOscNetReturn 00082 { 00083 protected: 00084 WOscNetReturn(); 00085 virtual ~WOscNetReturn(); 00086 00087 /** The parent object (WOscQueueItem) determines if a network-return 00088 * address is an orphan by adding and removing itself as a parent. */ 00089 friend class WOscQueueItem; 00090 /** When receiving a message, the network-return-address has to be deleted 00091 * in receiver. */ 00092 friend class WOscReceiver; 00093 void AddParent(); 00094 void RemoveParent(); 00095 00096 private: 00097 WOscNetReturn(const WOscNetReturn&); 00098 WOscNetReturn& operator=(const WOscNetReturn&); 00099 00100 /** Number of WOscQueueItems are using this element currently.*/ 00101 int m_numUsers; 00102 }; 00103 00104 #endif