cisst-saw
|
#include <mtsTaskFromCallback.h>
Public Member Functions | |
mtsTaskFromCallback (const std::string &name, unsigned int sizeStateTable=256) | |
virtual | ~mtsTaskFromCallback () |
void | Create (void *data=0) |
void | Start (void) |
void | Suspend (void) |
void | Kill (void) |
virtual void * | DoCallback (void *data=0) |
![]() | |
mtsTask (const std::string &name, unsigned int sizeStateTable=256) | |
virtual | ~mtsTask () |
virtual void | OnStartupException (const std::exception &excp) |
virtual void | Run (void)=0 |
virtual void | OnRunException (const std::exception &excp) |
virtual void | Configure (const std::string &CMN_UNUSED(filename)="") |
void | SetInitializationDelay (double delay) |
void | Create (void) |
double | GetAveragePeriod (void) const |
const std::string | GetDefaultStateTableName (void) const |
mtsStateTable * | GetDefaultStateTable (void) |
mtsInterfaceRequired * | AddInterfaceRequiredWithoutSystemEventHandlers (const std::string &interfaceRequiredName, mtsRequiredType required=MTS_REQUIRED) |
mtsInterfaceProvided * | AddInterfaceProvidedWithoutSystemEvents (const std::string &newInterfaceName, mtsInterfaceQueueingPolicy queueingPolicy=MTS_COMPONENT_POLICY, bool isProxy=false) |
virtual bool | WaitToStart (double timeout) |
virtual bool | WaitToTerminate (double timeout) |
virtual void | WaitForWakeup (void) |
virtual void | Wakeup (void) |
void | ProcessManagerCommandsIfNotActive () |
bool | CheckForOwnThread (void) const |
virtual bool | IsPeriodic (void) const |
virtual bool | IsOverranPeriod (void) const |
virtual void | ResetOverranPeriod (void) |
![]() | |
mtsComponent (const std::string &deviceName) | |
virtual | ~mtsComponent () |
const std::string & | GetName (void) const |
void | GetName (std::string &placeHolder) const |
void | SetName (const std::string &componentName) |
virtual void | Configure (const std::string &filename="") |
bool | CreateAndWait (double timeoutInSeconds) |
bool | StartAndWait (double timeoutInSeconds) |
bool | KillAndWait (double timeoutInSeconds) |
virtual void | Startup (void) |
virtual void | Cleanup (void) |
mtsInterfaceProvided * | AddInterfaceProvided (const std::string &interfaceProvidedName, mtsInterfaceQueueingPolicy queueingPolicy=MTS_COMPONENT_POLICY) |
CISST_DEPRECATED mtsInterfaceProvided * | AddProvidedInterface (const std::string &interfaceProvidedName) |
virtual mtsInterfaceOutput * | AddInterfaceOutput (const std::string &interfaceOutputName) |
bool | InterfaceExists (const std::string &interfaceName, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_VERBOSE) const |
bool | InterfaceProvidedOrOutputExists (const std::string &interfaceName, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_VERBOSE) const |
bool | InterfaceRequiredOrInputExists (const std::string &interfaceName, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_VERBOSE) const |
mtsInterfaceProvided * | GetInterfaceProvided (const std::string &interfaceProvidedName) const |
mtsInterfaceOutput * | GetInterfaceOutput (const std::string &interfaceOutputName) const |
size_t | GetNumberOfInterfacesProvided (void) const |
size_t | GetNumberOfInterfacesOutput (void) const |
bool | RemoveInterfaceProvided (const std::string &interfaceProvidedName, const bool skipDisconnect=false) |
mtsInterfaceRequired * | AddInterfaceRequired (const std::string &interfaceRequiredName, mtsRequiredType isRequired=MTS_REQUIRED) |
CISST_DEPRECATED mtsInterfaceRequired * | AddRequiredInterface (const std::string &requiredInterfaceName) |
virtual mtsInterfaceInput * | AddInterfaceInput (const std::string &interfaceInputName) |
const mtsInterfaceProvided * | GetInterfaceProvidedFor (const std::string &interfaceRequiredName) |
mtsInterfaceRequired * | GetInterfaceRequired (const std::string &interfaceRequiredName) |
mtsInterfaceInput * | GetInterfaceInput (const std::string &interfaceInputName) const |
size_t | GetNumberOfInterfacesRequired (void) const |
size_t | GetNumberOfInterfacesInput (void) const |
bool | RemoveInterfaceRequired (const std::string &interfaceRequiredName, const bool skipDisconnect=false) |
const mtsManagerComponentServices * | GetManagerComponentServices (void) const |
mtsManagerComponentServices * | GetManagerComponentServices (void) |
mtsStateTable * | GetStateTable (const std::string &stateTableName) |
bool | AddStateTable (mtsStateTable *existingStateTable, bool addInterfaceProvided=true) |
void | UseSeparateLogFileDefault (bool forwardToLogger=true) |
void | UseSeparateLogFileDefaultWithDate (bool forwardToLogger=true) |
void | UseSeparateLogFile (const std::string &filename, bool forwardToLogger=true) |
cmnLogger::StreamBufType * | GetLogMultiplexer (void) const |
bool | IsRunning (void) const |
bool CISST_DEPRECATED | Running (void) const |
bool | IsStarted (void) const |
bool | IsTerminated (void) const |
bool | IsEndTask (void) const |
const mtsComponentState & | GetState (void) const |
void | GetState (mtsComponentState &state) const |
void | ToStream (std::ostream &outputStream) const |
bool | SetReplayMode (void) |
bool | SetReplayData (const std::string &stateTableName, const std::string &fileName) |
bool | SetReplayTime (const double time) |
std::vector< std::string > | GetNamesOfInterfacesProvidedOrOutput (void) const |
std::vector< std::string > | GetNamesOfInterfacesProvided (void) const |
std::vector< std::string > | GetNamesOfInterfacesOutput (void) const |
std::vector< std::string > | GetNamesOfInterfacesRequiredOrInput (void) const |
std::vector< std::string > | GetNamesOfInterfacesRequired (void) const |
std::vector< std::string > | GetNamesOfInterfacesInput (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 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 mtsTask | BaseType |
![]() | |
typedef cmnNamedMap < mtsStateTable > | StateTableMapType |
typedef cmnNamedMap < mtsInterfaceProvided > | InterfacesProvidedMapType |
typedef cmnNamedMap < mtsInterfaceOutput > | InterfacesOutputMapType |
typedef cmnNamedMap < mtsInterfaceRequired > | InterfacesRequiredMapType |
typedef cmnNamedMap < mtsInterfaceInput > | InterfacesInputMapType |
Additional Inherited Members | |
![]() | |
typedef mtsComponent | BaseType |
![]() | |
typedef mtsComponent | ThisType |
![]() | |
static std::runtime_error | UnknownException |
This is a task that has its thread provided by a callback from an external piece of software.
If the external package accepts a user-supplied 'void *' as the first parameter, then mtsTaskFromCallbackAdapter can be used; this class provides an adapter that expects the 'void *' parameter to contain a pointer to an instance of the mtsTaskFromCallbackAdapter class.
The mtsTaskFromCallback class can be used in all cases. The derived class must provide a callback function (e.g., a static function) and implement an alternate method to get the 'this' pointer. The user-created callback function should call RunInternal and return the data (if any).
One suggestion is to make the derived class a Singleton. The derived class should contain a (static) CustomCallbackAdapter function that has the correct signature. For example, if we create a derived class called MyCallbackClass:
static int MyCallbackClass::CustomCallbackAdapter(char *a, int b) { MyCallbackClass *obj = MyCallbackClass::GetInstance(); Avoid re-entrancy problems by creating a CallbackParms object on the stack and passing it to RunInternal, which already contains a software guard to prevent re-entrant calls. Alternatively, the data can be copied to class members, which can then be accessed inside the Run method. In this case, the CustomCallbackAdapter should handle the re-entrancy problems (e.g., if CustomCallbackAdapter is called again before the last call has finished, it could overwrite the previous values stored in the class members). MyCallbackClass::CallbackParms data(a,b); void *ret = RunInternal(static_cast<void *>(data)); Run method can use data.a and data.b and set the return value by calling mtsTask::SetThreadReturnValue. return static_cast<int>(ret); }
|
protected |
|
inline |
Create a task with name 'name' and set the state table size. The execution of this task will rely on a callback from an external thread.
name | The name of the task |
sizeStateTable | The history size of the state table |
|
inlinevirtual |
Default Destructor.
|
virtual |
Implements mtsTask.
Reimplemented in mtsSensableHD, and mtsNovintHDL.
|
inlinevirtual |
Hook for calling RunInternal
|
virtual |
|
protectedvirtual |
The member function that is passed as 'start routine' argument for thread creation.
Implements mtsTask.
|
virtual |
Start/resume execution of the task
Reimplemented from mtsComponent.
Reimplemented in mtsSensableHD, and mtsNovintHDL.
|
protectedvirtual |
The member funtion that is executed as soon as the thread gets created. It does some housekeeping before the user code can be executed.
Reimplemented from mtsTask.
|
virtual |
Suspend the execution of the task
Reimplemented from mtsComponent.
|
protected |