OpenRTM-aist  1.2.2
ExecutionContextBase.h
[詳解]
1 // -*- C++ -*-
18 #ifndef RTC_EXECUTIONCONTEXTBASE_H
19 #define RTC_EXECUTIONCONTEXTBASE_H
20 
21 #include <coil/Factory.h>
22 
23 #include <rtm/idl/RTCSkel.h>
24 #include <rtm/idl/OpenRTMSkel.h>
25 #include <rtm/Factory.h>
28 
29 #ifdef WIN32
30 #pragma warning( disable : 4290 )
31 #endif
32 
33 #define DEFAULT_EXECUTION_RATE 1000
34 
35 namespace coil
36 {
37  class Properties;
38 }
39 
40 namespace RTC
41 {
370  {
371  public:
385  ExecutionContextBase(const char* name);
386 
400  virtual ~ExecutionContextBase(void);
401 
415  virtual void init(coil::Properties& props);
416 
430  virtual RTC::ReturnCode_t bindComponent(RTC::RTObject_impl* rtc);
431 
432  //============================================================
433  // implementation functions for EC's CORBA operation
434  //============================================================
458  CORBA::Boolean isRunning();
459 
487  RTC::ReturnCode_t start(void);
488 
515  virtual RTC::ReturnCode_t stop(void);
516 
537  double getRate(void) const;
538  coil::TimeValue getPeriod(void) const;
539 
573  RTC::ReturnCode_t setRate(double rate);
574 
606  RTC::ReturnCode_t addComponent(RTC::LightweightRTObject_ptr comp);
607 
638  RTC::ReturnCode_t removeComponent(RTC::LightweightRTObject_ptr comp);
639 
673  RTC::ReturnCode_t activateComponent(RTC::LightweightRTObject_ptr comp);
674 
715  RTC::ReturnCode_t deactivateComponent(RTC::LightweightRTObject_ptr comp);
716 
748  RTC::ReturnCode_t resetComponent(RTC::LightweightRTObject_ptr comp);
749 
776  RTC::LifeCycleState getComponentState(RTC::LightweightRTObject_ptr comp);
777  const char* getStateString(RTC::LifeCycleState state);
778 
798  RTC::ExecutionKind getKind(void) const;
799 
822  RTC::ExecutionContextProfile* getProfile(void);
823 
824  //============================================================
825  // Delegated functions to ExecutionContextProfile
826  //============================================================
846  void setObjRef(RTC::ExecutionContextService_ptr ec_ptr);
847 
866  RTC::ExecutionContextService_ptr getObjRef(void) const;
867 
890  const char* getKindString(RTC::ExecutionKind kind) const;
891 
910  RTC::ReturnCode_t setKind(RTC::ExecutionKind kind);
911 
929  RTC::ReturnCode_t setOwner(RTC::LightweightRTObject_ptr comp);
930 
947  const RTC::RTObject_ptr getOwner() const;
948 
967  const RTC::RTCList& getComponentList() const;
968 
989  void setProperties(coil::Properties& props);
990 
1010  const coil::Properties getProperties() const;
1011 
1029  const RTC::ExecutionContextProfile& getProfile(void) const;
1030  // end of delegated functions to ExecutionContextProfile
1031  //============================================================
1032 
1033  //============================================================
1034  // Delegated functions to ExecutionContextWorker
1035  //============================================================
1036  bool isAllCurrentState(RTC::LifeCycleState state)
1037  {
1038  return m_worker.isAllCurrentState(state);
1039  };
1040  bool isAllNextState(RTC::LifeCycleState state)
1041  {
1042  return m_worker.isAllNextState(state);
1043  };
1044  bool isOneOfCurrentState(RTC::LifeCycleState state)
1045  {
1046  return m_worker.isOneOfCurrentState(state);
1047  };
1048  bool isOneOfNextState(RTC::LifeCycleState state)
1049  {
1050  return m_worker.isOneOfNextState(state);
1051  };
1052 
1057 
1058 
1059  protected:
1060  // template virtual functions related to start/stop
1061  virtual bool onIsRunning(bool running) { return running; }
1062  virtual RTC::ReturnCode_t onStarting() { return RTC::RTC_OK; }
1063  virtual RTC::ReturnCode_t onStarted() { return RTC::RTC_OK; }
1064  virtual RTC::ReturnCode_t onStopping() { return RTC::RTC_OK; }
1065  virtual RTC::ReturnCode_t onStopped() { return RTC::RTC_OK; }
1066 
1067  // template virtual functions getting/setting execution rate
1068  virtual double onGetRate(double rate) const { return rate; }
1069  virtual double onSettingRate(double rate) { return rate; }
1070  virtual RTC::ReturnCode_t onSetRate(double rate) { return RTC::RTC_OK; }
1071 
1072  // template virtual functions adding/removing component
1073  virtual RTC::ReturnCode_t
1075  {
1076  return RTC::RTC_OK;
1077  }
1078  virtual RTC::ReturnCode_t
1080  {
1081  return RTC::RTC_OK;
1082  }
1083  virtual RTC::ReturnCode_t
1085  {
1086  return RTC::RTC_OK;
1087  }
1088  virtual RTC::ReturnCode_t
1090  {
1091  return RTC::RTC_OK;
1092  }
1093 
1094  // template virtual functions related to activation/deactivation/reset
1095  virtual RTC::ReturnCode_t
1097  {
1098  return RTC::RTC_OK;
1099  }
1100  virtual RTC::ReturnCode_t
1102  {
1103  return RTC::RTC_OK;
1104  }
1105  virtual RTC::ReturnCode_t
1107  long int count)
1108  {
1109  return RTC::RTC_OK;
1110  }
1111  virtual RTC::ReturnCode_t
1113  {
1114  return RTC::RTC_OK;
1115  }
1116  virtual RTC::ReturnCode_t
1118  {
1119  return RTC::RTC_OK;
1120  }
1121  virtual RTC::ReturnCode_t
1123  {
1124  return RTC::RTC_OK;
1125  }
1126  virtual RTC::ReturnCode_t onResetting(RTC::LightweightRTObject_ptr comp)
1127  {
1128  return RTC::RTC_OK;
1129  }
1130  virtual RTC::ReturnCode_t
1132  {
1133  return RTC::RTC_OK;
1134  }
1135  virtual RTC::ReturnCode_t
1137  {
1138  return RTC::RTC_OK;
1139  }
1140 
1141  virtual RTC::LifeCycleState
1142  onGetComponentState(RTC::LifeCycleState state)
1143  {
1144  return state;
1145  }
1146  virtual RTC::ExecutionKind
1147  onGetKind(RTC::ExecutionKind kind) const
1148  {
1149  return kind;
1150  }
1151  virtual RTC::ExecutionContextProfile*
1152  onGetProfile(RTC::ExecutionContextProfile*& profile)
1153  {
1154  return profile;
1155  }
1156 
1157  private:
1165  bool setExecutionRate(coil::Properties& props);
1173  bool setTransitionMode(coil::Properties& props,
1174  const char* key, bool& flag);
1182  bool setTimeout(coil::Properties& props, const char* key,
1183  coil::TimeValue& timevalue);
1184 
1185  RTC::ReturnCode_t waitForActivated(RTC_impl::RTObjectStateMachine* rtobj);
1186  RTC::ReturnCode_t waitForDeactivated(RTC_impl::RTObjectStateMachine* rtobj);
1187  RTC::ReturnCode_t waitForReset(RTC_impl::RTObjectStateMachine* rtobj);
1188 
1189  protected:
1191 
1194 
1198 
1202  }; // class ExecutionContextBase
1203 
1205 
1206 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
1208 #endif
1209 }; // namespace RTC
1210 
1211 #ifdef WIN32
1212 #pragma warning( default : 4290 )
1213 #endif
1214 
1215 #ifdef __GNUC__
1217 #endif
1218 
1219 #endif // RTC_EXECUTIONCONTEXTBASE_H
RTC_impl::ExecutionContextWorker::isAllNextState
bool isAllNextState(RTC::LifeCycleState state)
RTC::ExecutionContextBase::invokeWorkerDo
void invokeWorkerDo()
Definition: ExecutionContextBase.h:1055
RTC_impl::LightweightRTObject_ptr
RTC::LightweightRTObject_ptr LightweightRTObject_ptr
Definition: ExecutionContextWorker.h:43
RTC::ExecutionContextBase::onDeactivating
virtual RTC::ReturnCode_t onDeactivating(RTC::LightweightRTObject_ptr comp)
Definition: ExecutionContextBase.h:1112
RTC_impl::ExecutionContextWorker
ExecutionContextWorker クラス
Definition: ExecutionContextWorker.h:118
RTC::ExecutionContextBase::onRemovingComponent
virtual RTC::ReturnCode_t onRemovingComponent(RTC::LightweightRTObject_ptr rtobj)
Definition: ExecutionContextBase.h:1084
RTC::ExecutionContextBase::~ExecutionContextBase
virtual ~ExecutionContextBase(void)
仮想デストラクタ
RTC::Properties
coil::Properties Properties
Definition: RTC.h:83
RTC::ExecutionContextBase::onStopped
virtual RTC::ReturnCode_t onStopped()
Definition: ExecutionContextBase.h:1065
RTC::ExecutionContextBase::getOwner
const RTC::RTObject_ptr getOwner() const
Ownerコンポーネントの参照を取得する
RTC::ExecutionContextBase::m_profile
RTC_impl::ExecutionContextProfile m_profile
Definition: ExecutionContextBase.h:1193
RTC_impl::ExecutionContextWorker::isOneOfNextState
bool isOneOfNextState(RTC::LifeCycleState state)
ExecutionContextProfile.h
ExecutionContextProfile class
RTC::ExecutionContextBase::isOneOfNextState
bool isOneOfNextState(RTC::LifeCycleState state)
Definition: ExecutionContextBase.h:1048
RTC_impl::ExecutionContextProfile
ExecutionContextProfile クラス
Definition: ExecutionContextProfile.h:56
RTC::ExecutionContextBase::setKind
RTC::ReturnCode_t setKind(RTC::ExecutionKind kind)
ExecutionKind を設定する
RTC::ExecutionContextBase::removeComponent
RTC::ReturnCode_t removeComponent(RTC::LightweightRTObject_ptr comp)
RTコンポーネントを参加者リストから削除する
RTC::ExecutionContextBase::isAllNextState
bool isAllNextState(RTC::LifeCycleState state)
Definition: ExecutionContextBase.h:1040
RTC::ExecutionContextBase::onIsRunning
virtual bool onIsRunning(bool running)
Definition: ExecutionContextBase.h:1061
RTC::ExecutionContextBase::rtclog
RTC::Logger rtclog
Definition: ExecutionContextBase.h:1190
RTC::ExecutionContextBase::getComponentList
const RTC::RTCList & getComponentList() const
RTコンポーネントの参加者リストを取得する
RTC::ExecutionContextBase::onDeactivated
virtual RTC::ReturnCode_t onDeactivated(RTC_impl::RTObjectStateMachine *comp, long int count)
Definition: ExecutionContextBase.h:1122
RTC::ExecutionContextBase::bindComponent
virtual RTC::ReturnCode_t bindComponent(RTC::RTObject_impl *rtc)
コンポーネントをバインドする。
RTC_impl::ExecutionContextWorker::invokeWorkerPostDo
void invokeWorkerPostDo()
RTC::ExecutionContextBase
ExecutionContext用基底クラス
Definition: ExecutionContextBase.h:369
ExecutionContextWorker.h
ExecutionContext's state machine worker class
RTC::ExecutionContextBase::getStateString
const char * getStateString(RTC::LifeCycleState state)
RTC::ExecutionContextBase::m_syncActivation
bool m_syncActivation
Definition: ExecutionContextBase.h:1199
RTC::ExecutionContextBase::getProperties
const coil::Properties getProperties() const
Propertiesを取得する
RTC::ExecutionContextBase::isAllCurrentState
bool isAllCurrentState(RTC::LifeCycleState state)
Definition: ExecutionContextBase.h:1036
RTC_impl::ExecutionContextWorker::invokeWorkerDo
void invokeWorkerDo()
RTC::ExecutionContextBase::invokeWorkerPostDo
void invokeWorkerPostDo()
Definition: ExecutionContextBase.h:1056
RTC::ExecutionContextBase::m_syncReset
bool m_syncReset
Definition: ExecutionContextBase.h:1201
RTC::ExecutionContextBase::start
RTC::ReturnCode_t start(void)
ExecutionContext の実行を開始
RTC::RTObject_impl
RTコンポーネントクラス
Definition: RTObject.h:89
RTC::ExecutionContextBase::onGetRate
virtual double onGetRate(double rate) const
Definition: ExecutionContextBase.h:1068
coil::Singleton
Singleton テンプレートクラス
Definition: Singleton.h:106
RTC_impl::ExecutionContextWorker::isOneOfCurrentState
bool isOneOfCurrentState(RTC::LifeCycleState state)
RTC::ExecutionContextBase::m_syncDeactivation
bool m_syncDeactivation
Definition: ExecutionContextBase.h:1200
coil::TimeValue
TimeValue クラス
Definition: TimeValue.h:40
RTC::ExecutionContextBase::resetComponent
RTC::ReturnCode_t resetComponent(RTC::LightweightRTObject_ptr comp)
RTコンポーネントをリセットする
RTC::ExecutionContextBase::onGetComponentState
virtual RTC::LifeCycleState onGetComponentState(RTC::LifeCycleState state)
Definition: ExecutionContextBase.h:1142
RTC::ExecutionContextBase::onAddedComponent
virtual RTC::ReturnCode_t onAddedComponent(RTC::LightweightRTObject_ptr rtobj)
Definition: ExecutionContextBase.h:1079
RTC::ExecutionContextBase::onGetKind
virtual RTC::ExecutionKind onGetKind(RTC::ExecutionKind kind) const
Definition: ExecutionContextBase.h:1147
RTC::ExecutionContextBase::isOneOfCurrentState
bool isOneOfCurrentState(RTC::LifeCycleState state)
Definition: ExecutionContextBase.h:1044
RTC::ExecutionContextBase::setProperties
void setProperties(coil::Properties &props)
Propertiesをセットする
DLL_PLUGIN
#define DLL_PLUGIN
Definition: Factory.h:40
RTC::ExecutionContextBase::onGetProfile
virtual RTC::ExecutionContextProfile * onGetProfile(RTC::ExecutionContextProfile *&profile)
Definition: ExecutionContextBase.h:1152
RTC::ExecutionContextBase::m_activationTimeout
coil::TimeValue m_activationTimeout
Definition: ExecutionContextBase.h:1195
RTC::ExecutionContextBase::onResetting
virtual RTC::ReturnCode_t onResetting(RTC::LightweightRTObject_ptr comp)
Definition: ExecutionContextBase.h:1126
RTC::ExecutionContextBase::onActivated
virtual RTC::ReturnCode_t onActivated(RTC_impl::RTObjectStateMachine *comp, long int count)
Definition: ExecutionContextBase.h:1106
RTC::ExecutionContextBase::getPeriod
coil::TimeValue getPeriod(void) const
RTC::ExecutionContextBase::onRemovedComponent
virtual RTC::ReturnCode_t onRemovedComponent(RTC::LightweightRTObject_ptr rtobj)
Definition: ExecutionContextBase.h:1089
RTC::ExecutionContextFactory
coil::GlobalFactory< ExecutionContextBase > ExecutionContextFactory
Definition: ExecutionContextBase.h:1204
RTC::ExecutionContextBase::onWaitingDeactivated
virtual RTC::ReturnCode_t onWaitingDeactivated(RTC_impl::RTObjectStateMachine *comp, long int count)
Definition: ExecutionContextBase.h:1117
RTC::ExecutionContextBase::setObjRef
void setObjRef(RTC::ExecutionContextService_ptr ec_ptr)
CORBA オブジェクト参照の取得
Factory.h
generic Factory template class
RTC_impl::ExecutionContextWorker::invokeWorkerPreDo
void invokeWorkerPreDo()
RTC::ExecutionContextBase::getObjRef
RTC::ExecutionContextService_ptr getObjRef(void) const
CORBA オブジェクト参照の取得
RTC::Logger
Logger クラス
Definition: SystemLogger.h:99
RTC::ExecutionContextBase::invokeWorker
void invokeWorker()
Definition: ExecutionContextBase.h:1053
RTC::ExecutionContextBase::init
virtual void init(coil::Properties &props)
ExecutionContextの初期化を行う
coil::GlobalFactory
GlobalFactory テンプレートクラス
Definition: Factory.h:583
Factory.h
RT-Component factory class
RTC_impl::ExecutionContextWorker::invokeWorker
void invokeWorker()
RTC::ExecutionContextBase::onWaitingReset
virtual RTC::ReturnCode_t onWaitingReset(RTC_impl::RTObjectStateMachine *comp, long int count)
Definition: ExecutionContextBase.h:1131
EXTERN
#define EXTERN
Definition: Factory.h:42
coil::Properties
プロパティセットを表現するクラス
Definition: Properties.h:101
RTC::ExecutionContextBase::m_resetTimeout
coil::TimeValue m_resetTimeout
Definition: ExecutionContextBase.h:1197
RTC::ExecutionContextBase::m_worker
RTC_impl::ExecutionContextWorker m_worker
Definition: ExecutionContextBase.h:1192
RTC::ExecutionContextBase::getKindString
const char * getKindString(RTC::ExecutionKind kind) const
ExecutionKind を文字列化する
RTC::ExecutionContextBase::getKind
RTC::ExecutionKind getKind(void) const
ExecutionKind を取得する
RTC_impl::ExecutionContextWorker::isAllCurrentState
bool isAllCurrentState(RTC::LifeCycleState state)
RTC::ExecutionContextBase::getComponentState
RTC::LifeCycleState getComponentState(RTC::LightweightRTObject_ptr comp)
RTコンポーネントの状態を取得する
RTC::ExecutionContextBase::onStarting
virtual RTC::ReturnCode_t onStarting()
Definition: ExecutionContextBase.h:1062
RTC::ExecutionContextBase::setOwner
RTC::ReturnCode_t setOwner(RTC::LightweightRTObject_ptr comp)
Ownerコンポーネントをセットする。
RTC::ExecutionContextBase::getProfile
RTC::ExecutionContextProfile * getProfile(void)
Profileを取得する
RTC::ExecutionContextBase::onSettingRate
virtual double onSettingRate(double rate)
Definition: ExecutionContextBase.h:1069
RTC::ExecutionContextBase::activateComponent
RTC::ReturnCode_t activateComponent(RTC::LightweightRTObject_ptr comp)
RTコンポーネントをアクティブ化する
RTC_impl::RTObjectStateMachine
Definition: RTObjectStateMachine.h:46
RTC::ExecutionContextBase::onAddingComponent
virtual RTC::ReturnCode_t onAddingComponent(RTC::LightweightRTObject_ptr rtobj)
Definition: ExecutionContextBase.h:1074
RTC::ExecutionContextBase::stop
virtual RTC::ReturnCode_t stop(void)
ExecutionContext の実行を停止
RTC
RTコンポーネント
RTC::ExecutionContextBase::ExecutionContextBase
ExecutionContextBase(const char *name)
仮想デストラクタ
RTC::ExecutionContextBase::onSetRate
virtual RTC::ReturnCode_t onSetRate(double rate)
Definition: ExecutionContextBase.h:1070
coil
Common Object Interface Layer
Definition: Affinity.h:28
RTC::ExecutionContextBase::onActivating
virtual RTC::ReturnCode_t onActivating(RTC::LightweightRTObject_ptr comp)
Definition: ExecutionContextBase.h:1096
RTC::ExecutionContextBase::addComponent
RTC::ReturnCode_t addComponent(RTC::LightweightRTObject_ptr comp)
RTコンポーネントを追加する
RTC::ExecutionContextBase::onWaitingActivated
virtual RTC::ReturnCode_t onWaitingActivated(RTC_impl::RTObjectStateMachine *comp, long int count)
Definition: ExecutionContextBase.h:1101
RTC::ExecutionContextBase::setRate
RTC::ReturnCode_t setRate(double rate)
ExecutionContext の実行周期(Hz)を設定する
RTC::ExecutionContextBase::isRunning
CORBA::Boolean isRunning()
ExecutionContext 実行状態確認関数
RTC::ExecutionContextBase::onStopping
virtual RTC::ReturnCode_t onStopping()
Definition: ExecutionContextBase.h:1064
RTC::ExecutionContextBase::invokeWorkerPreDo
void invokeWorkerPreDo()
Definition: ExecutionContextBase.h:1054
RTC::ExecutionContextBase::m_deactivationTimeout
coil::TimeValue m_deactivationTimeout
Definition: ExecutionContextBase.h:1196
RTC::ExecutionContextBase::deactivateComponent
RTC::ReturnCode_t deactivateComponent(RTC::LightweightRTObject_ptr comp)
RTコンポーネントを非アクティブ化する
RTC::ExecutionContextBase::getRate
double getRate(void) const
ExecutionContext の実行周期(Hz)を取得する
RTC::ExecutionContextBase::onReset
virtual RTC::ReturnCode_t onReset(RTC_impl::RTObjectStateMachine *comp, long int count)
Definition: ExecutionContextBase.h:1136
RTC::ExecutionContextBase::onStarted
virtual RTC::ReturnCode_t onStarted()
Definition: ExecutionContextBase.h:1063