00001
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #ifndef PortAdmin_h
00046 #define PortAdmin_h
00047
00048 #include <rtm/idl/RTCSkel.h>
00049 #include <rtm/PortBase.h>
00050 #include <rtm/ObjectManager.h>
00051
00052
00053
00054 namespace RTC
00055 {
00056
00057
00058 class PortAdmin
00059 {
00060 public:
00061 PortAdmin(CORBA::ORB_ptr, PortableServer::POA_ptr poa);
00062 virtual ~PortAdmin(){};
00063
00084 PortList* getPortList() const;
00085
00086 PortProfileList getPortProfileList() const;
00111 Port_ptr getPortRef(const char* port_name) const;
00112
00113
00138 PortBase* getPort(const char* port_name) const;
00139
00140
00165 void registerPort(PortBase& port);
00166
00167
00191 void deletePort(PortBase& port);
00192
00216 void deletePortByName(const char* port_name);
00217
00218
00236 void finalizePorts();
00237
00238 private:
00239
00240 CORBA::ORB_var m_pORB;
00241
00242
00243 PortableServer::POA_var m_pPOA;
00244
00245
00246 PortList m_portRefs;
00247
00248
00249 template <class T>
00250 class comp_op
00251 {
00252 public:
00253 comp_op(const char* _name)
00254 :
00255 m_name(_name)
00256 {
00257 }
00258 comp_op(T* obj)
00259 : m_name((const char*)(obj->getProfile().name))
00260 {
00261 }
00262 bool operator()(T* obj)
00263 {
00264 std::string name((const char*)obj->getProfile().name);
00265 return m_name == name;
00266 }
00267 private:
00268 std::string m_name;
00269 };
00270
00271 class port_prof_collect
00272 {
00273 public:
00274 port_prof_collect(PortProfileList& p) : m_p(p) {}
00275 void operator()(const PortBase* port)
00276 {
00277 CORBA_SeqUtil::push_back(m_p, port->getPortProfile());
00278 }
00279 private:
00280 PortProfileList& m_p;
00281 };
00282
00283 struct find_port_name;
00284 struct del_port;
00285
00286
00287 ObjectManager<const char*, PortBase, comp_op<PortBase> > m_portServants;
00288
00289
00290 };
00291 };
00292 #endif // PortAdmin_h