WOscNetReturn Class Reference

#include <WOscNetReturn.h>

Inherited by TheNetReturnAddress.

List of all members.

Protected Member Functions

 WOscNetReturn ()
virtual ~WOscNetReturn ()
void AddParent ()
void RemoveParent ()


class WOscQueueItem
class WOscReceiver

Detailed Description

System independent network-address base-class. Required to pass a return address of the client which send the message to the method handling the message. Inherit a new class from this base class and your system-specific network address-class.

All address-object-references passed to networkReceive of WOscReceiver (and inherited classes) will be managed and deleted internally.

Due to the priority queue and nested OSC-bundles which are inserted into it, estimations about the lifetime of an address-object are difficult to make. Each OSC-bundle received from a network (or similar) interface and its inner bundles have the same return-address. but since inner bundles (bundles in bundles) can have larger time-tags than the outer bundle, the return address has to be preserved. This would make a memory-management on bundle-level complicated. This library delegates this task to a lower level: To the elements, which get queued in a priority queue (i.e. bundles) and a special return-address base-class.

WOscNetReturn features a garbage-collector like memory-management which keeps the object alive as long there are parents. Each parent has to register and unregister itself by calling addParent() and removeParent() resp..

If the last object unregisters itself, the object gets deleted.

In this library the WOscQueueItem and WOscReceiver are the only users of objects of this kind.

All return-address management in this library is handled through references, thus the library does not have to be recompiled or even changed when using external internet-(or similar for different transport layers) addresses. Simply inherit.

See also:
WOscReceiver::networkReceive(const char* const data, int dataLen, WOscNetReturn* networkReturnAddress) , WOscQueueItem::WOscQueueItem(WOscTimeTag& timeTag, WOscNetReturn* ra) , WOscQueueItem::~WOscQueueItem() and the examples.

WOscClient.cpp, WOscServer.cpp, WOscStreamingClient.cpp, and WOscStreamingServer.cpp.

Definition at line 81 of file WOscNetReturn.h.

Constructor & Destructor Documentation

WOscNetReturn::WOscNetReturn (  )  [protected]

Constructor. Resets the parent counter (no parents yet).

Definition at line 46 of file WOscNetReturn.cpp.

00046                             {
00047     m_numUsers = 0;
00048 }

WOscNetReturn::~WOscNetReturn (  )  [protected, virtual]


Definition at line 76 of file WOscNetReturn.cpp.

00076                              {
00077 }

Member Function Documentation

void WOscNetReturn::AddParent (  )  [protected]

An owner (user) of this object increases the parent counter to request an ongoing existence. To unregister call WOscNetReturn::removeParent() .

See also:

Definition at line 57 of file WOscNetReturn.cpp.

00057                              {
00058     m_numUsers++;
00059 }

void WOscNetReturn::RemoveParent (  )  [protected]

An owner (user) of this object decreases the parent counter to announce, that it isn't interested in this object anymore. If the parent counter reaches zero, the object destructs itself.

See also:

Definition at line 67 of file WOscNetReturn.cpp.

Referenced by WOscReceiver::ManagePriorityQueue(), and WOscReceiver::NetworkReceive().

00067                                 {
00068     m_numUsers--;
00069     if ( m_numUsers <= 0 )
00070         delete this;
00071 }

Friends And Related Function Documentation

friend class WOscQueueItem [friend]

The parent object (WOscQueueItem) determines if a network-return address is an orphan by adding and removing itself as a parent.

Definition at line 89 of file WOscNetReturn.h.

friend class WOscReceiver [friend]

When receiving a message, the network-return-address has to be deleted in receiver.

Definition at line 92 of file WOscNetReturn.h.

The documentation for this class was generated from the following files:
Generated on Sat Oct 23 03:05:59 2010 for WOscLib by  doxygen 1.6.3