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

#include <mtsInterfaceRequired.h>

Inheritance diagram for mtsInterfaceRequired:
mtsInterface cmnGenericObject

Classes

class  FunctionOrReceiverInfo
 

Public Types

enum  { DEFAULT_MAIL_BOX_AND_ARGUMENT_QUEUES_SIZE = 64 }
 
typedef FunctionOrReceiverInfo
< mtsFunctionBase
FunctionInfo
 
typedef FunctionOrReceiverInfo
< mtsEventReceiverVoid
ReceiverVoidInfo
 
typedef FunctionOrReceiverInfo
< mtsEventReceiverWrite
ReceiverWriteInfo
 

Public Member Functions

 mtsInterfaceRequired (const std::string &interfaceName, mtsComponent *component, mtsMailBox *mailBox, mtsRequiredType required=MTS_REQUIRED)
 
virtual ~mtsInterfaceRequired ()
 
const mtsInterfaceProvidedGetConnectedInterface (void) const
 
bool SetMailBoxSize (size_t desiredSize)
 
bool SetArgumentQueuesSize (size_t desiredSize)
 
bool SetMailBoxAndArgumentQueuesSize (size_t desiredSize)
 
bool ConnectTo (mtsInterfaceProvided *interfaceProvided)
 
mtsRequiredType IsRequired (void) const
 
bool AddSystemEventHandlers (void)
 
void DisableAllEvents (void)
 
void EnableAllEvents (void)
 
size_t ProcessMailBoxes (void)
 
void ToStream (std::ostream &outputStream) const
 
bool AddFunction (const std::string &functionName, mtsFunctionVoid &function, mtsRequiredType required=MTS_REQUIRED)
 
bool AddFunction (const std::string &functionName, mtsFunctionVoidReturn &function, mtsRequiredType required=MTS_REQUIRED)
 
bool AddFunction (const std::string &functionName, mtsFunctionWrite &function, mtsRequiredType required=MTS_REQUIRED)
 
bool AddFunction (const std::string &functionName, mtsFunctionWriteReturn &function, mtsRequiredType required=MTS_REQUIRED)
 
bool AddFunction (const std::string &functionName, mtsFunctionRead &function, mtsRequiredType required=MTS_REQUIRED)
 
bool AddFunction (const std::string &functionName, mtsFunctionQualifiedRead &function, mtsRequiredType required=MTS_REQUIRED)
 
bool AddEventReceiver (const std::string &eventName, mtsEventReceiverVoid &receiver, mtsRequiredType required=MTS_REQUIRED)
 
bool AddEventReceiver (const std::string &eventName, mtsEventReceiverWrite &receiver, mtsRequiredType required=MTS_REQUIRED)
 
mtsCommandVoidAddEventHandlerVoid (mtsCallableVoidBase *callable, const std::string &eventName, mtsEventQueueingPolicy queueingPolicy=MTS_INTERFACE_EVENT_POLICY)
 
template<class __classType >
mtsCommandVoidAddEventHandlerVoid (void(__classType::*method)(void), __classType *classInstantiation, const std::string &eventName, mtsEventQueueingPolicy queueingPolicy=MTS_INTERFACE_EVENT_POLICY)
 
mtsCommandVoidAddEventHandlerVoid (void(*function)(void), const std::string &eventName, mtsEventQueueingPolicy queueingPolicy=MTS_INTERFACE_EVENT_POLICY)
 
template<class __classType , class __argumentType >
mtsCommandWriteBaseAddEventHandlerWrite (void(__classType::*method)(const __argumentType &), __classType *classInstantiation, const std::string &eventName, mtsEventQueueingPolicy queueingPolicy=MTS_INTERFACE_EVENT_POLICY)
 
template<class __classType >
mtsCommandWriteBaseAddEventHandlerWriteGeneric (void(__classType::*method)(const mtsGenericObject &), __classType *classInstantiation, const std::string &eventName, mtsEventQueueingPolicy queueingPolicy=MTS_INTERFACE_EVENT_POLICY, mtsGenericObject *argumentPrototype=0)
 
bool RemoveEventHandlerVoid (const std::string &eventName)
 
bool RemoveEventHandlerWrite (const std::string &eventName)
 
virtual std::vector< std::string > GetNamesOfFunctions (void) const
 
virtual std::vector< std::string > GetNamesOfFunctionsVoid (void) const
 
virtual std::vector< std::string > GetNamesOfFunctionsVoidReturn (void) const
 
virtual std::vector< std::string > GetNamesOfFunctionsWrite (void) const
 
virtual std::vector< std::string > GetNamesOfFunctionsWriteReturn (void) const
 
virtual std::vector< std::string > GetNamesOfFunctionsRead (void) const
 
virtual std::vector< std::string > GetNamesOfFunctionsQualifiedRead (void) const
 
mtsFunctionVoidGetFunctionVoid (const std::string &functionName) const
 
mtsFunctionVoidReturnGetFunctionVoidReturn (const std::string &functionName) const
 
mtsFunctionWriteGetFunctionWrite (const std::string &functionName) const
 
mtsFunctionWriteReturnGetFunctionWriteReturn (const std::string &functionName) const
 
mtsFunctionReadGetFunctionRead (const std::string &functionName) const
 
mtsFunctionQualifiedReadGetFunctionQualifiedRead (const std::string &functionName) const
 
virtual std::vector< std::string > GetNamesOfEventHandlersVoid (void) const
 
virtual std::vector< std::string > GetNamesOfEventHandlersWrite (void) const
 
virtual mtsCommandVoidGetEventHandlerVoid (const std::string &eventName) const
 
virtual mtsCommandWriteBaseGetEventHandlerWrite (const std::string &eventName) const
 
- 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
 

Protected Types

typedef cmnNamedMap< FunctionInfoFunctionInfoMapType
 
typedef cmnNamedMap
< ReceiverVoidInfo
EventReceiverVoidMapType
 
typedef cmnNamedMap
< ReceiverWriteInfo
EventReceiverWriteMapType
 
typedef cmnNamedMap
< mtsCommandVoid
EventHandlerVoidMapType
 
typedef cmnNamedMap
< mtsCommandWriteBase
EventHandlerWriteMapType
 

Protected Member Functions

 mtsInterfaceRequired (void)
 
osaThreadSignalGetThreadSignal (void)
 
bool UseQueueBasedOnInterfacePolicy (mtsEventQueueingPolicy queueingPolicy, const std::string &methodName, const std::string &eventName)
 
bool AddEventHandlerToReceiver (const std::string &eventName, mtsCommandVoid *handler) const
 
bool AddEventHandlerToReceiver (const std::string &eventName, mtsCommandWriteBase *handler) const
 
void GetDescription (mtsInterfaceRequiredDescription &requiredInterfaceDescription)
 

Protected Attributes

mtsRequiredType Required
 
mtsMailBoxMailBox
 
const mtsInterfaceProvidedInterfaceProvided
 
size_t MailBoxSize
 
size_t ArgumentQueuesSize
 
osaThreadSignal ThreadSignalForBlockingCommands
 
FunctionInfoMapType FunctionsVoid
 
FunctionInfoMapType FunctionsVoidReturn
 
FunctionInfoMapType FunctionsWrite
 
FunctionInfoMapType FunctionsWriteReturn
 
FunctionInfoMapType FunctionsRead
 
FunctionInfoMapType FunctionsQualifiedRead
 
EventReceiverVoidMapType EventReceiversVoid
 
EventReceiverWriteMapType EventReceiversWrite
 
EventHandlerVoidMapType EventHandlersVoid
 
EventHandlerWriteMapType EventHandlersWrite
 
- Protected Attributes inherited from mtsInterface
const std::string Name
 
mtsComponentComponent
 

Friends

class mtsComponentProxy
 
class mtsComponentInterfaceProxyClient
 
class mtsManagerLocal
 
class mtsManagerLocalTest
 
class mtsEventReceiverBase
 
class mtsManagerComponentClient
 
class mtsSocketProxyClient
 
class mtsSocketProxyServer
 

Detailed Description

This class implements the required interface for a component (mtsComponent, mtsTask, ...). The required interface gets populated with pointers to 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 required interface may also have command object pointers for the following types of event handlers:

Void: no parameters Write: one const parameter

When the required interface of this component is connected to the provided interface of another component, the command object pointers are "bound" to command objects provided by the other component. Similarly, the event handlers are added as observers of events that are generated by the provided interface of the other component.

This implementation is simpler than the provided interface because we assume that a required interface is never connected to more than one provided interface, whereas a provided interface can be used by multiple required interfaces. While one can conceive of cases where it may be useful to have a required interface connect to multiple provided interfaces (e.g., running a robot simulation in parallel with a real robot), at this time it is not worth the trouble.

Member Typedef Documentation

Typedef for a map of event name and event handler (command object).

Member Enumeration Documentation

anonymous enum

Default size for mail boxes and argument queues used by event handlers.

Enumerator
DEFAULT_MAIL_BOX_AND_ARGUMENT_QUEUES_SIZE 

Constructor & Destructor Documentation

mtsInterfaceRequired::mtsInterfaceRequired ( void  )
protected

Default constructor. Does nothing, should not be used.

mtsInterfaceRequired::mtsInterfaceRequired ( const std::string &  interfaceName,
mtsComponent component,
mtsMailBox mailBox,
mtsRequiredType  required = MTS_REQUIRED 
)

Constructor. Sets the name, device pointer, and mailbox for queued events.

Parameters
interfaceNameName of required interface
mboxMailbox to use for queued events (for tasks); set to 0 for devices (i.e. mtsComponent) while tasks (derived from mtsTask) create a mailbox and then provide the mailbox to the required interface.
isRequiredUsed to indicate if the component should function even if this interface is not connected to a provided interface.
virtual mtsInterfaceRequired::~mtsInterfaceRequired ( )
virtual

Default destructor.

Member Function Documentation

bool mtsInterfaceRequired::AddEventHandlerToReceiver ( const std::string &  eventName,
mtsCommandVoid handler 
) const
protected
bool mtsInterfaceRequired::AddEventHandlerToReceiver ( const std::string &  eventName,
mtsCommandWriteBase handler 
) const
protected
mtsCommandVoid* mtsInterfaceRequired::AddEventHandlerVoid ( mtsCallableVoidBase callable,
const std::string &  eventName,
mtsEventQueueingPolicy  queueingPolicy = MTS_INTERFACE_EVENT_POLICY 
)
template<class __classType >
mtsCommandVoid* mtsInterfaceRequired::AddEventHandlerVoid ( void(__classType::*)(void)  method,
__classType *  classInstantiation,
const std::string &  eventName,
mtsEventQueueingPolicy  queueingPolicy = MTS_INTERFACE_EVENT_POLICY 
)
inline
mtsCommandVoid* mtsInterfaceRequired::AddEventHandlerVoid ( void(*)(void)  function,
const std::string &  eventName,
mtsEventQueueingPolicy  queueingPolicy = MTS_INTERFACE_EVENT_POLICY 
)
inline
template<class __classType , class __argumentType >
mtsCommandWriteBase * mtsInterfaceRequired::AddEventHandlerWrite ( void(__classType::*)(const __argumentType &)  method,
__classType *  classInstantiation,
const std::string &  eventName,
mtsEventQueueingPolicy  queueingPolicy = MTS_INTERFACE_EVENT_POLICY 
)
inline
template<class __classType >
mtsCommandWriteBase * mtsInterfaceRequired::AddEventHandlerWriteGeneric ( void(__classType::*)(const mtsGenericObject &)  method,
__classType *  classInstantiation,
const std::string &  eventName,
mtsEventQueueingPolicy  queueingPolicy = MTS_INTERFACE_EVENT_POLICY,
mtsGenericObject argumentPrototype = 0 
)
inline
bool mtsInterfaceRequired::AddEventReceiver ( const std::string &  eventName,
mtsEventReceiverVoid receiver,
mtsRequiredType  required = MTS_REQUIRED 
)
bool mtsInterfaceRequired::AddEventReceiver ( const std::string &  eventName,
mtsEventReceiverWrite receiver,
mtsRequiredType  required = MTS_REQUIRED 
)
bool mtsInterfaceRequired::AddFunction ( const std::string &  functionName,
mtsFunctionVoid function,
mtsRequiredType  required = MTS_REQUIRED 
)
bool mtsInterfaceRequired::AddFunction ( const std::string &  functionName,
mtsFunctionVoidReturn function,
mtsRequiredType  required = MTS_REQUIRED 
)
bool mtsInterfaceRequired::AddFunction ( const std::string &  functionName,
mtsFunctionWrite function,
mtsRequiredType  required = MTS_REQUIRED 
)
bool mtsInterfaceRequired::AddFunction ( const std::string &  functionName,
mtsFunctionWriteReturn function,
mtsRequiredType  required = MTS_REQUIRED 
)
bool mtsInterfaceRequired::AddFunction ( const std::string &  functionName,
mtsFunctionRead function,
mtsRequiredType  required = MTS_REQUIRED 
)
bool mtsInterfaceRequired::AddFunction ( const std::string &  functionName,
mtsFunctionQualifiedRead function,
mtsRequiredType  required = MTS_REQUIRED 
)
bool mtsInterfaceRequired::AddSystemEventHandlers ( void  )
Todo:
update documentation Bind command and events. This method needs to provide a user Id so that GetCommandVoid and GetCommandWrite (queued commands) know which mailbox to use. The user Id is provided by the provided interface when calling AllocateResources.
bool mtsInterfaceRequired::ConnectTo ( mtsInterfaceProvided interfaceProvided)
void mtsInterfaceRequired::DisableAllEvents ( void  )
void mtsInterfaceRequired::EnableAllEvents ( void  )
const mtsInterfaceProvided* mtsInterfaceRequired::GetConnectedInterface ( void  ) const
void mtsInterfaceRequired::GetDescription ( mtsInterfaceRequiredDescription requiredInterfaceDescription)
protected

Get description of this interface (with serialized argument information)

virtual mtsCommandVoid* mtsInterfaceRequired::GetEventHandlerVoid ( const std::string &  eventName) const
virtual

Find an event handler based on its name.

virtual mtsCommandWriteBase* mtsInterfaceRequired::GetEventHandlerWrite ( const std::string &  eventName) const
virtual
mtsFunctionQualifiedRead* mtsInterfaceRequired::GetFunctionQualifiedRead ( const std::string &  functionName) const
mtsFunctionRead* mtsInterfaceRequired::GetFunctionRead ( const std::string &  functionName) const
mtsFunctionVoid* mtsInterfaceRequired::GetFunctionVoid ( const std::string &  functionName) const

Find a function based on its name.

mtsFunctionVoidReturn* mtsInterfaceRequired::GetFunctionVoidReturn ( const std::string &  functionName) const
mtsFunctionWrite* mtsInterfaceRequired::GetFunctionWrite ( const std::string &  functionName) const
mtsFunctionWriteReturn* mtsInterfaceRequired::GetFunctionWriteReturn ( const std::string &  functionName) const
virtual std::vector<std::string> mtsInterfaceRequired::GetNamesOfEventHandlersVoid ( void  ) const
virtual

Get the names of event handlers that exist in this interface

virtual std::vector<std::string> mtsInterfaceRequired::GetNamesOfEventHandlersWrite ( void  ) const
virtual
virtual std::vector<std::string> mtsInterfaceRequired::GetNamesOfFunctions ( void  ) const
virtual

Get the names of commands required by this interface.

virtual std::vector<std::string> mtsInterfaceRequired::GetNamesOfFunctionsQualifiedRead ( void  ) const
virtual
virtual std::vector<std::string> mtsInterfaceRequired::GetNamesOfFunctionsRead ( void  ) const
virtual
virtual std::vector<std::string> mtsInterfaceRequired::GetNamesOfFunctionsVoid ( void  ) const
virtual
virtual std::vector<std::string> mtsInterfaceRequired::GetNamesOfFunctionsVoidReturn ( void  ) const
virtual
virtual std::vector<std::string> mtsInterfaceRequired::GetNamesOfFunctionsWrite ( void  ) const
virtual
virtual std::vector<std::string> mtsInterfaceRequired::GetNamesOfFunctionsWriteReturn ( void  ) const
virtual
osaThreadSignal* mtsInterfaceRequired::GetThreadSignal ( void  )
protected

For event receiver.

mtsRequiredType mtsInterfaceRequired::IsRequired ( void  ) const

Check if this interface is required or not for the component to function.

size_t mtsInterfaceRequired::ProcessMailBoxes ( void  )

Process any queued events.

bool mtsInterfaceRequired::RemoveEventHandlerVoid ( const std::string &  eventName)
bool mtsInterfaceRequired::RemoveEventHandlerWrite ( const std::string &  eventName)
bool mtsInterfaceRequired::SetArgumentQueuesSize ( size_t  desiredSize)

Set the desired size for all argument queues. If queueing has been enabled for this interface, each write event handler 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 event handlers mail box as there can't be more arguments queued than events. The reciprocal is not true as different events can be queued. So, the argument queue size should be lesser or equal to the mail box size.

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

bool mtsInterfaceRequired::SetMailBoxAndArgumentQueuesSize ( size_t  desiredSize)

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

bool mtsInterfaceRequired::SetMailBoxSize ( size_t  desiredSize)

Set the desired size for the event handlers mail box. If queueing has been enabled for this interface, a single mailbox is created to handle all events. Each write event handler manages it's own queue for the event 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 this required interface is connected to a provided interface.

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

Send a human readable description of the interface.

Reimplemented from cmnGenericObject.

bool mtsInterfaceRequired::UseQueueBasedOnInterfacePolicy ( mtsEventQueueingPolicy  queueingPolicy,
const std::string &  methodName,
const std::string &  eventName 
)
protected

Utility method to determine if an event handler 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 mtsComponentInterfaceProxyClient
friend
friend class mtsComponentProxy
friend
friend class mtsEventReceiverBase
friend
friend class mtsManagerComponentClient
friend
friend class mtsManagerLocal
friend
friend class mtsManagerLocalTest
friend
friend class mtsSocketProxyClient
friend
friend class mtsSocketProxyServer
friend

Member Data Documentation

size_t mtsInterfaceRequired::ArgumentQueuesSize
protected

Size to be used for argument queues

EventHandlerVoidMapType mtsInterfaceRequired::EventHandlersVoid
protected
EventHandlerWriteMapType mtsInterfaceRequired::EventHandlersWrite
protected
EventReceiverVoidMapType mtsInterfaceRequired::EventReceiversVoid
protected

Typedef for a receiver of void events

EventReceiverWriteMapType mtsInterfaceRequired::EventReceiversWrite
protected

Typedef for a receiver of write events

FunctionInfoMapType mtsInterfaceRequired::FunctionsQualifiedRead
protected

Typedef for a map of name of two argument command and name of command.

FunctionInfoMapType mtsInterfaceRequired::FunctionsRead
protected

Typedef for a map of name of one argument command and name of command.

FunctionInfoMapType mtsInterfaceRequired::FunctionsVoid
protected

Typedef for a map of name of zero argument command and name of command.

FunctionInfoMapType mtsInterfaceRequired::FunctionsVoidReturn
protected

Typedef for a map of name of zero argument command and name of command.

FunctionInfoMapType mtsInterfaceRequired::FunctionsWrite
protected

Typedef for a map of name of one argument command and name of command.

FunctionInfoMapType mtsInterfaceRequired::FunctionsWriteReturn
protected

Typedef for a map of name of one argument command and name of command.

const mtsInterfaceProvided* mtsInterfaceRequired::InterfaceProvided
protected

Pointer to provided interface that we are connected to.

mtsMailBox* mtsInterfaceRequired::MailBox
protected

Mailbox (if supported).

size_t mtsInterfaceRequired::MailBoxSize
protected

Size to be used for mailboxes

mtsRequiredType mtsInterfaceRequired::Required
protected

Indicates if the interface must be connected.

osaThreadSignal mtsInterfaceRequired::ThreadSignalForBlockingCommands
protected

Thread signal used for blocking calls. It is shared between all functions


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