22 #ifndef _mtsComponent_h
23 #define _mtsComponent_h
84 void ToStream(std::ostream & outputStream)
const {
85 outputStream <<
"Name: " <<
Name
86 <<
", Arg: " <<
Arg << std::endl;
90 virtual void ToStreamRaw(std::ostream & outputStream,
const char delimiter =
' ',
91 bool headerOnly =
false,
const std::string & headerPrefix =
"")
const {
94 outputStream << headerPrefix <<
"-name" << delimiter
95 << headerPrefix <<
"-arg";
97 outputStream << this->
Name << delimiter
104 virtual bool FromStreamRaw(std::istream & inputStream,
const char delimiter =
' ') {
106 if (inputStream.fail())
109 if (inputStream.fail())
155 friend class mtsComponentProxy;
178 void Initialize(
void);
192 mtsInterfaceRequired * AddInterfaceRequiredUsingMailbox(
const std::string & interfaceRequiredName,
199 mtsInterfaceProvided * AddInterfaceProvidedUsingMailbox(
const std::string & interfaceProvidedName,
202 mtsInterfaceInput * AddInterfaceInputExisting(
const std::string & interfaceInputName,
205 mtsInterfaceOutput * AddInterfaceOutputExisting(
const std::string & interfaceOutputName,
210 void KillSeparateLogFile(
void);
223 const std::string & GetName(
void)
const;
224 void GetName(std::string & placeHolder)
const;
228 void SetName(
const std::string & componentName);
232 virtual void Configure(
const std::string & filename =
"");
237 virtual void Create(
void);
240 bool CreateAndWait(
double timeoutInSeconds);
244 virtual void Start(
void);
247 bool StartAndWait(
double timeoutInSeconds);
250 virtual void Suspend(
void);
254 virtual void Kill(
void);
257 bool KillAndWait(
double timeoutInSeconds);
281 AddInterfaceProvidedWithoutSystemEvents(
const std::string & interfaceProvidedName,
283 bool isProxy =
false);
287 return this->AddInterfaceProvided(interfaceProvidedName);
291 virtual mtsInterfaceOutput * AddInterfaceOutput(
const std::string & interfaceOutputName);
297 std::vector<std::string> GetNamesOfInterfacesProvidedOrOutput(
void)
const;
298 std::vector<std::string> GetNamesOfInterfacesProvided(
void)
const;
299 std::vector<std::string> GetNamesOfInterfacesOutput(
void)
const;
315 mtsInterfaceOutput * GetInterfaceOutput(
const std::string & interfaceOutputName)
const;
318 size_t GetNumberOfInterfacesProvided(
void)
const;
321 size_t GetNumberOfInterfacesOutput(
void)
const;
324 bool RemoveInterfaceProvided(
const std::string & interfaceProvidedName,
const bool skipDisconnect =
false);
337 AddInterfaceRequiredWithoutSystemEventHandlers(
const std::string & interfaceRequiredName,
342 return this->AddInterfaceRequired(requiredInterfaceName);
346 virtual mtsInterfaceInput * AddInterfaceInput(
const std::string & interfaceInputName);
350 std::vector<std::string> GetNamesOfInterfacesRequiredOrInput(
void)
const;
351 std::vector<std::string> GetNamesOfInterfacesRequired(
void)
const;
352 std::vector<std::string> GetNamesOfInterfacesInput(
void)
const;
359 const mtsInterfaceProvided * GetInterfaceProvidedFor(
const std::string & interfaceRequiredName);
365 mtsInterfaceInput * GetInterfaceInput(
const std::string & interfaceInputName)
const;
368 size_t GetNumberOfInterfacesRequired(
void)
const;
371 size_t GetNumberOfInterfacesInput(
void)
const;
374 bool RemoveInterfaceRequired(
const std::string & interfaceRequiredName,
const bool skipDisconnect =
false);
382 {
return this->ManagerComponentServices; }
384 {
return this->ManagerComponentServices; }
387 mtsStateTable * GetStateTable(
const std::string & stateTableName);
398 bool AddStateTable(
mtsStateTable * existingStateTable,
bool addInterfaceProvided =
true);
404 void UseSeparateLogFileDefault(
bool forwardToLogger =
true);
411 void UseSeparateLogFileDefaultWithDate(
bool forwardToLogger =
true);
416 void UseSeparateLogFile(
const std::string & filename,
bool forwardToLogger =
true);
427 bool IsRunning(
void)
const;
429 return this->IsRunning();
433 bool IsStarted(
void)
const;
436 bool IsTerminated(
void)
const;
439 bool IsEndTask(
void)
const;
490 size_t ProcessMailBoxes(InterfacesProvidedMapType & interfaces);
495 return this->ProcessMailBoxes(InterfacesProvided);
501 size_t ProcessQueuedEvents(
void);
523 bool AddInterfaceInternal(
const bool useMangerComponentServices =
false);
530 void InterfaceInternalCommands_ComponentCreate(
const mtsDescriptionComponent & componentDescription,
bool & result);
535 void ToStream(std::ostream & outputStream)
const;
538 bool SetReplayMode(
void);
540 bool SetReplayData(
const std::string & stateTableName,
const std::string & fileName);
542 bool SetReplayTime(
const double time);
553 return "mtsComponent: " +
object->GetName();
560 #endif // _mtsComponent_h
Defines the command interfaces.
Defines a function object to use a void command (mtsCommandVoid)
void DeSerializeRaw(std::istream &inputStream)
Definition: mtsComponent.h:78
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
std::string mtsObjectName(const mtsComponent *object)
Definition: mtsComponent.h:552
mtsComponentState State
Definition: mtsComponent.h:163
mtsInterfaceQueueingPolicy
Definition: mtsForwardDeclarations.h:39
Definition: mtsParameterTypesOld.h:41
Defines the command interfaces.
#define CISST_DEPRECATED
Definition: cmnPortability.h:310
mtsComponentConstructorNameAndArg()
Definition: mtsComponent.h:67
~mtsComponentConstructorNameAndArg()
Definition: mtsComponent.h:70
size_t ProcessQueuedCommands(void)
Definition: mtsComponent.h:494
Definition: mtsParameterTypes.h:100
cmnNamedMap< mtsInterfaceOutput > InterfacesOutputMapType
Definition: mtsComponent.h:470
bool ReplayMode
Definition: mtsComponent.h:546
cmnLogger::StreamBufType * LoDMultiplexerStreambuf
Definition: mtsComponent.h:458
Portability across compilers and operating systems tools.
Class registration macros.
Definition: mtsParameterTypes.h:652
Definition: mtsForwardDeclarations.h:52
InterfacesRequiredMapType InterfacesRequired
Definition: mtsComponent.h:479
Definition: mtsInterfaceRequired.h:85
virtual void SerializeRaw(std::ostream &outputStream) const
virtual void DeSerializeRaw(std::istream &inputStream)
std::ofstream * LogFile
Definition: mtsComponent.h:461
Declaration of cmnNamedMap.
const mtsManagerComponentServices * GetManagerComponentServices(void) const
Definition: mtsComponent.h:381
#define CMN_LOG_LEVEL_INIT_VERBOSE
Definition: cmnLogLoD.h:60
cmnNamedMap< mtsStateTable > StateTableMapType
Definition: mtsComponent.h:486
Base class for high level objects.
Definition: cmnGenericObject.h:51
Base class for data object in cisstMultiTask.
Definition: mtsGenericObject.h:56
virtual bool FromStreamRaw(std::istream &inputStream, const char delimiter= ' ')
Defines the command interfaces.
Defines a command with one argument sent to multiple interfaces.
virtual void ToStreamRaw(std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
Definition: mtsComponent.h:90
virtual void Startup(void)
Definition: mtsComponent.h:262
Definition: mtsManagerLocal.h:89
short cmnLogLevel
Definition: cmnLogLoD.h:55
Definition: mtsComponent.h:60
void ToStream(std::ostream &outputStream) const
Definition: mtsComponent.h:84
mtsRequiredType
Definition: mtsForwardDeclarations.h:52
bool UseSeparateLogFileFlag
Definition: mtsComponent.h:451
void SerializeRaw(std::ostream &outputStream) const
Definition: mtsComponent.h:72
std::string Name
Definition: mtsComponent.h:160
Definition: mtsStateTable.h:67
Defines a function object to use a void command (mtsCommandWriteReturn)
Forward declarations and #define for cisstMultiTask.
bool CISST_DEPRECATED Running(void) const
Definition: mtsComponent.h:428
void cmnDeSerializeRaw(std::istream &inputStream, _elementType &data)
Definition: cmnDeSerializer.h:82
CISST_DEPRECATED mtsInterfaceProvided * AddProvidedInterface(const std::string &interfaceProvidedName)
Definition: mtsComponent.h:286
Definition: mtsComponent.h:150
CISST_DEPRECATED mtsInterfaceRequired * AddRequiredInterface(const std::string &requiredInterfaceName)
Definition: mtsComponent.h:341
Defines cmnGenericObject.
void cmnSerializeRaw(std::ostream &outputStream, const _elementType &data)
Definition: cmnSerializer.h:78
Definition: mtsComponentState.h:34
Defines a function object to use a void command (mtsCommandVoidReturn)
std::string Name
Definition: mtsComponent.h:64
Definition: mtsParameterTypes.h:974
#define CMN_DECLARE_SERVICES(hasDynamicCreation, lod)
Definition: cmnClassRegisterMacros.h:116
cmnNamedMap< mtsInterfaceRequired > InterfacesRequiredMapType
Definition: mtsComponent.h:478
cmnNamedMap< mtsInterfaceInput > InterfacesInputMapType
Definition: mtsComponent.h:480
mtsComponentConstructorNameAndArg(const std::string &name, const T &arg)
Definition: mtsComponent.h:68
Definition: mtsInterfaceProvided.h:96
InterfacesProvidedMapType InterfacesProvided
Definition: mtsComponent.h:469
mtsInterfaceProvided * InterfaceProvidedToManager
Definition: mtsComponent.h:166
T Arg
Definition: mtsComponent.h:65
InterfacesOutputMapType InterfacesOutput
Definition: mtsComponent.h:471
mtsComponentConstructorNameAndArg< int > mtsComponentConstructorNameAndInt
Definition: mtsComponent.h:115
InterfacesInputMapType InterfacesInput
Definition: mtsComponent.h:481
Definition: mtsForwardDeclarations.h:39
StateTableMapType StateTables
Definition: mtsComponent.h:487
virtual bool FromStreamRaw(std::istream &inputStream, const char delimiter= ' ')
Definition: mtsComponent.h:104
mtsComponent ThisType
Definition: mtsComponent.h:214
Definition: mtsInterfaceOutput.h:39
Definition: mtsFunctionWrite.h:37
mtsManagerComponentServices * ManagerComponentServices
Definition: mtsComponent.h:504
mtsFunctionWrite EventGeneratorChangeState
Definition: mtsComponent.h:515
const int CMN_NO_DYNAMIC_CREATION
Definition: cmnClassRegisterMacros.h:328
const int CMN_DYNAMIC_CREATION
Definition: cmnClassRegisterMacros.h:331
mtsManagerComponentServices * GetManagerComponentServices(void)
Definition: mtsComponent.h:383
virtual void ToStreamRaw(std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
Definition: mtsMailBox.h:36
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition: cmnClassRegisterMacros.h:202
virtual void Cleanup(void)
Definition: mtsComponent.h:267
Definition: mtsManagerComponentServices.h:31
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76
Defines a command with one argument sent to multiple interfaces.
cmnNamedMap< mtsInterfaceProvided > InterfacesProvidedMapType
Definition: mtsComponent.h:468