WOscMethod Class Reference

#include <WOscMethod.h>

Inherited by WOscReceiverMethod.

List of all members.

Public Member Functions

 WOscMethod (WOscContainer *parent, const char *name, WOscMethodInfo *info=NULL)
virtual void Method (const WOscMessage *message, const WOscTimeTag &when, const WOscNetReturn *networkReturnAddress)=0
void AddMethodAlias (WOscContainer *parent, const char *alias)
WOscContainerGetParent ()
WOscString GetName ()
WOscString GetAddress ()
WOscString GetAddressSpace ()
const WOscMethodInfoGetInfo () const

Protected Member Functions

virtual ~WOscMethod ()

Friends

class WOscContainer

Detailed Description

OSC callback methods are objects that are mapped to a specific OSC-address. Very similar to OSC-containers they are children of any container.

If during dispatching and subsequent invoking an OSC-method gets called, the message, which produced the invokation, and a network-return-address is passed.

Methods can be seen as remote functions. Multiple computers communicate remotely by calling each others functions and passing arguments.

Inherit your own methods from this class or - when using WOscReceiver - from WOscReceiverMethod.

See also:
WOscCallbackList | WOscCallbackListItem | WOscReceiverMethod
Examples:

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

Definition at line 84 of file WOscMethod.h.


Constructor & Destructor Documentation

WOscMethod::WOscMethod ( WOscContainer parent,
const char *  name,
WOscMethodInfo info = NULL 
)

Constructor. Osc-methods can only be constructed in presence of a parent container, since method-orphans are not allowed. Additionally they have to be instantiated dynamically because the OSC-address-tree (formed by WOscContainer objects) handles the clean-up of all tree-elements. Therefor the destructor is private.

Parameters:
info Info about this method.
parent Pointer of the container that's going to be the parent of this method.
context A void pointer for later use from within the method. This can be used to pass an object pointer on which the method should operate lateron (As implemented in WOscReceiver).
name The OSC-pattern that will be the name of this method in the OSC-address space. If WOSC_ADDR_WILDCARDS is defined 1, wildcard matching will be performed on the address path segments.
Exceptions:
WOscException When illegal parent pointers are passed (i.e. NULL).

Definition at line 96 of file WOscMethod.cpp.

References ERR_PARENT_POINTER_NULL, and WOscMethod().

Referenced by WOscMethod().

00098                               :
00099     m_parent(parent), m_info(info)
00100 {
00101     if ( parent == NULL )
00102         throw WOscException(ERR_PARENT_POINTER_NULL, __FILE__, __LINE__);
00103     m_parent->AddMethod(this, name, false);
}

virtual WOscMethod::~WOscMethod (  )  [inline, protected, virtual]

Destructor. A WOscMethod can be deleted only by WOscContainers. Does nothing currently.

Definition at line 132 of file WOscMethod.h.

00132 { delete m_info; }


Member Function Documentation

void WOscMethod::AddMethodAlias ( WOscContainer parent,
const char *  alias 
)

Adds this method as alias to the list of methods of the container passed as argument.

Parameters:
parent Parent container to which this method should be added as alias.
alias New (aliased) name of the method.
Exceptions:
WOscException When passing an illegal parent pointer (i.e. NULL).
See also:
WOscContainer::addContainerAlias(WOscContainer* parent, char* alias)
Examples:
WOscClient.cpp, WOscStreamingClient.cpp, and WOscStreamingServer.cpp.

Definition at line 120 of file WOscMethod.cpp.

References ERR_PARENT_POINTER_NULL.

00121 {
00122     if ( parent == NULL ) // should not happen
00123         throw WOscException(ERR_PARENT_POINTER_NULL, __FILE__, __LINE__);
00124     parent->AddMethod(this, alias, true);
00125 }

WOscString WOscMethod::GetAddress (  ) 

Returns the OSC-address of this container as seen from the root. If this container should be aliased, it returns the main, not aliased, address.

Returns:
OSC-address as WOscString.
Remarks:
Remember: Container-addresses end with '/', method-addresses with no slash.

Definition at line 207 of file WOscMethod.cpp.

References WOscContainer::GetName(), and GetName().

00208 {
00209     WOscContainer* momentaryParent = m_parent;
00210     WOscString address = GetName();
00211     WOscString tmp;
00212 
00213     /* traverse tree upwards until root is reached */
00214     while ( momentaryParent != NULL ){
00215         if (momentaryParent->m_parent == NULL) break;
00216         WOscString tmp = momentaryParent->GetName();
00217         tmp += '/';
00218         address = tmp + address;
00219 
00220         momentaryParent = momentaryParent->m_parent;
00221     }
00222     tmp = '/';
00223     
00224     return tmp + address;
00225 }

WOscString WOscMethod::GetAddressSpace (  ) 

Returns the whole OSC-address-space as seen from root. The address-space contains only addresses with valid leaves (OSC-methods).

Returns:
All OSC-addresses which form the OSC-address-space, separated by '
'-characters.

Definition at line 188 of file WOscMethod.cpp.

References WOscContainer::FindRoot(), and WOscContainer::GetMethodList().

00189 {
00190     const WOscContainer* root = m_parent->FindRoot();
00191     return root->GetMethodList();
00192 }

const WOscMethodInfo* WOscMethod::GetInfo (  )  const [inline]

Retrieve the proprietary info which can be set in the constructor. NULL if not set.

Definition at line 125 of file WOscMethod.h.

00125 { return m_info; }

WOscString WOscMethod::GetName (  ) 

The OSC method. This is the function that will be called, when a certain OSC-address in a message matches the address of this method-object. The message is then passed together with a network-return-address and a timeTag which contains the point in time of the invokation.

Each message object can access the programm-ressources without global variables by using the context-pointer.

Parameters:
message Message causing this call (eventually containing arguments).
when Time of invokation (should be current time, when a priority queue, system time and a fast update-rate is used.
networkReturnAddress The network address where the message came from.
Exceptions:
Not in this, but perhaps in inherited classes and in their function-calls.

void WOscMethod::method(WOscMessage *message, WOscTimeTag& when, WOscNetReturn* networkReturnAddress){

} Gets the name (the single pattern, not the OSC-address) of this node. If a container is named "xyz" and it's located in the OSC-address-space at "/abcd/klm/xyz/lalala", only xyz is returned.

Returns:
The name of this container as WOscString.

Definition at line 166 of file WOscMethod.cpp.

Referenced by GetAddress().

00167 {
00168     /* search all children of parent for not aliased name */
00169     const std::vector<WOscMethodEntry>& methEntries = m_parent->m_methodEntries;
00170     for ( int i = methEntries.size()-1; i >= 0; i-- )
00171         if ( methEntries[i].m_method == this && !methEntries[i].m_isAlias ) {
00172             return WOscString(methEntries[i].m_name.c_str());
00173         }
00174 
00175     return WOscString();
00176 }

WOscContainer * WOscMethod::GetParent (  ) 

Returns the main parent-container (not aliased ones!). For use in the method-member function to get the calling- container-context.

Returns:
The main parent container (not aliased).

Definition at line 235 of file WOscMethod.cpp.

00236 {
00237     return m_parent;
00238 }

virtual void WOscMethod::Method ( const WOscMessage message,
const WOscTimeTag when,
const WOscNetReturn networkReturnAddress 
) [pure virtual]

The OSC method. This is the function that will be called, when a certain OSC-address in a message matches the address of this method-object. The message is then passed together with a network-return-address and a timeTag which contains the point in time of the invocation.

Each message object can access the program resources without global variables by using the context-pointer.

Parameters:
message Message causing this call (eventually containing arguments).
when Time of invocation (should be current time, when a priority queue, system time and a fast update-rate is used.
networkReturnAddress The network address where the message came from.
Exceptions:
Not in this, but perhaps in inherited classes and in their function-calls.
Examples:
WOscClient.cpp, and WOscServer.cpp.

Friends And Related Function Documentation

friend class WOscContainer [friend]

WOscContainer controls the deletion of registered methods.

Definition at line 129 of file WOscMethod.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