Choreonoid  1.5
RTCItem.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_OPENRTM_PLUGIN_RTC_ITEM_H_INCLUDED
6 #define CNOID_OPENRTM_PLUGIN_RTC_ITEM_H_INCLUDED
7 
8 #include <cnoid/Item>
9 #include <cnoid/Process>
10 #include <boost/filesystem.hpp>
11 #include <rtm/Manager.h>
12 #include "exportdecl.h"
13 
14 using namespace std;
15 using namespace RTC;
16 
17 namespace cnoid {
18 
20 typedef map<string, string> PropertyMap;
21 
23 {
24 public:
25  RTComponent(const boost::filesystem::path& modulePath, PropertyMap& properties);
26  ~RTComponent();
27  void deleteRTC(bool waitToBeDeleted);
28  RtcBase* rtc() { return rtc_; };
29  bool isValid() const;
30  const std::string& name() const { return componentName; }
31 
32 private:
33  RTObject_var rtcRef;
34  RtcBase* rtc_;
35  boost::filesystem::path modulePath;
36  Process rtcProcess;
37  string componentName;
38  MessageView* mv;
39 
40  void init(const string& moduleName, PropertyMap& properties);
41  void init(const boost::filesystem::path& modulePath, PropertyMap& properties);
42  bool createRTC(PropertyMap& properties);
43  void setupModules(string& fileName, string& initFuncName, string& componentName, PropertyMap& properties );
44  void createProcess(string& command, PropertyMap& properties);
45  void onReadyReadServerProcessOutput();
46 };
47 
48 class CNOID_EXPORT RTCItem : public Item
49 {
50 public:
51  static void initialize(ExtensionManager* ext);
52 
53  RTCItem();
54  RTCItem(const RTCItem& org);
55  virtual ~RTCItem();
56 
58  PERIODIC_EXECUTION_CONTEXT = 0,
62  N_PERIODIC_TYPE
63  };
64 
65  enum PathBase {
66  RTC_DIRECTORY = 0,
68  N_PATH_BASE
69  };
70 
71  void setModuleName(const std::string& name);
72  void setPeriodicType(int type);
73  void setPeriodicRate(int rate);
74  void setPathBase(int base);
75 
76 protected:
77  virtual void onPositionChanged();
78  virtual void onDisconnectedFromRoot();
79  virtual Item* doDuplicate() const;
80  virtual void doPutProperties(PutPropertyFunction& putProperty);
81  virtual bool store(Archive& archive);
82  virtual bool restore(const Archive& archive);
83 
84 private:
85  ostream& os;
86  MessageView* mv;
87  string moduleName;
88  RTComponent* rtcomp;
89  Selection periodicType;
90  int periodicRate;
91  int oldType;
92  PropertyMap properties;
93  Selection pathBase;
94  int oldPathBase;
95  boost::filesystem::path modulePath;
96 
97  bool convertAbsolutePath();
98 };
99 
101 }
102 
103 #endif
Definition: Archive.h:21
Definition: ExtensionManager.h:26
Definition: RTCItem.h:67
const std::string & name() const
Definition: RTCItem.h:30
STL namespace.
Definition: RTCItem.h:48
RtcBase * rtc()
Definition: RTCItem.h:28
Definition: PutPropertyFunction.h:35
Definition: Referenced.h:128
Definition: Selection.h:14
Definition: Process.h:24
Definition: MessageView.h:19
PathBase
Definition: RTCItem.h:65
Definition: Item.h:38
CNOID_EXPORT bool deleteRTC(RTC::RtcBase *rtc, bool waitToBeDeleted=true)
Definition: OpenRTMPlugin.cpp:401
Defines the minimum processing for performing pasing file for STL.
Definition: AbstractSceneLoader.h:9
map< string, string > PropertyMap
Definition: RTCItem.h:19
PERIODIC_TYPE
Definition: RTCItem.h:57
Definition: RTCItem.h:59
#define CNOID_EXPORT
Definition: Util/exportdecl.h:37
ref_ptr< RTCItem > RTCItemPtr
Definition: RTCItem.h:100
Definition: RTCItem.h:22