PeriodicECSharedComposite.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00020 #ifndef RTC_PERIODICECSHAREDCOMPOSITE_H
00021 #define RTC_PERIODICECSHAREDCOMPOSITE_H
00022 
00023 #include <rtm/idl/RTCSkel.h>
00024 #include <rtm/idl/OpenRTMSkel.h>
00025 #include <rtm/RTObject.h>
00026 #include <rtm/PeriodicExecutionContext.h>
00027 #include <rtm/SdoOrganization.h>
00028 #include <coil/stringutil.h>
00029 
00045 #ifdef WIN32
00046 #pragma warning( disable : 4290 )
00047 #endif
00048 
00049 namespace SDOPackage
00050 {
00066   class PeriodicECOrganization
00067     : public Organization_impl
00068   {
00069     typedef std::vector<std::string> PortList;
00070 
00071   public:
00089     PeriodicECOrganization(::RTC::RTObject_impl* rtobj);
00103     virtual ~PeriodicECOrganization(void);
00104 
00127     virtual ::CORBA::Boolean add_members(const SDOList& sdo_list)
00128       throw (::CORBA::SystemException,
00129              InvalidParameter, NotAvailable, InternalError);
00130 
00154     virtual ::CORBA::Boolean set_members(const SDOList& sdos)
00155       throw (::CORBA::SystemException,
00156              InvalidParameter, NotAvailable, InternalError);
00157 
00179     virtual ::CORBA::Boolean remove_member(const char* id)
00180       throw (::CORBA::SystemException,
00181              InvalidParameter, NotAvailable, InternalError);
00182 
00190     void removeAllMembers(void);
00198     void updateDelegatedPorts(void);
00199 
00200   protected:
00201     class Member;
00209     bool sdoToDFC(const SDO_ptr sdo, ::OpenRTM::DataFlowComponent_ptr& dfc);
00210 
00218     void stopOwnedEC(Member& member);
00219 
00227     void startOwnedEC(Member& member);
00228 
00236     void addOrganizationToTarget(Member& member);
00237 
00245     void removeOrganizationFromTarget(Member& member);
00246 
00254     void addParticipantToEC(Member& member);
00255 
00263     void removeParticipantFromEC(Member& member);
00264 
00272     void addPort(Member& member, PortList& portlist);
00273 
00281     void removePort(Member& member, PortList& portlist);
00282 
00290     void updateExportedPortsList(void);
00291 
00292   protected:
00300     RTC::Logger rtclog;
00301 
00309     ::RTC::RTObject_impl* m_rtobj;
00310 
00318     ::RTC::ExecutionContext_var m_ec;
00319 
00320     class Member
00321     {
00322     public:
00323       Member(RTC::RTObject_ptr rtobj)
00324       //        : rtobj_(rtobj),
00325       //          profile_(rtobj->get_component_profile()),
00326       //          eclist_(rtobj->get_owned_contexts()),
00327       //          config_(rtobj->get_configuration())
00328       {
00329         rtobj_   = RTC::RTObject::_duplicate(rtobj);
00330         profile_ = rtobj->get_component_profile();
00331         eclist_  = rtobj->get_owned_contexts();
00332         config_  = rtobj->get_configuration();
00333       }
00334 
00335       virtual ~Member(void)
00336       {
00337         /*
00338         rtobj_.out();
00339         profile_.out();
00340         eclist_.out();
00341         config_.out();
00342         */
00343       }
00344 
00345       Member(const Member& x)
00346       //        : rtobj_(x.rtobj_),
00347       //          profile_(x.profile_),
00348       //          eclist_(x.eclist_),
00349       //          config_(x.config_)
00350       {
00351         rtobj_   = x.rtobj_;
00352         profile_ = x.profile_;
00353         eclist_  = x.eclist_;
00354         config_  = x.config_;
00355       }
00356 
00357       Member& operator=(const Member& x)
00358       {
00359 //        std::cout << "####################op=" << std::endl;
00360         Member tmp(x);
00361         tmp.swap(*this);
00362         return *this;
00363       }
00364 //
00365       void swap(Member& x)
00366       {
00367         RTC::RTObject_var rtobj(x.rtobj_);
00368         RTC::ComponentProfile_var profile(x.profile_);
00369         RTC::ExecutionContextList_var eclist(x.eclist_);
00370         SDOPackage::Configuration_var config(x.config_);
00371 
00372         x.rtobj_ = this->rtobj_;
00373         x.profile_ = this->profile_;
00374         x.eclist_ = this->eclist_;
00375         x.config_ = this->config_;
00376 
00377         this->rtobj_ = rtobj;
00378         this->profile_ = profile;
00379         this->eclist_ = eclist;
00380         this->config_ = config;
00381       }
00382 
00383       RTC::RTObject_var rtobj_;
00384       RTC::ComponentProfile_var profile_;
00385       RTC::ExecutionContextList_var eclist_;
00386       SDOPackage::Configuration_var config_;
00387     };
00388 
00396     std::vector<Member> m_rtcMembers;
00397     typedef std::vector<Member>::iterator MemIt;
00398 
00406     PortList m_expPorts;
00407     
00415     void print(PortList p)
00416     {
00417       for (int i(0), len(p.size()); i < len; ++i)
00418         {
00419           std::cout << p[i] << std::endl;
00420         }
00421     }
00422   };
00423 };
00424 
00425 
00440 namespace RTC
00441 {
00442   class Manager;
00443 
00466   class PeriodicECSharedComposite
00467     : public RTObject_impl
00468   {
00469   public:
00487     PeriodicECSharedComposite(Manager* manager);
00488     
00502     virtual ~PeriodicECSharedComposite(void);
00503     
00519     virtual ReturnCode_t onInitialize(void);
00551     virtual ReturnCode_t onActivated(RTC::UniqueId exec_handle);
00583     virtual ReturnCode_t onDeactivated(RTC::UniqueId exec_handle);
00584 
00615     virtual ReturnCode_t onReset(RTC::UniqueId exec_handle);
00640     virtual ReturnCode_t onFinalize(void);
00641     
00642   protected:
00650     std::vector<std::string> m_members;
00651 
00659     OpenRTM::DataFlowComponent_var m_ref;
00660 //    PeriodicExecutionContext* m_pec;
00661 //    ExecutionContextService_var m_ecref;
00669     SDOPackage::PeriodicECOrganization* m_org;
00670   };  // class PeriodicECOrganization
00671 }; // namespace RTC
00672 
00673 #ifdef WIN32
00674 #pragma warning( default : 4290 )
00675 #endif
00676 
00677 
00678 extern "C"
00679 {
00680   DLL_EXPORT void PeriodicECSharedCompositeInit(RTC::Manager* manager);
00681 };
00682 
00683 #endif // RTC_PERIODICECSHAREDCOMPOSITE_H


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sat Jun 8 2019 18:49:05