ERC CISST - cisst software

mtsComponent Class Reference
[Multi Task Support]

#include <mtsComponent.h>

Inheritance diagram for mtsComponent:

Inheritance graph
[legend]
Collaboration diagram for mtsComponent:

Collaboration graph
[legend]
List of all members.

Detailed Description

mtsComponent should be used to write wrappers around existing devices or resources. This class allows to interact with existing devices as one would interact with a task (as in mtsTask and mtsTaskPeriodic). To do so, the component maintains a list of provided interfaces (of type mtsInterfaceProvided) which contains commands.

The main differences are that the base component class doesn't have a thread and is stateless. Since the component doesn't have any thread, the commands are not queued and the class doesn't add any thread safety mechanism. The component class doesn't maintain a state as it relies on the underlying device to do so. It is basically a pass-thru or wrapper.

Definition at line 69 of file mtsComponent.h.

Public Types

Public Member Functions

Protected Member Functions

Protected Attributes

Friends


Member Typedef Documentation

typedef cmnNamedMap<mtsInterfaceProvidedOrOutput> mtsComponent::InterfacesProvidedOrOutputMapType [protected]

Map of provided and output interfaces. Used to store pointers on all provided interfaces. Separate lists of provided and output interfaces are maintained for efficiency.

Definition at line 328 of file mtsComponent.h.

typedef cmnNamedMap<mtsInterfaceRequiredOrInput> mtsComponent::InterfacesRequiredOrInputMapType [protected]

Map of required interfaces. Used to store pointers on all required interfaces. Separate lists of required and input interfaces are maintained for efficiency.

Definition at line 340 of file mtsComponent.h.


Constructor & Destructor Documentation

mtsComponent::mtsComponent ( void   )  [protected]

Default constructor. Protected to prevent creation of a component without a name.

mtsComponent::mtsComponent ( const mtsComponent other  )  [protected]

Default copy constructor. Protected to prevent copy as it is not support yet. It is not clear why one would use a copy constructor on a component anyway.

mtsComponent::mtsComponent ( const std::string &  deviceName  ) 

Default constructor. Sets the name.

virtual mtsComponent::~mtsComponent (  )  [virtual]

Default destructor. Does nothing.


Member Function Documentation

void mtsComponent::Initialize ( void   )  [protected]

Initializer

mtsInterfaceRequired* mtsComponent::AddInterfaceRequiredExisting ( const std::string &  interfaceRequiredName,
mtsInterfaceRequired interfaceRequired 
) [protected]

Add an already existing interface required to the interface, the user must pay attention to mailbox (or lack of) used to create the required interface. By default, mtsComponent uses a required interface without mailbox (i.e. doesn't queue), mtsTask uses an interface with a mailbox and mtsTaskFromSignal uses an interface with a mailbox with a post command queued command.

mtsInterfaceRequired* mtsComponent::AddInterfaceRequiredUsingMailbox ( const std::string &  interfaceRequiredName,
mtsMailBox mailBox,
mtsRequiredType  required 
) [protected]

Create and add a required interface with an existing mailbox. If the creation or addition failed (name already exists), the caller must make sure he/she deletes the unused mailbox.

mtsInterfaceProvided* mtsComponent::AddInterfaceProvidedUsingMailbox ( const std::string &  interfaceProvidedName,
mtsMailBox mailBox 
) [protected]

Create and add a provided interface with an existing mailbox. If the creation or addition failed (name already exists), the caller must make sure he/she deletes the unused mailbox.

const std::string& mtsComponent::GetName ( void   )  const

Returns the name of the component.

Referenced by mtsObjectName().

void mtsComponent::SetName ( const std::string &  componentName  ) 

Set name. This method is useful to perform dynamic creation using the default constructor and then set the name.

virtual void mtsComponent::Configure ( const std::string &  filename = ""  )  [virtual]

The virtual method so that the interface or tasks can configure themselves

virtual void mtsComponent::Create ( void   )  [virtual]

Virtual method to create the components, e.g. for tasks create the required threads. For other components, place initialization code.

Referenced by mtsTask::Create().

virtual void mtsComponent::Start ( void   )  [virtual]

Virtual method called after components are connected to start the computations and message processing.

virtual void mtsComponent::Kill ( void   )  [virtual]

Virtual method to stop the computations and message processing. See Start.

virtual mtsInterfaceProvided* mtsComponent::AddInterfaceProvided ( const std::string &  interfaceProvidedName,
mtsInterfaceQueueingPolicy  queueingPolicy = MTS_COMPONENT_POLICY 
) [virtual]

Method to add a provided interface to the component. This method is virtual so that mtsTaskBase can redefine it and generate the appropriate type of interface, i.e. mtsInterfaceProvided as opposed to mtsInterfaceProvided for mtsComponent.

Referenced by AddProvidedInterface().

virtual mtsInterfaceOutput* mtsComponent::AddInterfaceOutput ( const std::string &  interfaceOutputName  )  [virtual]

Method to add an output interface to the component.

std::vector<std::string> mtsComponent::GetNamesOfInterfacesProvidedOrOutput ( void   )  const

Return the list of provided interfaces. This returns a list of names. To retrieve the actual interface, use GetInterfaceProvided with the provided interface name.

std::vector<std::string> mtsComponent::GetNamesOfInterfacesProvided ( void   )  const

Return the list of provided interfaces. This returns a list of names. To retrieve the actual interface, use GetInterfaceProvided with the provided interface name.

std::vector<std::string> mtsComponent::GetNamesOfInterfacesOutput ( void   )  const

Return the list of provided interfaces. This returns a list of names. To retrieve the actual interface, use GetInterfaceProvided with the provided interface name.

mtsInterfaceProvidedOrOutput* mtsComponent::GetInterfaceProvidedOrOutput ( const std::string &  interfaceProvidedOrOutputName  ) 

Get a provided or output interface identified by its name

mtsInterfaceProvided* mtsComponent::GetInterfaceProvided ( const std::string &  interfaceProvidedName  )  const

Get a provided interface identified by its name

mtsInterfaceOutput* mtsComponent::GetInterfaceOutput ( const std::string &  interfaceOutputName  )  const

Get an output interface identified by its name

size_t mtsComponent::GetNumberOfInterfacesProvided ( void   )  const

Get the total number of provided interfaces

size_t mtsComponent::GetNumberOfInterfacesOutput ( void   )  const

Get the total number of output interfaces

bool mtsComponent::RemoveInterfaceProvided ( const std::string &  interfaceProvidedName  ) 

Remove a provided interface identified by its name

bool mtsComponent::RemoveInterfaceOutput ( const std::string &  interfaceOutputName  ) 

Remove an output interface identified by its name

virtual mtsInterfaceRequired* mtsComponent::AddInterfaceRequired ( const std::string &  interfaceRequiredName,
mtsRequiredType  isRequired = MTS_REQUIRED 
) [virtual]

Add a required interface. This interface will later on be connected to another task and use the provided interface of the other task. The required interface created also contains a list of event handlers to be used as observers.

Referenced by AddRequiredInterface().

virtual mtsInterfaceInput* mtsComponent::AddInterfaceInput ( const std::string &  interfaceInputName  )  [virtual]

Add an input interface.

std::vector<std::string> mtsComponent::GetNamesOfInterfacesRequiredOrInput ( void   )  const

Provide a list of existing required interfaces (by names)

std::vector<std::string> mtsComponent::GetNamesOfInterfacesRequired ( void   )  const

Provide a list of existing required interfaces (by names)

std::vector<std::string> mtsComponent::GetNamesOfInterfacesInput ( void   )  const

Provide a list of existing required interfaces (by names)

const mtsInterfaceProvidedOrOutput* mtsComponent::GetInterfaceProvidedOrOutputFor ( const std::string &  interfaceRequiredOrInputName  ) 

Get a pointer on the provided interface that has been connected to a given required interface (defined by its name). This method will return a null pointer if the required interface has not been connected. See mtsTaskManager::Connect.

mtsInterfaceRequiredOrInput* mtsComponent::GetInterfaceRequiredOrInput ( const std::string &  interfaceRequiredOrInputName  ) 

Get a required or input interface identified by its name

mtsInterfaceRequired* mtsComponent::GetInterfaceRequired ( const std::string &  interfaceRequiredName  ) 

Get a required interface identified by its name

mtsInterfaceInput* mtsComponent::GetInterfaceInput ( const std::string &  interfaceInputName  )  const

Get an input interface identified by its name

size_t mtsComponent::GetNumberOfInterfacesRequired ( void   )  const

Get the total number of required interfaces

size_t mtsComponent::GetNumberOfInterfacesInput ( void   )  const

Get the total number of input interfaces

bool mtsComponent::RemoveInterfaceRequired ( const std::string &  interfaceRequiredName  ) 

Remove a required interface identified by its name

bool mtsComponent::RemoveInterfaceInput ( const std::string &  interfaceInputName  ) 

Remove an input interface identified by its name

bool mtsComponent::ConnectInterfaceRequiredOrInput ( const std::string &  interfaceRequiredOrInputName,
mtsInterfaceProvidedOrOutput interfaceProvidedOrOutput 
)

Connect a required interface, used by mtsTaskManager

void mtsComponent::UseSeparateLogFileDefault ( bool  forwardToLogger = true  ) 

Tells this component to use its own file for log. By default the messages are also sent to cmnLogger but this can be changed setting forwardToLogger to false. The default file name is based on the component's name, followed by the date and '-log.txt'

void mtsComponent::UseSeparateLogFile ( const std::string &  filename,
bool  forwardToLogger = true 
)

Tells this component to use its own file for log. By default the messages are also sent to cmnLogger but this can be changed setting forwardToLogger to false.

cmnLogger::StreamBufType* mtsComponent::GetLogMultiplexer ( void   )  const [virtual]

Overload GetLodMultiplexer. This method is used for all class level log (i.e. CMN_LOG_CLASS) and allows to redirect the log to a separate file for each component when activated by UseSeparateLogFile or UseSeparateLogFileDefault.

Reimplemented from cmnGenericObject.

bool mtsComponent::IsRunning ( void   )  const

Return true if task is active.

Referenced by Running().

bool mtsComponent::IsStarted ( void   )  const

Return true if task was started.

bool mtsComponent::IsTerminated ( void   )  const

Return true if task is terminated.

bool mtsComponent::IsEndTask ( void   )  const

Return true if task is marked for killing.

const mtsComponentState& mtsComponent::GetState ( void   )  const

Return task state.

virtual bool mtsComponent::WaitForState ( mtsComponentState  desiredState,
double  timeout 
) [protected, virtual]

Helper function to wait on a state change, with specified timeout in seconds.

size_t mtsComponent::ProcessMailBoxes ( InterfacesProvidedListType interfaces  )  [protected]

Process all messages in mailboxes. Returns number of commands processed.

Referenced by ProcessQueuedCommands().

size_t mtsComponent::ProcessQueuedCommands ( void   )  [inline, protected]

Process all queued commands. Returns number of events processed. These are the commands provided by all interfaces of the task.

Definition at line 353 of file mtsComponent.h.

References InterfacesProvided, and ProcessMailBoxes().

size_t mtsComponent::ProcessQueuedEvents ( void   )  [protected]

Process all queued events. Returns number of events processed. These are the commands queued following events currently observed via the required interfaces.

mtsInterfaceRequired* mtsComponent::EnableDynamicComponentManagement ( void   )  [protected]

Enable support for dynamic component management services.

Returns:
Pointer to internal required interface, if success. NULL otherwise.
Note:
If user component needs dynamic component management services, this method should be called by user component's constructor

bool mtsComponent::AddInterfaceInternal ( const bool  useMangerComponentServices = false  )  [protected]

Add internal interfaces.

Parameters:
useMangerComponentServices True to allow this component to use dynamic component control services through mts command pattern to control other components. If true, the internal required interface is added to this component (the internal provided interface is added by default)

void mtsComponent::InterfaceInternalCommands_ComponentStop ( const mtsComponentStatusControl arg  )  [protected]

Internal commands to process command execution request coming from manager component client

void mtsComponent::ToStream ( std::ostream &  outputStream  )  const [virtual]

Send a human readable description of the component.

Reimplemented from cmnGenericObject.

Reimplemented in mtsTask.


Member Data Documentation

std::string mtsComponent::Name [protected]

A string identifying the 'Name' of the component.

Definition at line 79 of file mtsComponent.h.

mtsComponentState mtsComponent::State [protected]

Component state.

Definition at line 82 of file mtsComponent.h.

bool mtsComponent::UseSeparateLogFileFlag [protected]

Flag to keep track of separate log file use

Definition at line 301 of file mtsComponent.h.

cmnLogger::StreamBufType* mtsComponent::LoDMultiplexerStreambuf [protected]

Pointers on multiplexer used by this component for logging purposes. By default the file "LogFile" is the only output stream but a user can add any stream using mtsComponent::GetLogMultiplexer combined with cmnLODMultiplexerStreambuf::AddChannel.

Definition at line 308 of file mtsComponent.h.

std::ofstream* mtsComponent::LogFile [protected]

Default log file used for this component logging

Definition at line 311 of file mtsComponent.h.

mtsManagerComponentServices* mtsComponent::ManagerComponentServices [protected]

Dynamic component management service provider

Definition at line 363 of file mtsComponent.h.

mtsFunctionWrite mtsComponent::EventGeneratorChangeState [protected]

Event generator to inform the manager component client of the state change of this component

Definition at line 374 of file mtsComponent.h.


The documentation for this class was generated from the following file:
erc-cisst-devel<at>lists.johnshopkins.edu