Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

RtcNaming.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00019 /*
00020  * $Log: RtcNaming.h,v $
00021  * Revision 1.1.1.1  2005/05/12 09:06:18  n-ando
00022  * Public release.
00023  *
00024  *
00025  */
00026 
00027 
00028 #ifndef RtcNaming_h
00029 #define RtcNaming_h
00030 
00031 // CORBA header include
00032 #include "rtm/idl/RTMBaseStub.h"
00033 #include "rtm/idl/RTMBaseSkel.h"
00034 #include "rtm/RtcBase.h"
00035 
00036 // STL includes
00037 #include <map>
00038 #include <string>
00039 #include <vector>
00040 
00041 #define HOST_CTXT_LEVEL 1
00042 #define MANAGER_CTXT_LEVEL 2
00043 #define MANAGER_LEVEL 3
00044 #define CATEGORY_CTXT_LEVEL 3
00045 #define MODULE_CTXT_LEVEL 4
00046 #define COMPONENT_LEVEL 5
00047 
00048 namespace RTM
00049 {
00050   using namespace std;
00051   
00052   typedef std::vector<CosNaming::NamingContextExt_var> ContextList;
00053   typedef std::vector<CORBA::Object_ptr> ObjectList;
00054 
00055 
00071   class RtcNaming
00072   {
00073   public:
00084     RtcNaming() : m_bindListNum(100) {};
00085         
00096     RtcNaming(CORBA::ORB_ptr orb) : m_bindListNum(100) {initNaming(orb);};
00097         
00108         ~RtcNaming();
00109         
00110         
00125     bool initNaming(const CORBA::ORB_ptr orb);
00126         
00127         
00128     //============================================================
00129     // << Create and Bind Methods >>
00130     //============================================================
00131         
00132         
00155     CosNaming::NamingContextExt_var
00156     createContext(CosNaming::NamingContextExt_var context,
00157                                   const std::string& id, const std::string& kind);
00158         
00159         
00178     bool createHostContext(const std::string& id);
00179         
00180         
00199     bool createManagerContext(const std::string& id);
00200         
00201         
00220     bool createCategoryContext(const std::string& category);
00221         
00222         
00243     bool createModuleContext(const std::string& module,
00244                                                          const std::string& category);
00245         
00246         
00271     bool bindObject(CosNaming::NamingContextExt_var context,
00272                                         const std::string& id, const std::string& kind,
00273                                         CORBA::Object_ptr obj);
00274 
00295         bool bindObjectByFullPath(const std::string& path,
00296                                                           CORBA::Object_ptr obj);
00297         
00320     bool bindComponent(const std::string& component, const std::string& module,
00321                                            const std::string& category, CORBA::Object_ptr obj);
00322         
00343     bool bindManager(const std::string& id, CORBA::Object_ptr obj);
00344         
00345         
00346     //============================================================
00347     // << Destroy and Unbind methods >>
00348     //============================================================
00349         
00350         
00360     bool destroyHostContext();
00361         
00371     bool destroyManagerContext();
00372         
00386     bool destroyCategoryContext(const std::string& id);
00387         
00388         
00404     bool destroyModuleContext(const std::string& module,
00405                                                           const std::string& category);
00406         
00407         
00430     bool unbindObject(CosNaming::NamingContextExt_var context,
00431                                           const std::string& id, const std::string& kind);
00432 
00433 
00434 
00453         bool unbindObjectByFullPath(const std::string& path);
00454 
00455 
00479         bool unbindLocalComponent(const std::string category,
00480                                                           const std::string module,
00481                                                           const std::string instance);
00482         
00483 
00484 
00485     //============================================================
00486     // << Find methods >>
00487     //============================================================
00488         
00504     bool findHostContext(const std::string& id_seq, ContextList& context);
00505         
00506         
00522     bool findCategoryContext(const std::string& id_seq, ContextList& context);
00523         
00524         
00540     bool findModuleContext(const std::string& id_seq, ContextList& context);
00541         
00542         
00558     bool findManagerContext(const std::string& id_seq, ContextList& context);
00559         
00560         
00576     bool findManager(std::string& id, ObjectList& objects);
00577         
00578         
00594     bool findComponents(const std::string& id_seq, ObjectList& objects);
00595         
00596         
00597   protected:
00611     bool destroyRecursive(CosNaming::NamingContextExt_var context);
00612         
00613         
00631     void findObjectsRecursive(CosNaming::NamingContextExt_ptr context,
00632                                                           const std::string& path, ObjectList& obj);
00633         
00651     void findContextRecursive(CosNaming::NamingContextExt_var context,
00652                                                           const std::string& path, ContextList& context_list);
00653         
00654         
00672         void bindObjectRecursive(CosNaming::NamingContextExt_var context,
00673                                                          const std::string& path,
00674                                                          CORBA::Object_ptr obj);
00675         
00676         
00677   private:
00685     int split(const std::string& input, const std::string& delimiter,
00686                           std::vector<std::string>& results);
00687         
00702     std::string makeFullPath(std::string path, int level);
00703         
00721     bool pickupNode(const std::string& path, std::string& node, std::string& remain);
00722         
00741     void nodeToIdKindAny(const std::string& node,
00742                                           std::string& id, std::string& kind);
00743 
00761     void nodeToIdKind(const std::string& node,
00762                                           std::string& id, std::string& kind);
00763         
00764   private:
00765         
00773     CORBA::Object_var m_nameRef;
00774         
00782     CosNaming::NamingContextExt_var m_rootContext;
00783         
00791     CosNaming::NamingContextExt_var m_hostContext;
00792         std::string m_hostName;
00793 
00801     CosNaming::NamingContextExt_var m_mngrContext;
00802         std::string m_mngrName;
00803 
00811     std::map<std::string, CosNaming::NamingContextExt_var> m_cateContext;
00812         
00820     std::map<std::string, std::map<std::string, CosNaming::NamingContextExt_var> > m_compContext;
00821         
00829     int m_bindListNum;
00830         
00838     std::vector<CORBA::Object_ptr> m_vObjects;
00839         
00840   };
00841   
00842 }; // end of namespace RTM
00843 
00844 #endif // end of __RtcNaming_h__

Generated on Mon May 23 03:13:56 2005 for OpenRTM by doxygen 1.3.6