cisst-saw
|
#include <mtsInterfaceRequired.h>
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 mtsInterfaceProvided * | GetConnectedInterface (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) |
mtsCommandVoid * | AddEventHandlerVoid (mtsCallableVoidBase *callable, const std::string &eventName, mtsEventQueueingPolicy queueingPolicy=MTS_INTERFACE_EVENT_POLICY) |
template<class __classType > | |
mtsCommandVoid * | AddEventHandlerVoid (void(__classType::*method)(void), __classType *classInstantiation, const std::string &eventName, mtsEventQueueingPolicy queueingPolicy=MTS_INTERFACE_EVENT_POLICY) |
mtsCommandVoid * | AddEventHandlerVoid (void(*function)(void), const std::string &eventName, mtsEventQueueingPolicy queueingPolicy=MTS_INTERFACE_EVENT_POLICY) |
template<class __classType , class __argumentType > | |
mtsCommandWriteBase * | AddEventHandlerWrite (void(__classType::*method)(const __argumentType &), __classType *classInstantiation, const std::string &eventName, mtsEventQueueingPolicy queueingPolicy=MTS_INTERFACE_EVENT_POLICY) |
template<class __classType > | |
mtsCommandWriteBase * | AddEventHandlerWriteGeneric (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 |
mtsFunctionVoid * | GetFunctionVoid (const std::string &functionName) const |
mtsFunctionVoidReturn * | GetFunctionVoidReturn (const std::string &functionName) const |
mtsFunctionWrite * | GetFunctionWrite (const std::string &functionName) const |
mtsFunctionWriteReturn * | GetFunctionWriteReturn (const std::string &functionName) const |
mtsFunctionRead * | GetFunctionRead (const std::string &functionName) const |
mtsFunctionQualifiedRead * | GetFunctionQualifiedRead (const std::string &functionName) const |
virtual std::vector< std::string > | GetNamesOfEventHandlersVoid (void) const |
virtual std::vector< std::string > | GetNamesOfEventHandlersWrite (void) const |
virtual mtsCommandVoid * | GetEventHandlerVoid (const std::string &eventName) const |
virtual mtsCommandWriteBase * | GetEventHandlerWrite (const std::string &eventName) const |
![]() | |
mtsInterface (const std::string &interfaceName, mtsComponent *component) | |
virtual | ~mtsInterface () |
const std::string & | GetName (void) const |
const std::string | GetFullName (void) const |
const mtsComponent * | GetComponent (void) const |
const std::string & | GetComponentName (void) const |
![]() | |
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::StreamBufType * | GetLogMultiplexer (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< FunctionInfo > | FunctionInfoMapType |
typedef cmnNamedMap < ReceiverVoidInfo > | EventReceiverVoidMapType |
typedef cmnNamedMap < ReceiverWriteInfo > | EventReceiverWriteMapType |
typedef cmnNamedMap < mtsCommandVoid > | EventHandlerVoidMapType |
typedef cmnNamedMap < mtsCommandWriteBase > | EventHandlerWriteMapType |
Protected Member Functions | |
mtsInterfaceRequired (void) | |
osaThreadSignal * | GetThreadSignal (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) |
Friends | |
class | mtsComponentProxy |
class | mtsComponentInterfaceProxyClient |
class | mtsManagerLocal |
class | mtsManagerLocalTest |
class | mtsEventReceiverBase |
class | mtsManagerComponentClient |
class | mtsSocketProxyClient |
class | mtsSocketProxyServer |
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.
|
protected |
Typedef for a map of event name and event handler (command object).
|
protected |
|
protected |
|
protected |
|
protected |
anonymous enum |
|
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.
interfaceName | Name of required interface |
mbox | Mailbox 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. |
isRequired | Used to indicate if the component should function even if this interface is not connected to a provided interface. |
|
virtual |
Default destructor.
|
protected |
|
protected |
mtsCommandVoid* mtsInterfaceRequired::AddEventHandlerVoid | ( | mtsCallableVoidBase * | callable, |
const std::string & | eventName, | ||
mtsEventQueueingPolicy | queueingPolicy = MTS_INTERFACE_EVENT_POLICY |
||
) |
|
inline |
|
inline |
|
inline |
|
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 | ) |
bool mtsInterfaceRequired::ConnectTo | ( | mtsInterfaceProvided * | interfaceProvided | ) |
void mtsInterfaceRequired::DisableAllEvents | ( | void | ) |
void mtsInterfaceRequired::EnableAllEvents | ( | void | ) |
const mtsInterfaceProvided* mtsInterfaceRequired::GetConnectedInterface | ( | void | ) | const |
|
protected |
Get description of this interface (with serialized argument information)
|
virtual |
Find an event handler based on its name.
|
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 |
Get the names of event handlers that exist in this interface
|
virtual |
|
virtual |
Get the names of commands required by this interface.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
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.
|
virtual |
Send a human readable description of the interface.
Reimplemented from cmnGenericObject.
|
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.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |
Size to be used for argument queues
|
protected |
|
protected |
|
protected |
Typedef for a receiver of void events
|
protected |
Typedef for a receiver of write events
|
protected |
Typedef for a map of name of two argument command and name of command.
|
protected |
Typedef for a map of name of one argument command and name of command.
|
protected |
Typedef for a map of name of zero argument command and name of command.
|
protected |
Typedef for a map of name of zero argument command and name of command.
|
protected |
Typedef for a map of name of one argument command and name of command.
|
protected |
Typedef for a map of name of one argument command and name of command.
|
protected |
Pointer to provided interface that we are connected to.
|
protected |
Mailbox (if supported).
|
protected |
Size to be used for mailboxes
|
protected |
Indicates if the interface must be connected.
|
protected |
Thread signal used for blocking calls. It is shared between all functions