vhdTestServiceBody Class Reference

#include <vhdTestServiceBody.h>

List of all members.

Public Member Functions

 vhdTestServiceBody (const std::string &serviceClassName, const std::string &serviceName)
virtual ~vhdTestServiceBody ()
int nbProperty (void) const
vhdPropertyRef getProperty (const int id) const
vhdPropertyRef getProperty (const std::string &pname) const
vhtBool loadInitProps ()

Protected Member Functions

virtual vhtSize32 _getServiceBodyVersionImplem ()
virtual void _declareCollaborationsImplem ()
virtual vhtBool _initImplem (vhdServiceContextRef serviceContext)
virtual vhtBool _runImplem ()
virtual vhtBool _initPropertyScanImplem (vhdPropertyRef property)
virtual vhtBool _terminateImplem ()
virtual vhtBool _updateImplem ()
virtual vhtBool _freezeImplem (void)
virtual void _handleWarpClockExchangeImplem (const std::string &warpClockName, vhdWarpClockRef warpClock)
virtual void _handleAddServiceImplem (vhdServiceHandleRef serviceHandle)
virtual void _handleRemoveServiceImplem (vhdServiceHandleRef serviceHandle)
virtual void _handleServiceStateChangeImplem (vhdServiceHandleRef serviceHandle)
virtual vhtBool _handleAddPropertyScanImplem (vhdPropertyRef property)
virtual vhtBool _handleRemovePropertyScanImplem (vhdPropertyRef property)
virtual void _handlePropertyChangeImplem (vhdPropertyRef property)
virtual vhtBool _filterEventImplem (vhdEventRef event)
virtual vhtBool _handleEventImplem (vhdEventRef event)

Static Protected Member Functions

static bool testCBHandler (void *self, int key, int value)

Private Attributes

 vhdCLASS_TYPE
_Impl_pImpl

Classes

class  _Impl


Constructor & Destructor Documentation

vhdTestServiceBody::vhdTestServiceBody ( const std::string &  serviceClassName,
const std::string &  serviceName 
)

Constructor.

vhdTestServiceBody::~vhdTestServiceBody (  )  [virtual]

Destructor.


Member Function Documentation

int vhdTestServiceBody::nbProperty ( void   )  const

Get the number of OSGShaderService registered vhdProperty (either vhdGeometryProperty or vhdHANIMProperty)

vhdPropertyRef vhdTestServiceBody::getProperty ( const int  id  )  const

Get one OSGShaderService registered vhdProperty by index [in the internal propertyController table] (either vhdGeometryProperty or vhdHANIMProperty) Return NULL if index out of bound.

vhdPropertyRef vhdTestServiceBody::getProperty ( const std::string &  pname  )  const

Get one OSGShaderService registered vhdProperty by name (either vhdGeometryProperty or vhdHANIMProperty) Return NULL if no registered property found for the given 'pname'.

vhtBool vhdTestServiceBody::loadInitProps (  ) 

virtual vhtSize32 vhdTestServiceBody::_getServiceBodyVersionImplem (  )  [inline, protected, virtual]

___IMPLEMENT IT___

Imeplement it as a simple inline method returning version number of your ServiceBody implementation. Example: virtual vhtSize32 _getServiceVersion() { return 27; }

virtual void vhdTestServiceBody::_declareCollaborationsImplem (  )  [inline, protected, virtual]

___OPTIONALLY_IMPLEMENT IT___

vhtBool vhdTestServiceBody::_initImplem ( vhdServiceContextRef  serviceContext  )  [protected, virtual]

___IMPLEMENT IT___

Called by vhdServiceHandle to notify ServiceBody that it should initialize itself. It is assured that the non-NULL cnotext is passed thanks to the thread safe interface

vhtBool vhdTestServiceBody::_runImplem (  )  [protected, virtual]

Called by ServiceHead to notify ServiceBody that service will be running which means that ServiceBody will receive calls to _udate() from now on.

vhtBool vhdTestServiceBody::_initPropertyScanImplem ( vhdPropertyRef  property  )  [protected, virtual]

___OPTIONALLY_IMPLEMENT IT___

Right after _initImplem() the kernel will make the vhdProperty tree scan for you using vhdPropertyTreeIterator and it will feed you with all vhdProperties found using this method. Note that the service is initialized after the scan which means that within this method you may be adding new properties to the tree and still your _handleAddPropertyImplem() will not be called since notifications are forwrded onyl to the initialized services.

You may stop the scan at any moment by returning FALSE. Othewise return TRUE to continue the scan.

Return TRUE for each property that your vhdService will operate on (FALSE means that you are not interested in a property)

Normally for properties that you would like to use add them to your vhdPropertyController (for READ/WRITE) or vhdPropertyObserver (for READ ONLY)

Example of implementation that filters proeprties that can be of interest for you. void postInitPropertyScanImplem( vhdPropertyRef property) { if (false) else if ( vhdREF_IS_OF_CLASS( vhdGeometryProperty, property)) { vhdGeometryPropertyRef geomProp = vhdREF_DYNAMIC_CAST( vhdGeometryProperty, property); ... getServiceContext()->getPropertyController/Observer()->addProperty(property); } else if ( vhdREF_IS_OF_CLASS( vhdCameraProperty, property)) { vhdCameraPropertyRef camProp = vhdREF_DYNAMIC_CAST( vhdCameraProperty, property); ... getServiceContext()->getPropertyController/Observer()->addProperty(property); } else if ( vhdREF_IS_OF_CLASS( vhdProperty, property)) { vhdCameraPropertyRef camProp = vhdREF_DYNAMIC_CAST( vhdCameraProperty, property); ... getServiceContext()->getPropertyController/Observer()->addProperty(property); }

return TRUE; // to tell the kernel to continue the scan }

vhtBool vhdTestServiceBody::_terminateImplem (  )  [protected, virtual]

Called by vhdServiceHandle to notify ServiceBody that it should terminate.

vhtBool vhdTestServiceBody::_updateImplem (  )  [protected, virtual]

Called by ServiceHead to notify ServiceBody that is should update itself. It is called only when serive is initialized and running.

vhtBool vhdTestServiceBody::_freezeImplem ( void   )  [protected, virtual]

vhdOSGSahderServiceBody freeze. Freezes = no further updates.

void vhdTestServiceBody::_handleWarpClockExchangeImplem ( const std::string &  warpClockName,
vhdWarpClockRef  warpClock 
) [protected, virtual]

___OPTINALLY_IMPLEMENT IT___

By implementing this method you may react to the changes of the vhdWarpClock stored for you in the vhdServiceContext. Through this methdo you receive new warpClockName and warpClock or empty string and NULL which means that from now on getWarpClockCurrentTime() will be returnign time readings from the SIM clock.

void vhdTestServiceBody::_handleAddServiceImplem ( vhdServiceHandleRef  serviceHandle  )  [protected, virtual]

___OPTINALLY_IMPLEMENT IT___

Each time new vhdProperty is added ot the property tree kept by vhdPropertyManager then vhdPropertyManager goes to the vhdServiceManager and notifies each vhdServiceBody about new properties. If you return TRUE then the property will be added automatically to the private vhdPropertyController of the vhdServiceBody.

This method is called right after the vhdPropery has been added

Parameters:
property just added to the property tree kept by vhdPropertyManager (so you can inspect the parent, etc.)

void vhdTestServiceBody::_handleRemoveServiceImplem ( vhdServiceHandleRef  serviceHandle  )  [protected, virtual]

___OPTIONALLY_IMPLEMENT IT___

This method is called just before any vhdProperty is going to be removed. You may return FALSE to block the removal of the property.

Parameters:
property just about to be removed from the property tree kept by vhdPropertyManager (so you can inspect the parent, etc.)

void vhdTestServiceBody::_handleServiceStateChangeImplem ( vhdServiceHandleRef  serviceHandle  )  [protected, virtual]

___OPTIONALLY_IMPLEMENT IT___

This method is called just after the state of the service changed

Parameters:
property just about to be removed from the property tree kept by vhdPropertyManager (so you can inspect the parent, etc.)
Returns:
TRUE to agree for removal; FALSE to protest/block the removal.

vhtBool vhdTestServiceBody::_handleAddPropertyScanImplem ( vhdPropertyRef  property  )  [protected, virtual]

___OPTINALLY_IMPLEMENT IT___

Each time a new vhdProperty is added ot the property tree kept by vhdPropertyManager the vhdPropertyManager goes to the vhdServiceManager and notifies each vhdServiceBody about a new property and its subtree using this method.

If you are just interested in the just added property and you do not care about its subproeprty tree then return FALSE which will tell the kernel to stop the scan.

Normally you should check the propery type and if you are interested in controlling or observing it you should add it respectively to your vhdPropertyController or vhdPropertyObserver.

This method is called right after the vhdPropery has been added.

Parameters:
property just added to the property tree kept by vhdPropertyManager (so you can inspect the parent, etc.)
Returns:
TRUE continue the scan; FALSE to stop the scan.

vhtBool vhdTestServiceBody::_handleRemovePropertyScanImplem ( vhdPropertyRef  property  )  [protected, virtual]

___OPTIONALLY_IMPLEMENT IT___

Each time new vhdProperty is about to be removed from the property tree kept by vhdPropertyManager the vhdPropertyManager goes to the vhdServiceManager and notifies each vhdServiceBody about a property that is about to be removed and its subtree using this method.

If you are just interested in the proeprty to be removed and you do not care about its subproeprty tree then return FALSE which will tell the kernel to stop the scan.

Normally here you should check the propery type and have a look into your vhdPropertyController or/and vhdPropertyObserver to find out if you were controlling or/and observing a property. This is your decision here then to remove it or still keep the property in vhdPropertyController or/and vhdPropertyObserver.

This method is called just before any vhdProperty is going to be removed.

Parameters:
property just about to be removed from the property tree kept by vhdPropertyManager (so you can inspect the parent, etc.)
Returns:
TRUE continue the scan; FALSE to stop the scan.

void vhdTestServiceBody::_handlePropertyChangeImplem ( vhdPropertyRef  property  )  [protected, virtual]

___OPTIONALLY_IMPLEMENT IT___

In vhdServiceContext of your service you will find access to your own vhdPropertyObserver. vhdPropertyObserver of your service should store all vhdProperies that you are interested to monitor/inspect during the service runtime.

HOW IT WORKS: If you modify any property you may wish to notify all vhdPropertyObservers interested in observing of that property. In order to notify observers you call property->notifyPropertyObservers(). notifyPropertyObservers() will go over all connected vhdPropertyObservers and call on each one propertyObserver->observeProperty(property), and this one in turn will be forwarded to this method below that by default is registerd to the default vhdProperyObserver of your service. As the notification propagation is synchronous you should better react fast.

Please not that once you get the property you do not know what type it is. You may perform powerful hierarchical filtering here. See the example below: void _observePropertyImplem( vhdPropertyRef property) { if (false) else if ( vhdREF_IS_OF_CLASS( vhdGeometryProperty, property)) { vhdGeometryPropertyRef geomProp = vhdREF_DYNAMIC_CAST( vhdGeometryProperty, property); ... } else if ( vhdREF_IS_OF_CLASS( vhdCameraProperty, property)) { vhdCameraPropertyRef camProp = vhdREF_DYNAMIC_CAST( vhdCameraProperty, property); ... } else if ( vhdREF_IS_OF_CLASS( vhdProperty, property)) { ... } else { vhdDIAG_WARNING("::unknown property"); } }

Parameters:
property that has changed (or somebody wants just to draw your attention to it)

vhtBool vhdTestServiceBody::_filterEventImplem ( vhdEventRef  event  )  [protected, virtual]

___OPTIONALLY_IMPLEMENT IT___

Allows for filtering of the events arriving to the vhdEventReceiver of this vhdServiceBody. You filter out event by returnign TRUE. By returning FALSE you let the event go to the _handleEventImplem() method.

SYNC EVENT DISPATCH FORBIDDEN: It is forbidden to call dispatchEvent() (SYNC) opertations from inside of this method. Calling such operations will cause vhdEventDispatcherException. On the other hand you may use postEvent() (ASYNC) opertations. This is to avoid recurrent dispatch opertations where initial dispatch causes handler to trigger another dispatch, etc. which may easily lead to deadlocks and long event handling chains prohibitive for RT simulation.

Hierarchical catching of events is similar to catching of exceptions in C++. You should always catch the root class at the end of the statement. vhtBool _filterEventImplem( vhdEventRef event) { if (false) else if ( vhdREF_IS_OF_CLASS( vhdMySimulationEvent, event)) { ... return TRUE; } else if ( vhdREF_IS_OF_CLASS( vhdSimulationEvent, event)) { ... return TRUE; } else if ( vhdREF_IS_OF_CLASS( vhdSystemEvent, event)) { ... return TRUE; }

return FALSE; }

Parameters:
event to be checked.
Returns:
TRUE to filter out (consume) the event; FALSE to let it go.

vhtBool vhdTestServiceBody::_handleEventImplem ( vhdEventRef  event  )  [protected, virtual]

___OPTIONALLY_IMPLEMENT IT___

If the event passed the filtering step defined by _filterEventImpl() then it is passed to this method for handling. By implementing this method you define an IMMEDIATE REACTION of your service to the events it receives. If you return TRUE it means you handled the event. IF you return FALSE it menas that event should be added to getServiceContext()->getEventReceiver() that is buffering unhandled events for you so that you can process them during _updateImplem().

SYNC EVENT DISPATCH FORBIDDEN: It is forbidden to call dispatchEvent() (SYNC) opertations from inside of this method. Calling such operations will cause vhdEventDispatcherException. On the other hand you may use postEvent() (ASYNC) opertations. This is to avoid recurrent dispatch opertations where initial dispatch causes handler to trigger another dispatch, etc. which may easily lead to deadlocks and long event handling chains prohibitive for RT simulation.

Hierarchical catching of events is similar to catching of exceptions in C++. You should always catch the root class at the end of the statement. vhtBool _filterEventImplem( vhdEventRef event) { if (false) else if ( vhdREF_IS_OF_CLASS( vhdMySimulationEvent, event)) { ... return TRUE; } else if ( vhdREF_IS_OF_CLASS( vhdSimulationEvent, event)) { ... return TRUE; } else if ( vhdREF_IS_OF_CLASS( vhdSystemEvent, event)) { ... return TRUE; }

return FALSE; }

Parameters:
event to handle.
Returns:
TRUE to tell the kernel that you handled the event; FALSE to tell the kernel to put the event to the getServiceContext()->getEventReceiver() for later handling inside _updateImplem() method.

bool vhdTestServiceBody::testCBHandler ( void *  self,
int  key,
int  value 
) [static, protected]

Callback implementing the default set of keyboard behaviour.


Member Data Documentation

vhdTestServiceBody::vhdCLASS_TYPE [private]

_Impl* vhdTestServiceBody::_pImpl [private]


Generated on Thu Jan 18 10:06:27 2007 for vhdPLUS by  doxygen 1.5.1-p1