CorbaNaming.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00020 #ifndef CorbaNaming_h
00021 #define CorbaNaming_h
00022 
00023 #include <rtm/RTC.h>
00024 #ifdef ORB_IS_OMNIORB
00025 #undef PACKAGE_BUGREPORT
00026 #undef PACKAGE_NAME
00027 #undef PACKAGE_STRING
00028 #undef PACKAGE_TARNAME
00029 #undef PACKAGE_VERSION
00030 #include <omniORB4/CORBA.h>
00031 #endif
00032 
00033 // STL includes
00034 #include <map>
00035 #include <string>
00036 #include <vector>
00037 
00052 namespace RTC
00053 {
00092   class CorbaNaming
00093   {
00094   public:
00110     CorbaNaming(CORBA::ORB_ptr orb);
00111     
00129     CorbaNaming(CORBA::ORB_ptr orb, const char* name_server);
00130     
00142     virtual ~CorbaNaming(){};
00143     
00163     void init(const char* name_server);
00164     
00165     typedef CosNaming::NamingContext::NotFound      NotFound;
00166     typedef CosNaming::NamingContext::CannotProceed CannotProceed;
00167     typedef CosNaming::NamingContext::InvalidName   InvalidName;
00168     typedef CosNaming::NamingContext::AlreadyBound  AlreadyBound;
00169     typedef CosNaming::NamingContext::NotEmpty      NotEmpty;
00170     typedef CosNaming::NamingContextExt::InvalidAddress InvalidAddress;
00171     typedef std::vector<CORBA::Object_ptr> ObjectList;
00172     
00255     void bind(const CosNaming::Name& name, CORBA::Object_ptr obj,
00256               const bool force = 1)
00257       throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00258     
00297     void bindByString(const char* string_name, CORBA::Object_ptr obj,
00298                       const bool force = 1)
00299       throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00300     
00361     void bindRecursive(CosNaming::NamingContext_ptr context,
00362                        const CosNaming::Name& name,
00363                        CORBA::Object_ptr obj)
00364       throw(CannotProceed, InvalidName, AlreadyBound);
00365     
00403     void rebind(const CosNaming::Name& name, CORBA::Object_ptr obj,
00404                 const bool force = 1)
00405       throw(NotFound, CannotProceed, InvalidName);
00406     
00443     void rebindByString(const char* string_name, CORBA::Object_ptr obj,
00444                         const bool force = 1)
00445       throw(NotFound, CannotProceed, InvalidName);
00446     
00484     void rebindRecursive(CosNaming::NamingContext_ptr context,
00485                          const CosNaming::Name& name,
00486                          CORBA::Object_ptr obj)
00487       throw(CannotProceed, InvalidName);
00488     
00525     void bindContext(const CosNaming::Name& name,
00526                      CosNaming::NamingContext_ptr name_cxt,
00527                      const bool force = 1)
00528       throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00529     
00567     void bindContext(const char* string_name,
00568                      CosNaming::NamingContext_ptr name_cxt,
00569                      const bool force = 1)
00570       throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00571     
00597     void bindContextRecursive(CosNaming::NamingContext_ptr context,
00598                               const CosNaming::Name& name,
00599                               CosNaming::NamingContext_ptr name_cxt);
00600     
00639     void rebindContext(const CosNaming::Name& name,
00640                        CosNaming::NamingContext_ptr name_cxt,
00641                        const bool force = 1)
00642       throw(NotFound, CannotProceed, InvalidName);
00643     
00682     void rebindContext(const char* string_name,
00683                        CosNaming::NamingContext_ptr name_cxt,
00684                        const bool force = 1)
00685       throw(NotFound, CannotProceed, InvalidName);
00686     
00712     void rebindContextRecursive(CosNaming::NamingContext_ptr context,
00713                                 const CosNaming::Name& name,
00714                                 CosNaming::NamingContext_ptr name_cxt);
00715     
00757     CORBA::Object_ptr resolve(const CosNaming::Name& name)
00758       throw(NotFound, CannotProceed, InvalidName);
00759     
00802     CORBA::Object_ptr resolve(const char* string_name)
00803       throw(NotFound, CannotProceed, InvalidName);
00804     
00842     void unbind(const CosNaming::Name& name)
00843       throw(NotFound, CannotProceed, InvalidName);
00844     
00887     void unbind(const char* string_name)
00888       throw(NotFound, CannotProceed, InvalidName);
00889     
00911     CosNaming::NamingContext_ptr newContext();
00912     
00952     CosNaming::NamingContext_ptr
00953     bindNewContext(const CosNaming::Name& name, bool force = true)
00954       throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00955     
00996     CosNaming::NamingContext_ptr
00997     bindNewContext(const char* string_name, bool force = true)
00998       throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00999     
01027     void destroy(CosNaming::NamingContext_ptr context)
01028       throw(NotEmpty);
01029     
01061     void destroyRecursive(CosNaming::NamingContext_ptr context)
01062       throw(NotEmpty, NotFound, CannotProceed, InvalidName);
01063     
01077     void clearAll();
01078     
01102     void list(CosNaming::NamingContext_ptr name_cxt,
01103               unsigned long how_many,
01104               CosNaming::BindingList_var& bl,
01105               CosNaming::BindingIterator_var& bi);
01106     
01107     //============================================================
01108     // interface of NamingContextExt
01109     //============================================================
01135     char* toString(const CosNaming::Name& name)
01136       throw(InvalidName);
01137     
01163     CosNaming::Name toName(const char* string_name)
01164       throw(InvalidName);
01165     
01195     char* toUrl(char* addr, char* string_name)
01196       throw(InvalidAddress, InvalidName);
01197     
01229     CORBA::Object_ptr resolveStr(const char* string_name)
01230       throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
01231     
01232     //============================================================
01233     // Find functions
01234     //============================================================
01235     
01236     //    ObjectList find(const char* name, const char* kind);
01237     //    ObjectList findById(const char* name, const char* kind);
01238     //    ObjectList findByKind(const char* name, const char* kind);
01239     
01272     CORBA::Object_ptr bindOrResolve(CosNaming::NamingContext_ptr context,
01273                                     const CosNaming::Name& name,
01274                                     CORBA::Object_ptr obj);
01275     
01309     CosNaming::NamingContext_ptr
01310     bindOrResolveContext(CosNaming::NamingContext_ptr context,
01311                          const CosNaming::Name& name,
01312                          CosNaming::NamingContext_ptr new_context);
01313     
01344     CosNaming::NamingContext_ptr
01345     bindOrResolveContext(CosNaming::NamingContext_ptr context,
01346                          const CosNaming::Name& name);
01347     
01365     const char* getNameServer();
01366     
01384     CosNaming::NamingContext_ptr getRootContext();
01385     
01407     bool isNamingContext(CORBA::Object_ptr obj);
01408     
01430     bool isNamingContext(const CosNaming::Name& name);
01431     
01453     bool isNamingContext(const char* string_name);
01454     
01484     CosNaming::Name subName(const CosNaming::Name& name,
01485                             long begin,
01486                             long end = -1);
01487     
01488   protected:
01521     void nameToString(const CosNaming::Name& name, char* string_name,
01522                       unsigned long slen);
01551     CORBA::ULong getNameLength(const CosNaming::Name& name);
01552     
01578     unsigned int split(const std::string& input,
01579                        const std::string& delimiter,
01580                        std::vector<std::string>& results);
01581     
01589     CORBA::ORB_var m_varORB;
01590     
01598     std::string m_nameServer;
01606     CosNaming::NamingContextExt_var m_rootContext;
01607     
01608   private:
01609     CORBA::ULong m_blLength;
01610     
01611   }; // class CorbaNaming
01612 }; // namespace RTC
01613 
01614 #endif // end of __Naming_h__

Generated on Thu May 29 15:03:33 2008 for OpenRTM by  doxygen 1.5.3