cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
mtsInterfaceProvided Class Reference

#include <mtsInterfaceProvided.h>

Inheritance diagram for mtsInterfaceProvided:
mtsInterface cmnGenericObject

Public Types

enum  { DEFAULT_MAIL_BOX_AND_ARGUMENT_QUEUES_SIZE = 64 }
 
typedef mtsInterfaceProvided ThisType
 
typedef mtsInterface BaseType
 
typedef cmnNamedMap
< mtsCommandVoid
CommandVoidMapType
 
typedef cmnNamedMap
< mtsCommandVoidReturn
CommandVoidReturnMapType
 
typedef cmnNamedMap
< mtsCommandWriteBase
CommandWriteMapType
 
typedef cmnNamedMap
< mtsCommandWriteReturn
CommandWriteReturnMapType
 
typedef cmnNamedMap
< mtsCommandRead
CommandReadMapType
 
typedef cmnNamedMap
< mtsCommandQualifiedRead
CommandQualifiedReadMapType
 
typedef cmnNamedMap
< mtsMulticastCommandVoid
EventVoidMapType
 
typedef cmnNamedMap
< mtsMulticastCommandWriteBase
EventWriteMapType
 
typedef cmnNamedMap
< mtsCommandBase
CommandInternalMapType
 

Public Member Functions

 mtsInterfaceProvided (const std::string &name, mtsComponent *component, mtsInterfaceQueueingPolicy queueingPolicy, mtsCallableVoidBase *postCommandQueuedCallable=0, bool isProxy=false)
 
virtual ~mtsInterfaceProvided ()
 
void Cleanup (void)
 
void SetMailBoxSize (size_t desiredSize)
 
size_t GetMailBoxSize (void) const
 
void SetArgumentQueuesSize (size_t desiredSize)
 
size_t GetArgumentQueuesSize (void) const
 
void SetMailBoxAndArgumentQueuesSize (size_t desiredSize)
 
template<class __classType >
mtsCommandVoidAddCommandVoid (void(__classType::*method)(void), __classType *classInstantiation, const std::string &commandName, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
mtsCommandVoidAddCommandVoid (void(*function)(void), const std::string &commandName, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
template<class _elementType >
mtsCommandReadAddCommandReadState (const mtsStateTable &stateTable, const _elementType &stateData, const std::string &commandName)
 
template<class _elementType >
mtsCommandReadAddCommandReadStateDelayed (const mtsStateTable &stateTable, const _elementType &stateData, const std::string &commandName)
 
template<class _elementType >
mtsCommandWriteBaseAddCommandWriteState (const mtsStateTable &stateTable, const _elementType &stateData, const std::string &commandName, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
mtsInterfaceProvidedGetOriginalInterface (void) const
 
mtsInterfaceProvidedFindEndUserInterfaceByName (const std::string &userName)
 
std::vector< std::string > GetListOfUserNames (void) const
 
int GetNumberOfEndUsers () const
 
size_t ProcessMailBoxes (void)
 
void ToStream (std::ostream &outputStream) const
 
mtsInterfaceProvidedGetEndUserInterface (const std::string &userName)
 
std::vector< std::string > GetNamesOfCommands (void) const
 
std::vector< std::string > GetNamesOfCommandsVoid (void) const
 
std::vector< std::string > GetNamesOfCommandsVoidReturn (void) const
 
std::vector< std::string > GetNamesOfCommandsWrite (void) const
 
std::vector< std::string > GetNamesOfCommandsWriteReturn (void) const
 
std::vector< std::string > GetNamesOfCommandsRead (void) const
 
std::vector< std::string > GetNamesOfCommandsQualifiedRead (void) const
 
std::vector< std::string > GetNamesOfEventsVoid (void) const
 
std::vector< std::string > GetNamesOfEventsWrite (void) const
 
mtsCommandVoidGetCommandVoid (const std::string &commandName) const
 
mtsCommandVoidReturnGetCommandVoidReturn (const std::string &commandName) const
 
mtsCommandWriteBaseGetCommandWrite (const std::string &commandName) const
 
mtsCommandWriteReturnGetCommandWriteReturn (const std::string &commandName) const
 
mtsCommandReadGetCommandRead (const std::string &commandName) const
 
mtsCommandQualifiedReadGetCommandQualifiedRead (const std::string &commandName) const
 
mtsMulticastCommandVoidGetEventVoid (const std::string &eventName) const
 
mtsMulticastCommandWriteBaseGetEventWrite (const std::string &eventName) const
 
template<class __classType , class __resultType >
mtsCommandVoidReturnAddCommandVoidReturn (void(__classType::*method)(__resultType &), __classType *classInstantiation, const std::string &commandName, const __resultType &resultPrototype, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
template<class __classType , class __resultType >
mtsCommandVoidReturnAddCommandVoidReturn (void(__classType::*method)(__resultType &), __classType *classInstantiation, const std::string &commandName, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
template<class __classType , class __argumentType >
mtsCommandWriteBaseAddCommandWrite (void(__classType::*method)(const __argumentType &), __classType *classInstantiation, const std::string &commandName, const __argumentType &argumentPrototype, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
template<class __classType , class __argumentType >
mtsCommandWriteBaseAddCommandWrite (void(__classType::*method)(const __argumentType &), __classType *classInstantiation, const std::string &commandName, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
template<class __classType , class __argumentType , class __resultType >
mtsCommandWriteReturnAddCommandWriteReturn (void(__classType::*method)(const __argumentType &, __resultType &), __classType *classInstantiation, const std::string &commandName, const __argumentType &argumentPrototype, const __resultType &resultPrototype, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
template<class __classType , class __argumentType , class __resultType >
mtsCommandWriteReturnAddCommandWriteReturn (void(__classType::*method)(const __argumentType &, __resultType &), __classType *classInstantiation, const std::string &commandName, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
template<class __classType , class __argumentType >
mtsCommandReadAddCommandRead (void(__classType::*method)(__argumentType &) const, __classType *classInstantiation, const std::string &commandName, const __argumentType &argumentPrototype)
 
template<class __classType , class __argumentType >
mtsCommandReadAddCommandRead (void(__classType::*method)(__argumentType &) const, __classType *classInstantiation, const std::string &commandName)
 
template<class __classType , class __argument1Type , class __argument2Type >
mtsCommandQualifiedReadAddCommandQualifiedRead (void(__classType::*method)(const __argument1Type &, __argument2Type &) const, __classType *classInstantiation, const std::string &commandName, const __argument1Type &argument1Prototype, const __argument2Type &argument2Prototype)
 
template<class __classType , class __argument1Type , class __argument2Type >
mtsCommandQualifiedReadAddCommandQualifiedRead (void(__classType::*method)(const __argument1Type &, __argument2Type &) const, __classType *classInstantiation, const std::string &commandName)
 
template<class __classType , class __argumentType , class __filteredType >
mtsCommandWriteBaseAddCommandFilteredWrite (void(__classType::*premethod)(const __argumentType &, __filteredType &) const, void(__classType::*method)(const __filteredType &), __classType *classInstantiation, const std::string &commandName, const __argumentType &argumentPrototype, const __filteredType &filteredPrototype, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
template<class __classType , class __argumentType , class __filteredType >
mtsCommandWriteBaseAddCommandFilteredWrite (void(__classType::*premethod)(const __argumentType &, __filteredType &) const, void(__classType::*method)(const __filteredType &), __classType *classInstantiation, const std::string &commandName, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
mtsCommandVoidAddEventVoid (const std::string &eventName)
 
bool AddEventVoid (mtsFunctionVoid &eventTrigger, const std::string &eventName)
 
template<class __argumentType >
mtsCommandWriteBaseAddEventWrite (const std::string &eventName, const __argumentType &argumentPrototype)
 
template<class __argumentType >
bool AddEventWrite (mtsFunctionWrite &eventTrigger, const std::string &eventName, const __argumentType &argumentPrototype)
 
mtsCommandWriteBaseAddEventWriteGeneric (const std::string &eventName, const mtsGenericObject &argumentPrototype)
 
bool AddEventWriteGeneric (mtsFunctionWrite &eventTrigger, const std::string &eventName, const mtsGenericObject &argumentPrototype)
 
bool AddObserver (const std::string &eventName, mtsCommandVoid *handler)
 
bool AddObserver (const std::string &eventName, mtsCommandWriteBase *handler)
 
void AddObserverList (const mtsEventHandlerList &argin, mtsEventHandlerList &argout)
 
bool RemoveObserver (const std::string &eventName, mtsCommandVoid *handler)
 
bool RemoveObserver (const std::string &eventName, mtsCommandWriteBase *handler)
 
void RemoveObserverList (const mtsEventHandlerList &argin, mtsEventHandlerList &argout)
 
- Public Member Functions inherited from mtsInterface
 mtsInterface (const std::string &interfaceName, mtsComponent *component)
 
virtual ~mtsInterface ()
 
const std::string & GetName (void) const
 
const std::string GetFullName (void) const
 
const mtsComponentGetComponent (void) const
 
const std::string & GetComponentName (void) const
 
- Public Member Functions inherited from cmnGenericObject
virtual ~cmnGenericObject (void)
 
virtual const
cmnClassServicesBase
Services (void) const =0
 
bool ReconstructFrom (const cmnGenericObject &other)
 
std::string ToString (void) const
 
virtual void ToStreamRaw (std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
 
virtual bool FromStreamRaw (std::istream &inputStream, const char delimiter= ' ')
 
virtual void SerializeRaw (std::ostream &outputStream) const
 
virtual void DeSerializeRaw (std::istream &inputStream)
 
virtual cmnLogger::StreamBufTypeGetLogMultiplexer (void) const
 
virtual size_t ScalarNumber (void) const
 
virtual bool ScalarNumberIsFixed (void) const
 
virtual double Scalar (const size_t CMN_UNUSED(index)) const throw (std::out_of_range)
 
virtual std::string ScalarDescription (const size_t CMN_UNUSED(index), const std::string &CMN_UNUSED(userDescription)) const
 

Static Public Member Functions

static bool IsSystemEventVoid (const std::string &name)
 

Protected Types

typedef std::pair< size_t,
ThisType * > 
InterfaceProvidedCreatedPairType
 
typedef std::list
< InterfaceProvidedCreatedPairType
InterfaceProvidedCreatedListType
 

Protected Member Functions

 mtsInterfaceProvided (mtsInterfaceProvided *interfaceProvided, const std::string &userName, size_t mailBoxSize, size_t argumentQueuesSize)
 
mtsInterfaceProvidedRemoveEndUserInterface (mtsInterfaceProvided *interfaceProvided, const std::string &userName)
 
template<class _MapType , class _QueuedType >
void CloneCommands (const std::string &cmdType, const _MapType &CommandMapIn, _MapType &CommandMapOut)
 
bool UseQueueBasedOnInterfacePolicy (mtsCommandQueueingPolicy queueingPolicy, const std::string &methodName, const std::string &commandName)
 
mtsMailBoxGetMailBox (void)
 
mtsCommandVoidAddCommandVoid (mtsCallableVoidBase *callable, const std::string &name, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
mtsCommandVoidReturnAddCommandVoidReturn (mtsCallableVoidReturnBase *callable, const std::string &name, const mtsGenericObject *resultPrototype, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
mtsCommandWriteBaseAddCommandWrite (mtsCommandWriteBase *command, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
mtsCommandWriteReturnAddCommandWriteReturn (mtsCallableWriteReturnBase *callable, const std::string &name, const mtsGenericObject *argumentPrototype, const mtsGenericObject *resultPrototype, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
mtsCommandWriteBaseAddCommandFilteredWrite (mtsCommandQualifiedRead *filter, mtsCommandWriteBase *command, mtsCommandQueueingPolicy queueingPolicy=MTS_INTERFACE_COMMAND_POLICY)
 
mtsCommandReadAddCommandRead (mtsCallableReadBase *callable, const std::string &name, const mtsGenericObject *argumentPrototype)
 
mtsCommandQualifiedReadAddCommandQualifiedRead (mtsCallableQualifiedReadBase *callable, const std::string &name, const mtsGenericObject *argument1Prototype, const mtsGenericObject *argument2Prototype)
 
bool AddEvent (const std::string &commandName, mtsMulticastCommandVoid *generator)
 
bool AddEvent (const std::string &commandName, mtsMulticastCommandWriteBase *generator)
 
bool AddSystemEvents (void)
 
bool GetDescription (mtsInterfaceProvidedDescription &providedInterfaceDescription)
 
mtsCommandVoidAddCommandVoid (mtsCommandVoid *command)
 
mtsCommandVoidReturnAddCommandVoidReturn (mtsCommandVoidReturn *command)
 
mtsCommandWriteReturnAddCommandWriteReturn (mtsCommandWriteReturn *command)
 
mtsCommandReadAddCommandRead (mtsCommandRead *command)
 
mtsCommandQualifiedReadAddCommandQualifiedRead (mtsCommandQualifiedRead *command)
 

Static Protected Member Functions

static std::string GenerateEndUserInterfaceName (const mtsInterfaceProvided *originalInterface, const std::string &userName)
 

Protected Attributes

InterfaceProvidedCreatedListType InterfacesProvidedCreated
 
bool IsProxy
 
mtsMailBoxMailBox
 
mtsInterfaceQueueingPolicy QueueingPolicy
 
size_t MailBoxSize
 
size_t ArgumentQueuesSize
 
mtsCommandVoidBlockingCommandExecuted
 
mtsCommandVoidBlockingCommandReturnExecuted
 
ThisTypeOriginalInterface
 
bool EndUserInterface
 
std::string UserName
 
size_t UserCounter
 
CommandVoidMapType CommandsVoid
 
CommandVoidReturnMapType CommandsVoidReturn
 
CommandWriteMapType CommandsWrite
 
CommandWriteReturnMapType CommandsWriteReturn
 
CommandReadMapType CommandsRead
 
CommandQualifiedReadMapType CommandsQualifiedRead
 
EventVoidMapType EventVoidGenerators
 
EventWriteMapType EventWriteGenerators
 
CommandInternalMapType CommandsInternal
 
mtsCallableVoidBasePostCommandQueuedCallable
 
- Protected Attributes inherited from mtsInterface
const std::string Name
 
mtsComponentComponent
 

Friends

class mtsComponentProxy
 
class mtsManagerLocal
 
class mtsComponent
 
class mtsManagerComponentClient
 
class mtsComponentAddLatency
 
class mtsSocketProxyClient
 
class mtsSocketProxyServer
 

Detailed Description

This class implements the provided interface for a component, mtsComponent. It provides services via command objects, which have four signatures:

Void: no parameters Read: one non-const parameter Write: one const parameter QualifiedRead: one non-const (read) and one const (write) parameter

The interface can also generate two types of events:

Void: no parameters Write: one const parameter

Clients (components) connect to this interface and obtain pointers to command objects. They can then execute these command objects to obtain the desired service. Clients can also provide event handlers to the interface – these are actually command objects that the device will execute when the particular event occurs (Observer Pattern).

This class includes both public and protected members functions. The public members are for access by connected clients. The protected members are for access by the owning device, in order to populate the lists of commands and events.

Note that this class is instantiated by both mtsComponent and its derived mtsTask classes, via the virtual method AddInterfaceProvided. Because mtsTask (and its derived classes) have a thread, they (by default) instantiate mtsInterfaceProvided with a queueing policy of MTS_COMMANDS_SHOULD_BE_QUEUED. In this case, the provided interface uses queues for Void and Write commands in order to maintain thread safety. Furthermore, a separate queue is allocated for each client that connects to this interface – this ensures that each queue has only a single writer (the client) and a single reader (this task), so thread-safety can be achieved without relying on potentially blocking mutexes. This is implemented by the GetEndUserInterface method, which returns a new mtsInterfaceProvided object to the client component. In other words, the original provided interface acts as a provided interface factory that generates a "copy" of the provided interface for every client. Note that GetEndUserInterface is protected, and should only be called by mtsComponent.

Member Typedef Documentation

Base class

Typedef for a map of internally-generated commands (only used for garbage collection).

Typedef for a map of name and qualified read commands.

Typedef for a map of name and read commands.

Typedef for a map of name and void commands.

Typedef for a map of name and void return commands.

Typedef for a map of name and write commands.

Typedef for a map of name and write return commands.

Typedef for a map of event name and void event generators.

Typedef for a map of event name and write event generators.

typedef std::pair<size_t, ThisType *> mtsInterfaceProvided::InterfaceProvidedCreatedPairType
protected

types and containers to store interfaces cloned for thread safety

This type

Member Enumeration Documentation

anonymous enum

Default size for mail boxes and argument queues

Enumerator
DEFAULT_MAIL_BOX_AND_ARGUMENT_QUEUES_SIZE 

Constructor & Destructor Documentation

mtsInterfaceProvided::mtsInterfaceProvided ( const std::string &  name,
mtsComponent component,
mtsInterfaceQueueingPolicy  queueingPolicy,
mtsCallableVoidBase postCommandQueuedCallable = 0,
bool  isProxy = false 
)

Constructor with a post queued command. This constructor is used by mtsTaskFromSignal to provide the command used everytime one uses a queued command of this interface (write and void commands). The post command queued command in this case performs a wakeup (signal) on the task's thread.

virtual mtsInterfaceProvided::~mtsInterfaceProvided ( )
virtual

Default Destructor.

mtsInterfaceProvided::mtsInterfaceProvided ( mtsInterfaceProvided interfaceProvided,
const std::string &  userName,
size_t  mailBoxSize,
size_t  argumentQueuesSize 
)
protected

Constructor used to create an end user interface (object factory) for each user (interface required). This constructor is called by the method GetEndUserInterface.

Member Function Documentation

template<class __classType , class __argumentType , class __filteredType >
mtsCommandWriteBase* mtsInterfaceProvided::AddCommandFilteredWrite ( void(__classType::*)(const __argumentType &, __filteredType &) const  premethod,
void(__classType::*)(const __filteredType &)  method,
__classType *  classInstantiation,
const std::string &  commandName,
const __argumentType &  argumentPrototype,
const __filteredType &  filteredPrototype,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
inline
template<class __classType , class __argumentType , class __filteredType >
mtsCommandWriteBase* mtsInterfaceProvided::AddCommandFilteredWrite ( void(__classType::*)(const __argumentType &, __filteredType &) const  premethod,
void(__classType::*)(const __filteredType &)  method,
__classType *  classInstantiation,
const std::string &  commandName,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
inline
mtsCommandWriteBase* mtsInterfaceProvided::AddCommandFilteredWrite ( mtsCommandQualifiedRead filter,
mtsCommandWriteBase command,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
protected
template<class __classType , class __argument1Type , class __argument2Type >
mtsCommandQualifiedRead* mtsInterfaceProvided::AddCommandQualifiedRead ( void(__classType::*)(const __argument1Type &, __argument2Type &) const  method,
__classType *  classInstantiation,
const std::string &  commandName,
const __argument1Type &  argument1Prototype,
const __argument2Type &  argument2Prototype 
)
inline
template<class __classType , class __argument1Type , class __argument2Type >
mtsCommandQualifiedRead* mtsInterfaceProvided::AddCommandQualifiedRead ( void(__classType::*)(const __argument1Type &, __argument2Type &) const  method,
__classType *  classInstantiation,
const std::string &  commandName 
)
inline
mtsCommandQualifiedRead* mtsInterfaceProvided::AddCommandQualifiedRead ( mtsCallableQualifiedReadBase callable,
const std::string &  name,
const mtsGenericObject argument1Prototype,
const mtsGenericObject argument2Prototype 
)
protected
mtsCommandQualifiedRead* mtsInterfaceProvided::AddCommandQualifiedRead ( mtsCommandQualifiedRead command)
protected
template<class __classType , class __argumentType >
mtsCommandRead* mtsInterfaceProvided::AddCommandRead ( void(__classType::*)(__argumentType &) const  method,
__classType *  classInstantiation,
const std::string &  commandName,
const __argumentType &  argumentPrototype 
)
inline

Add a read command to the provided interface based on a method and an object instantiating the method. This method creates an mtsCommandRead object and then calls the AddCommandRead virtual method.

Parameters
methodmethod pointer
classInstantiationan instantiation of the method's class
commandNamename as it should appear in the interface
argumentPrototypeexample of argument that should be used to call this method. This is especially useful for commands using objects of variable size (dynamic allocation)
Returns
pointer on the newly created and added command, null pointer (0) if creation or addition failed (name already used)
template<class __classType , class __argumentType >
mtsCommandRead* mtsInterfaceProvided::AddCommandRead ( void(__classType::*)(__argumentType &) const  method,
__classType *  classInstantiation,
const std::string &  commandName 
)
inline
mtsCommandRead* mtsInterfaceProvided::AddCommandRead ( mtsCallableReadBase callable,
const std::string &  name,
const mtsGenericObject argumentPrototype 
)
protected
mtsCommandRead* mtsInterfaceProvided::AddCommandRead ( mtsCommandRead command)
protected
template<class _elementType >
mtsCommandRead * mtsInterfaceProvided::AddCommandReadState ( const mtsStateTable stateTable,
const _elementType &  stateData,
const std::string &  commandName 
)

Adds command objects to read from the state table (by default, all tasks have state tables, but it is possible to have a state table in a device). Note that there are two command objects: a 'read' command to get the latest value, and a 'qualified read' command to get the value at the specified time.

template<class _elementType >
mtsCommandRead * mtsInterfaceProvided::AddCommandReadStateDelayed ( const mtsStateTable stateTable,
const _elementType &  stateData,
const std::string &  commandName 
)

Adds command objects to read from the state table with a delay. The commands created ('read' and 'qualified read') are similar to the commands added using AddCommandReadState except that instead of reading from the head, these commands read from head - delay.

template<class __classType >
mtsCommandVoid* mtsInterfaceProvided::AddCommandVoid ( void(__classType::*)(void)  method,
__classType *  classInstantiation,
const std::string &  commandName,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
inline

Add a void command to the provided interface based on a method and an object instantiating the method. This method creates an mtsCommandVoid object and then calls the AddCommandVoid virtual method; this method is overridden in mtsInterfaceProvided to queue the void command (thereby ensuring thread safety).

Parameters
methodmethod pointer
classInstantiationan instantiation of the method's class
commandNamename as it should appear in the interface
Returns
pointer on the newly created and added command, null pointer (0) if creation or addition failed (name already used)
mtsCommandVoid* mtsInterfaceProvided::AddCommandVoid ( void(*)(void)  function,
const std::string &  commandName,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
inline

Add a void command to the provided interface based on a void function. This method creates an mtsCommandVoid object and then calls the AddCommandVoid virtual method; this method is overridden in mtsInterfaceProvided to queue the void command (thereby ensuring thread safety).

Parameters
functionvoid function pointer
commandNamename as it should appear in the interface
Returns
pointer on the newly created and added command, null pointer (0) if creation or addition failed (name already used)
mtsCommandVoid* mtsInterfaceProvided::AddCommandVoid ( mtsCallableVoidBase callable,
const std::string &  name,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
protected
mtsCommandVoid* mtsInterfaceProvided::AddCommandVoid ( mtsCommandVoid command)
protected

Methods to add an existing command to the interface. These methods will not check the queueing policy of the interface nor the type of command (queued or not). These methods must be used with extreme caution since they bypass the built-in thread safety mechanisms.

template<class __classType , class __resultType >
mtsCommandVoidReturn* mtsInterfaceProvided::AddCommandVoidReturn ( void(__classType::*)(__resultType &)  method,
__classType *  classInstantiation,
const std::string &  commandName,
const __resultType &  resultPrototype,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
inline

Add a void command with result.

template<class __classType , class __resultType >
mtsCommandVoidReturn* mtsInterfaceProvided::AddCommandVoidReturn ( void(__classType::*)(__resultType &)  method,
__classType *  classInstantiation,
const std::string &  commandName,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
inline
mtsCommandVoidReturn* mtsInterfaceProvided::AddCommandVoidReturn ( mtsCallableVoidReturnBase callable,
const std::string &  name,
const mtsGenericObject resultPrototype,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
protected
mtsCommandVoidReturn* mtsInterfaceProvided::AddCommandVoidReturn ( mtsCommandVoidReturn command)
protected
template<class __classType , class __argumentType >
mtsCommandWriteBase* mtsInterfaceProvided::AddCommandWrite ( void(__classType::*)(const __argumentType &)  method,
__classType *  classInstantiation,
const std::string &  commandName,
const __argumentType &  argumentPrototype,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
inline

Add a write command to the provided interface based on a method and an object instantiating the method. This method creates an mtsCommandWrite object and then calls the AddCommandWrite virtual method; this method is overridden in mtsInterfaceProvided to queue the write command (thereby ensuring thread safety).

Parameters
methodmethod pointer
classInstantiationan instantiation of the method's class
commandNamename as it should appear in the interface
argumentPrototypeexample of argument that should be used to call this method. This is especially useful for commands using objects of variable size (dynamic allocation)
Returns
pointer on the newly created and added command, null pointer (0) if creation or addition failed (name already used)
template<class __classType , class __argumentType >
mtsCommandWriteBase* mtsInterfaceProvided::AddCommandWrite ( void(__classType::*)(const __argumentType &)  method,
__classType *  classInstantiation,
const std::string &  commandName,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
inline
mtsCommandWriteBase* mtsInterfaceProvided::AddCommandWrite ( mtsCommandWriteBase command,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
protected
template<class __classType , class __argumentType , class __resultType >
mtsCommandWriteReturn* mtsInterfaceProvided::AddCommandWriteReturn ( void(__classType::*)(const __argumentType &, __resultType &)  method,
__classType *  classInstantiation,
const std::string &  commandName,
const __argumentType &  argumentPrototype,
const __resultType &  resultPrototype,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
inline

Add a write command with result.

template<class __classType , class __argumentType , class __resultType >
mtsCommandWriteReturn* mtsInterfaceProvided::AddCommandWriteReturn ( void(__classType::*)(const __argumentType &, __resultType &)  method,
__classType *  classInstantiation,
const std::string &  commandName,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
inline
mtsCommandWriteReturn* mtsInterfaceProvided::AddCommandWriteReturn ( mtsCallableWriteReturnBase callable,
const std::string &  name,
const mtsGenericObject argumentPrototype,
const mtsGenericObject resultPrototype,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)
protected
mtsCommandWriteReturn* mtsInterfaceProvided::AddCommandWriteReturn ( mtsCommandWriteReturn command)
protected
template<class _elementType >
mtsCommandWriteBase * mtsInterfaceProvided::AddCommandWriteState ( const mtsStateTable stateTable,
const _elementType &  stateData,
const std::string &  commandName,
mtsCommandQueueingPolicy  queueingPolicy = MTS_INTERFACE_COMMAND_POLICY 
)

Adds command object to write to state table.

bool mtsInterfaceProvided::AddEvent ( const std::string &  commandName,
mtsMulticastCommandVoid generator 
)
protected
bool mtsInterfaceProvided::AddEvent ( const std::string &  commandName,
mtsMulticastCommandWriteBase generator 
)
protected
mtsCommandVoid* mtsInterfaceProvided::AddEventVoid ( const std::string &  eventName)

Add events to the interface. This method creates the multicast command used to trigger all the observers for the event. These methods are used to populate the provided interface.

bool mtsInterfaceProvided::AddEventVoid ( mtsFunctionVoid eventTrigger,
const std::string &  eventName 
)
template<class __argumentType >
mtsCommandWriteBase * mtsInterfaceProvided::AddEventWrite ( const std::string &  eventName,
const __argumentType &  argumentPrototype 
)
template<class __argumentType >
bool mtsInterfaceProvided::AddEventWrite ( mtsFunctionWrite eventTrigger,
const std::string &  eventName,
const __argumentType &  argumentPrototype 
)
mtsCommandWriteBase* mtsInterfaceProvided::AddEventWriteGeneric ( const std::string &  eventName,
const mtsGenericObject argumentPrototype 
)
bool mtsInterfaceProvided::AddEventWriteGeneric ( mtsFunctionWrite eventTrigger,
const std::string &  eventName,
const mtsGenericObject argumentPrototype 
)
bool mtsInterfaceProvided::AddObserver ( const std::string &  eventName,
mtsCommandVoid handler 
)

Add an observer for the specified event. These methods are used to connect to an existing provided interface, ideally from a required interface.

Parameters
nameName of event
handlercommand object that implements event handler
Returns
true if successful; false otherwise
bool mtsInterfaceProvided::AddObserver ( const std::string &  eventName,
mtsCommandWriteBase handler 
)
void mtsInterfaceProvided::AddObserverList ( const mtsEventHandlerList argin,
mtsEventHandlerList argout 
)
bool mtsInterfaceProvided::AddSystemEvents ( void  )
protected
void mtsInterfaceProvided::Cleanup ( void  )

The member function that is executed once the task terminates. This does some cleanup work

template<class _MapType , class _QueuedType >
void mtsInterfaceProvided::CloneCommands ( const std::string &  cmdType,
const _MapType &  CommandMapIn,
_MapType &  CommandMapOut 
)
protected

Templated utility method to clone commands

mtsInterfaceProvided* mtsInterfaceProvided::FindEndUserInterfaceByName ( const std::string &  userName)

Find an end-user interface given a client name.

static std::string mtsInterfaceProvided::GenerateEndUserInterfaceName ( const mtsInterfaceProvided originalInterface,
const std::string &  userName 
)
staticprotected
size_t mtsInterfaceProvided::GetArgumentQueuesSize ( void  ) const
inline

Get the current argument queues size.

mtsCommandQualifiedRead* mtsInterfaceProvided::GetCommandQualifiedRead ( const std::string &  commandName) const
mtsCommandRead* mtsInterfaceProvided::GetCommandRead ( const std::string &  commandName) const
mtsCommandVoid* mtsInterfaceProvided::GetCommandVoid ( const std::string &  commandName) const

Find a command based on its name.

mtsCommandVoidReturn* mtsInterfaceProvided::GetCommandVoidReturn ( const std::string &  commandName) const
mtsCommandWriteBase* mtsInterfaceProvided::GetCommandWrite ( const std::string &  commandName) const
mtsCommandWriteReturn* mtsInterfaceProvided::GetCommandWriteReturn ( const std::string &  commandName) const
bool mtsInterfaceProvided::GetDescription ( mtsInterfaceProvidedDescription providedInterfaceDescription)
protected

Get description of this interface (with serialized argument information)

mtsInterfaceProvided* mtsInterfaceProvided::GetEndUserInterface ( const std::string &  userName)

This method creates a copy of the existing interface. The copy is required for each new user, i.e. for each required interface connected to this provided interface if queueing has been enabled. This method should not be called on a provided interface if queueing is not enable. The newly created provided interface is created using the current MailBoxSize (see SetMailBoxSize) and ArgumentQueuesSize (see SetArgumentQueuesSize). Commands and events should only be added to the original interface.

Parameters
userNamename of the required interface being connected to this provided interface. This information is used for logging only.
Returns
pointer to end-user interface (0 if error)
mtsMulticastCommandVoid* mtsInterfaceProvided::GetEventVoid ( const std::string &  eventName) const

Find an event based on its name.

mtsMulticastCommandWriteBase* mtsInterfaceProvided::GetEventWrite ( const std::string &  eventName) const
std::vector<std::string> mtsInterfaceProvided::GetListOfUserNames ( void  ) const

Returns a list of user names (name of connected required interface). Used to remove provided interface in a thread-safe way

mtsMailBox* mtsInterfaceProvided::GetMailBox ( void  )
protected
size_t mtsInterfaceProvided::GetMailBoxSize ( void  ) const
inline

Get the current mailbox size.

std::vector<std::string> mtsInterfaceProvided::GetNamesOfCommands ( void  ) const

Get the names of commands provided by this interface.

std::vector<std::string> mtsInterfaceProvided::GetNamesOfCommandsQualifiedRead ( void  ) const
std::vector<std::string> mtsInterfaceProvided::GetNamesOfCommandsRead ( void  ) const
std::vector<std::string> mtsInterfaceProvided::GetNamesOfCommandsVoid ( void  ) const
std::vector<std::string> mtsInterfaceProvided::GetNamesOfCommandsVoidReturn ( void  ) const
std::vector<std::string> mtsInterfaceProvided::GetNamesOfCommandsWrite ( void  ) const
std::vector<std::string> mtsInterfaceProvided::GetNamesOfCommandsWriteReturn ( void  ) const
std::vector<std::string> mtsInterfaceProvided::GetNamesOfEventsVoid ( void  ) const

Get the names of events coming from this interface

std::vector<std::string> mtsInterfaceProvided::GetNamesOfEventsWrite ( void  ) const
int mtsInterfaceProvided::GetNumberOfEndUsers ( ) const

Return number of active end-user interfaces.

mtsInterfaceProvided* mtsInterfaceProvided::GetOriginalInterface ( void  ) const

Get the original interface. This allows to retrieve the original interface from a copy created using GetEndUserInterface.

static bool mtsInterfaceProvided::IsSystemEventVoid ( const std::string &  name)
static

Returns true if the event is a system event (e.g., BlockingCommandExecuted or BlockingCommandReturnExecuted)

size_t mtsInterfaceProvided::ProcessMailBoxes ( void  )

Method used to process all commands queued in mailboxes. This method should only be used by the component that owns the interface for thread safety.

mtsInterfaceProvided* mtsInterfaceProvided::RemoveEndUserInterface ( mtsInterfaceProvided interfaceProvided,
const std::string &  userName 
)
protected

This method deletes the end-user interface created by GetEndUserInterface. Note that there are two mtsInterfaceProvided objects: (1) the interfaceProvided parameter, which should be a pointer to the end-user interface to be removed (2) the "this" pointer, which should point to the original interface.

Parameters
interfaceProvidedthe end-user interface to be removed
userNamename of the required interface (used for logging only)
Returns
0 if successful, interfaceProvided otherwise
bool mtsInterfaceProvided::RemoveObserver ( const std::string &  eventName,
mtsCommandVoid handler 
)

Remove an observer for the specified event. These methods are used when disconnecting from the provided interface.

Parameters
nameName of event
handlercommand object that implements event handler
Returns
true if successful; false otherwise
bool mtsInterfaceProvided::RemoveObserver ( const std::string &  eventName,
mtsCommandWriteBase handler 
)
void mtsInterfaceProvided::RemoveObserverList ( const mtsEventHandlerList argin,
mtsEventHandlerList argout 
)
void mtsInterfaceProvided::SetArgumentQueuesSize ( size_t  desiredSize)

Set the desired size for all argument queues. If queueing has been enabled for this interface, each write command (write or write with return) manages it's own queue of arguments. The command itself is queued in the interface mailbox (see SetMailBoxSize) and the argument is queued by the command itself. There is no reason to have an argument queue larger than the command mail box as there can't be more arguments queued than commands. The reciprocal is not true as different commands can be queued. So, the argument queue size should be lesser or equal to the mail box size.

The size of argument queues can't be changed while being used (i.e. while any required interface is connected to the provided interface.

void mtsInterfaceProvided::SetMailBoxAndArgumentQueuesSize ( size_t  desiredSize)

Set the desired size for the command mail box and argument queues. See SetMailBoxSize and SetArgumentQueuesSize.

void mtsInterfaceProvided::SetMailBoxSize ( size_t  desiredSize)

Set the desired size for the command mail box. If queueing has been enabled for this interface, a single mailbox is created for each connected required interface. All commands provided by this interface share a single mailbox but each write command (write and write with return) manages it's own queue for the command argument. To change the argument queue size, use SetArgumentQueuesSize. To change both parameters at once, use SetMailBoxAndArgumentQueuesSize.

The size of the mail box can't be changed while being used (i.e. while any required interface is connected to the provided interface.

void mtsInterfaceProvided::ToStream ( std::ostream &  outputStream) const
virtual

Send a human readable description of the interface.

Reimplemented from cmnGenericObject.

bool mtsInterfaceProvided::UseQueueBasedOnInterfacePolicy ( mtsCommandQueueingPolicy  queueingPolicy,
const std::string &  methodName,
const std::string &  commandName 
)
protected

Utility method to determine if a command should be queued or not based on the default policy for the interface and the user's requested policy. This method also generates a warning or error in the log if needed.

Friends And Related Function Documentation

friend class mtsComponent
friend
friend class mtsComponentAddLatency
friend
friend class mtsComponentProxy
friend
friend class mtsManagerComponentClient
friend
friend class mtsManagerLocal
friend
friend class mtsSocketProxyClient
friend
friend class mtsSocketProxyServer
friend

Member Data Documentation

size_t mtsInterfaceProvided::ArgumentQueuesSize
protected

Size to be used for argument queues

mtsCommandVoid* mtsInterfaceProvided::BlockingCommandExecuted
protected

Command to trigger void event for blocking commands.

mtsCommandVoid* mtsInterfaceProvided::BlockingCommandReturnExecuted
protected

Command to trigger void event for blocking commands with a return value.

CommandInternalMapType mtsInterfaceProvided::CommandsInternal
protected
CommandQualifiedReadMapType mtsInterfaceProvided::CommandsQualifiedRead
protected
CommandReadMapType mtsInterfaceProvided::CommandsRead
protected
CommandVoidMapType mtsInterfaceProvided::CommandsVoid
protected

Containers of commands

CommandVoidReturnMapType mtsInterfaceProvided::CommandsVoidReturn
protected
CommandWriteMapType mtsInterfaceProvided::CommandsWrite
protected
CommandWriteReturnMapType mtsInterfaceProvided::CommandsWriteReturn
protected
bool mtsInterfaceProvided::EndUserInterface
protected

Flag to indicate if this interface can be used directly or if it should be used as a factory to create a new interface. When the interface relies assumes queued commands, the first interface should be created as a factory or template. All users should use their own copy created using GetEndUserInterface().

EventVoidMapType mtsInterfaceProvided::EventVoidGenerators
protected
EventWriteMapType mtsInterfaceProvided::EventWriteGenerators
protected
InterfaceProvidedCreatedListType mtsInterfaceProvided::InterfacesProvidedCreated
protected
bool mtsInterfaceProvided::IsProxy
protected

Indicates if this interface is used to generate a proxy

mtsMailBox* mtsInterfaceProvided::MailBox
protected

Mailbox (if supported). Mailboxes should only be provided for end user provided interfaces (if needed). Factory interfaces should not use the mailbox.

size_t mtsInterfaceProvided::MailBoxSize
protected

Size to be used for mailboxes

ThisType* mtsInterfaceProvided::OriginalInterface
protected

If this interface was created using an existing one, keep a pointer on the original one.

mtsCallableVoidBase* mtsInterfaceProvided::PostCommandQueuedCallable
protected

Post command queued command

mtsInterfaceQueueingPolicy mtsInterfaceProvided::QueueingPolicy
protected

Flag to determine if by default void and write commands are queued.

size_t mtsInterfaceProvided::UserCounter
protected

Counter for number of users, i.e. number or required interfaces connected to this provided interface. This number should remain consistent with the size of created interfaces list.

std::string mtsInterfaceProvided::UserName
protected

Name of user for end user interface


The documentation for this class was generated from the following file: