cisst-saw
Loading...
Searching...
No Matches
mtsManagerComponent.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4/*
5 Author(s): Peter Kazanzides, Min Yang Jung, Anton Deguet
6 Created on: 2010-08-29
7
8 (C) Copyright 2010-2026 Johns Hopkins University (JHU), All Rights Reserved.
9
10--- begin cisst license - do not edit ---
11
12This software is provided "as is" under an open source license, with
13no warranty. The complete license can be found in license.txt and
14http://www.cisst.org/cisst/license.txt.
15
16--- end cisst license ---
17*/
18
19// mtsManagerComponent is a consolidation of mtsManagerComponentClient and
20// mtsManagerComponentServer, which have both been deleted.
21// In addition, it includes implementations from mtsManagerGlobal (deleted)
22// and mtsManagerLocal. In the latter case, mtsManagerLocal now primarily
23// uses a required interface to request actions to be performed by
24// mtsManagerComponent. See mtsManagerComponentServices for the implementation.
25//
26// mtsManagerComponent has two provided interfaces and one required interface
27// per connected component:
28// - dynamic component management (provided)
29// - logger (provided)
30// - component interface (required) -- InterfaceComponent
31
32#ifndef _mtsManagerComponent_h
33#define _mtsManagerComponent_h
34
35#include <string>
36#include <map>
37
40
41// Always include last
43
44// Forward declaration
46
48{
50
51protected:
52
57
60
71
74
75 //***************** Dynamic Component Management (provided interface) *****************
76
77 // Add provided interface for dynamic component management
79
81 void ComponentCreate(const mtsDescriptionComponent & componentDescription, bool & result);
82 void ComponentAdd(const mtsComponentPointer & componentPtr, bool & result);
83 void ComponentRemove(const std::string &component, bool & result);
84 void ComponentGet(const std::string &componentName, mtsComponentPointer & componentPtr) const;
86 void ComponentConnect(const mtsDescriptionConnection & arg, bool & result);
87 void ComponentDisconnect(const mtsDescriptionConnection & arg, bool & result);
91 void ComponentGetState(const mtsDescriptionComponent &component, mtsComponentState &state) const;
92 void LoadLibrary(const mtsDescriptionLoadLibrary & lib, bool & result) const;
93 void GetNamesOfProcesses(std::vector<std::string> & names) const;
94 void GetNamesOfComponents(const std::string & processName, std::vector<std::string> & names) const;
95 void GetDescriptionsOfComponents(const std::string & processName,
96 std::vector<mtsDescriptionComponent> & descriptions) const;
97 void GetNamesOfInterfaces(const mtsDescriptionComponent & component, mtsDescriptionInterface & interfaces) const;
99 void GetListOfConnections(std::vector <mtsDescriptionConnection> & listOfConnections) const;
100 void GetListOfComponentClasses(const std::string & processName,
101 std::vector<mtsDescriptionComponentClass> & listOfComponentClasses) const;
103 mtsInterfaceProvidedDescription & description) const;
105 mtsInterfaceRequiredDescription & description) const;
106
108 mtsComponent * GetComponent(const std::string &componentName) const;
109
115
116 //********************************* Logger (provided interface) ***************************************
117
118 // Following structure is for the provided interface that supports system-wide logging.
119 // - mtsManagerLocal connects and uses PrintLog to forward log messages
120 // - a user-provided logger component connects and observes EventPrintLog
122 void PrintLog(const mtsLogMessage & log); // Write command
124 };
126
127 //********************************* Connect/Disconnect Internal **************************************
128
129 bool ConnectInternal(const std::string & clientComponentName, const std::string & clientInterfaceName,
130 const std::string & serverComponentName, const std::string & serverInterfaceName,
131 const std::string & requestComponentName);
132
133 bool DisconnectInternal(const std::string & clientComponentName, const std::string & clientInterfaceName,
134 const std::string & serverComponentName, const std::string & serverInterfaceName,
135 const std::string & requestComponentName);
136
138
139 //*************************************** OTHER METHODS *********************************************
140
144 bool AddNewClientComponent(const std::string & clientComponentName);
145
146 // Event handlers for InterfaceComponent's required interface (handle events from Component)
147 void HandleChangeStateFromComponent(const mtsComponentStateChange & componentStateChange);
148
152 bool ConnectToManagerComponent(const std::string & componentName);
153
156 bool DisconnectFromManagerComponent(const std::string & componentName);
157
158public:
161
162 void Startup(void) override;
163 void Run(void) override;
164 void Cleanup(void) override;
165
167 static std::string GetInterfaceUID(
168 const std::string & processName, const std::string & componentName, const std::string & interfaceName);
169};
170
172
173#endif // _mtsManagerComponent_h
Definition cmnNamedMap.h:54
Definition mtsComponent.h:150
Definition mtsManagerComponentServices.h:36
Definition mtsParameterTypes.h:869
Definition mtsComponentState.h:34
Definition mtsParameterTypes.h:749
Definition mtsParameterTypes.h:58
Definition mtsParameterTypes.h:624
Definition mtsParameterTypes.h:506
Definition mtsParameterTypes.h:289
Definition mtsParameterTypes.h:974
Definition mtsFunctionWrite.h:37
Definition mtsFunctionWriteReturn.h:38
Definition mtsInterfaceCommon.h:888
Definition mtsInterfaceCommon.h:1007
Definition mtsParameterTypesOld.h:84
mtsManagerComponentBase(const std::string &componentName)
Definition mtsManagerComponent.h:48
void ComponentRemove(const std::string &component, bool &result)
bool DisconnectInternal(const std::string &clientComponentName, const std::string &clientInterfaceName, const std::string &serverComponentName, const std::string &serverInterfaceName, const std::string &requestComponentName)
ConnectionIDType ConnectionID
Definition mtsManagerComponent.h:59
mtsFunctionWrite InterfaceComponentEvents_AddComponent
Definition mtsManagerComponent.h:111
void ComponentDisconnect(const mtsDescriptionConnection &arg, bool &result)
mtsFunctionWrite InterfaceComponentEvents_AddConnection
Definition mtsManagerComponent.h:112
void GetNamesOfProcesses(std::vector< std::string > &names) const
void ComponentGetState(const mtsDescriptionComponent &component, mtsComponentState &state) const
void ComponentCreate(const mtsDescriptionComponent &componentDescription, bool &result)
void ComponentGet(const std::string &componentName, mtsComponentPointer &componentPtr) const
InterfaceComponentFunctionMapType InterfaceComponentFunctionMap
Definition mtsManagerComponent.h:73
static std::string GetInterfaceUID(const std::string &processName, const std::string &componentName, const std::string &interfaceName)
void GetListOfComponentClasses(const std::string &processName, std::vector< mtsDescriptionComponentClass > &listOfComponentClasses) const
bool FindByConnectionID(mtsDescriptionConnection &arg) const
void GetInterfaceRequiredDescription(const mtsDescriptionInterface &intfc, mtsInterfaceRequiredDescription &description) const
void ComponentConfigure(const mtsDescriptionComponent &arg)
void HandleChangeStateFromComponent(const mtsComponentStateChange &componentStateChange)
void GetNamesOfInterfaces(const mtsDescriptionComponent &component, mtsDescriptionInterface &interfaces) const
mtsFunctionWrite InterfaceComponentEvents_ChangeState
Definition mtsManagerComponent.h:114
bool DisconnectFromManagerComponent(const std::string &componentName)
Disconnect local component from manager component (disconnect InterfaceInternal.Required - InterfaceC...
void GetInterfaceProvidedDescription(const mtsDescriptionInterface &intfc, mtsInterfaceProvidedDescription &description) const
void GetDescriptionsOfComponents(const std::string &processName, std::vector< mtsDescriptionComponent > &descriptions) const
cmnNamedMap< mtsComponent > ComponentMapType
Definition mtsManagerComponent.h:55
mtsFunctionWrite InterfaceComponentEvents_RemoveConnection
Definition mtsManagerComponent.h:113
cmnNamedMap< InterfaceComponentFunctionType > InterfaceComponentFunctionMapType
Definition mtsManagerComponent.h:72
mtsComponent * GetComponent(const std::string &componentName) const
bool ConnectInternal(const std::string &clientComponentName, const std::string &clientInterfaceName, const std::string &serverComponentName, const std::string &serverInterfaceName, const std::string &requestComponentName)
void ComponentStop(const mtsComponentStatusControl &arg)
void LoadLibrary(const mtsDescriptionLoadLibrary &lib, bool &result) const
void ComponentAdd(const mtsComponentPointer &componentPtr, bool &result)
void Startup(void) override
void Cleanup(void) override
ComponentMapType ComponentMap
Definition mtsManagerComponent.h:56
void ComponentStart(const mtsComponentStatusControl &arg)
void ComponentResume(const mtsComponentStatusControl &arg)
void Run(void) override
bool AddNewClientComponent(const std::string &clientComponentName)
bool AddInterfaceComponent(void)
void ComponentConnect(const mtsDescriptionConnection &arg, bool &result)
bool ConnectToManagerComponent(const std::string &componentName)
Connect a local component which has internal interfaces to the manager component (connect InterfaceIn...
LogInterface Logger
Definition mtsManagerComponent.h:125
void GetListOfConnections(std::vector< mtsDescriptionConnection > &listOfConnections) const
void GetNamesOfComponents(const std::string &processName, std::vector< std::string > &names) const
void GetDescriptionsOfInterfaces(const mtsDescriptionComponent &component, mtsDescriptionInterfaceFull &interfaces) const
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition cmnClassRegisterMacros.h:199
const int CMN_NO_DYNAMIC_CREATION
Definition cmnClassRegisterMacros.h:325
#define CISST_EXPORT
Definition cmnExportMacros.h:50
#define CMN_LOG_ALLOW_DEFAULT
Definition cmnLogLoD.h:76
Declaration of cmnNamedMap.
Rules of exporting.
unsigned int ConnectionIDType
Definition mtsForwardDeclarations.h:149
Declaration of Base Class for Manager Components.
Definition mtsManagerComponent.h:65
mtsFunctionWriteReturn RemoveObserverList
Definition mtsManagerComponent.h:69
mtsFunctionWriteReturn AddObserverList
Definition mtsManagerComponent.h:67
mtsFunctionWriteReturn RemoveEndUserInterface
Definition mtsManagerComponent.h:68
mtsFunctionWriteReturn GetEndUserInterface
Definition mtsManagerComponent.h:66
Definition mtsManagerComponent.h:121
mtsFunctionWrite EventPrintLog
Definition mtsManagerComponent.h:123
void PrintLog(const mtsLogMessage &log)