00001 // -*- C++ -*- 00019 #ifndef RTC_EXECUTIONCONTEXTPROFILE_H 00020 #define RTC_EXECUTIONCONTEXTPROFILE_H 00021 00022 #include <coil/Mutex.h> 00023 #include <coil/Guard.h> 00024 #include <coil/Properties.h> 00025 #include <coil/TimeValue.h> 00026 00027 #include <rtm/idl/RTCStub.h> 00028 #include <rtm/SystemLogger.h> 00029 00030 #ifdef WIN32 00031 #pragma warning( disable : 4290 ) 00032 #endif 00033 00034 namespace RTC_impl 00035 { 00056 class ExecutionContextProfile 00057 { 00058 typedef coil::Guard<coil::Mutex> Guard; 00059 public: 00079 ExecutionContextProfile(RTC::ExecutionKind kind = RTC::PERIODIC); 00080 00094 virtual ~ExecutionContextProfile(void); 00095 00119 void setObjRef(RTC::ExecutionContextService_ptr ec_ptr); 00120 00140 RTC::ExecutionContextService_ptr getObjRef(void) const; 00141 00175 RTC::ReturnCode_t setRate(double rate); 00176 RTC::ReturnCode_t setPeriod(double period); 00177 RTC::ReturnCode_t setPeriod(coil::TimeValue period); 00178 00199 double getRate(void) const; 00200 coil::TimeValue getPeriod(void) const; 00201 00224 const char* getKindString(RTC::ExecutionKind kind) const; 00225 const char* getKindString() const 00226 { 00227 return getKindString(m_profile.kind); 00228 } 00229 00248 RTC::ReturnCode_t setKind(RTC::ExecutionKind kind); 00249 00269 RTC::ExecutionKind getKind(void) const; 00270 00288 RTC::ReturnCode_t setOwner(RTC::LightweightRTObject_ptr comp); 00289 00306 const RTC::RTObject_ptr getOwner() const; 00307 00339 RTC::ReturnCode_t addComponent(RTC::LightweightRTObject_ptr comp); 00340 00371 RTC::ReturnCode_t removeComponent(RTC::LightweightRTObject_ptr comp); 00372 00400 const RTC::RTCList& getComponentList() const; 00401 00422 void setProperties(coil::Properties& props); 00423 00443 const coil::Properties getProperties() const; 00444 00467 RTC::ExecutionContextProfile* getProfile(void); 00468 00486 const RTC::ExecutionContextProfile& getProfile(void) const; 00487 00503 void lock() const; 00504 00520 void unlock() const; 00521 00522 private: 00530 mutable RTC::Logger rtclog; 00538 RTC::ExecutionContextProfile m_profile; 00539 00547 mutable coil::Mutex m_profileMutex; 00548 00556 coil::TimeValue m_period; 00557 00565 RTC::ExecutionContextService_var m_ref; 00566 00567 class find_participant 00568 { 00569 RTC::RTObject_var m_comp; 00570 public: 00571 find_participant(RTC::RTObject_ptr comp) 00572 : m_comp(RTC::RTObject::_duplicate(comp)) {} 00573 bool operator()(RTC::RTObject_ptr comp) 00574 { 00575 return m_comp->_is_equivalent(comp); 00576 } 00577 }; 00578 }; // class ExecutionContextProfile 00579 }; // namespace RTC 00580 00581 #ifdef WIN32 00582 #pragma warning( default : 4290 ) 00583 #endif 00584 00585 #endif // RTC_EXECUTIONCONTEXTPROFILE_H