Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages | Examples

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.

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.
Exceptions:
WOscException When illegal parent pointers are passed (i.e. NULL).

Definition at line 94 of file WOscMethod.cpp.

References WOscContainer::AddMethod(), and ERR_PARENT_POINTER_NULL.

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

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.

Definition at line 118 of file WOscMethod.cpp.

References WOscContainer::AddMethod(), and ERR_PARENT_POINTER_NULL.

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

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 205 of file WOscMethod.cpp.

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

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

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 186 of file WOscMethod.cpp.

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

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

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  ) 
 

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 164 of file WOscMethod.cpp.

References WOscContainer::m_methodEntries.

Referenced by GetAddress().

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

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 233 of file WOscMethod.cpp.

00234 {
00235     return m_parent;
00236 }

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.


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 Sun Nov 1 23:31:19 2009 for WOscLib by  doxygen 1.4.1