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

CorbaNaming.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00020 /*
00021  * $Log: CorbaNaming.h,v $
00022  * Revision 1.1  2006/11/04 19:43:01  n-ando
00023  * CORBA Naming service helper class has rewritten and renamed.
00024  *
00025  */
00026 
00027 
00028 #ifndef CorbaNaming_h
00029 #define CorbaNaming_h
00030 
00031 #include <rtm/RTC.h>
00032 #ifdef ORB_IS_OMNIORB
00033 #undef PACKAGE_BUGREPORT
00034 #undef PACKAGE_NAME
00035 #undef PACKAGE_STRING
00036 #undef PACKAGE_TARNAME
00037 #undef PACKAGE_VERSION
00038 #include <omniORB4/CORBA.h>
00039 #endif
00040 
00041 // STL includes
00042 #include <map>
00043 #include <string>
00044 #include <vector>
00045 
00046 namespace RTC
00047 {
00082   class CorbaNaming
00083   {
00084   public:
00085     CorbaNaming(CORBA::ORB_ptr orb);
00086     CorbaNaming(CORBA::ORB_ptr orb, const char* name_server);
00087     virtual ~CorbaNaming(){};
00088     void init(const char* name_server);
00089 
00090     typedef CosNaming::NamingContext::NotFound      NotFound;
00091     typedef CosNaming::NamingContext::CannotProceed CannotProceed;
00092     typedef CosNaming::NamingContext::InvalidName   InvalidName;
00093     typedef CosNaming::NamingContext::AlreadyBound  AlreadyBound;
00094     typedef CosNaming::NamingContext::NotEmpty      NotEmpty;
00095     typedef CosNaming::NamingContextExt::InvalidAddress InvalidAddress;
00096     typedef std::vector<CORBA::Object_ptr> ObjectList;
00097 
00098 
00144     void bind(const CosNaming::Name& name, CORBA::Object_ptr obj,
00145               const bool force = 1)
00146       throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00147 
00148 
00172     void bindByString(const char* string_name, CORBA::Object_ptr obj,
00173                       const bool force = 1)
00174       throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00175 
00211     void bindRecursive(CosNaming::NamingContext_ptr context,
00212                        const CosNaming::Name& name,
00213                        CORBA::Object_ptr obj)
00214       throw(CannotProceed, InvalidName, AlreadyBound);
00215 
00216 
00217 
00237     void rebind(const CosNaming::Name& name, CORBA::Object_ptr obj,
00238                 const bool force = 1)
00239       throw(NotFound, CannotProceed, InvalidName);
00240 
00241 
00264     void rebindByString(const char* string_name, CORBA::Object_ptr obj,
00265                         const bool force = 1)
00266       throw(NotFound, CannotProceed, InvalidName);
00267 
00268     
00293     void rebindRecursive(CosNaming::NamingContext_ptr context,
00294                          const CosNaming::Name& name,
00295                          CORBA::Object_ptr obj)
00296       throw(CannotProceed, InvalidName);
00297 
00316     void bindContext(const CosNaming::Name& name,
00317                      CosNaming::NamingContext_ptr name_cxt,
00318                      const bool force = 1)
00319       throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00320 
00339     void bindContext(const char* string_name,
00340                      CosNaming::NamingContext_ptr name_cxt,
00341                      const bool force = 1)
00342       throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00343 
00363     void bindContextRecursive(CosNaming::NamingContext_ptr context,
00364                               const CosNaming::Name& name,
00365                               CosNaming::NamingContext_ptr name_cxt);
00386     void rebindContext(const CosNaming::Name& name,
00387                        CosNaming::NamingContext_ptr name_cxt,
00388                        const bool force = 1)
00389       throw(NotFound, CannotProceed, InvalidName);
00390 
00411     void rebindContext(const char* string_name,
00412                        CosNaming::NamingContext_ptr name_cxt,
00413                        const bool force = 1)
00414       throw(NotFound, CannotProceed, InvalidName);
00415 
00416 
00417     void rebindContextRecursive(CosNaming::NamingContext_ptr context,
00418                                 const CosNaming::Name& name,
00419                                 CosNaming::NamingContext_ptr name_cxt);
00420 
00440     CORBA::Object_ptr resolve(const CosNaming::Name& name)
00441       throw(NotFound, CannotProceed, InvalidName);
00442 
00462     CORBA::Object_ptr resolve(const char* string_name)
00463       throw(NotFound, CannotProceed, InvalidName);
00464 
00484     void unbind(const CosNaming::Name& name)
00485       throw(NotFound, CannotProceed, InvalidName);
00486 
00506     void unbind(const char* string_name)
00507       throw(NotFound, CannotProceed, InvalidName);
00508 
00523     CosNaming::NamingContext_ptr newContext();
00524 
00540     CosNaming::NamingContext_ptr
00541     bindNewContext(const CosNaming::Name& name, bool force = true)
00542       throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00543 
00559     CosNaming::NamingContext_ptr
00560     bindNewContext(const char* string_name, bool force = true)
00561       throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00562 
00586     void destroy(CosNaming::NamingContext_ptr context)
00587       throw(NotEmpty);
00588 
00589 
00597     void destroyRecursive(CosNaming::NamingContext_ptr context)
00598       throw(NotEmpty, NotFound, CannotProceed, InvalidName);
00599 
00600 
00608     void clearAll();
00609 
00610 
00618     void list(CosNaming::NamingContext_ptr name_cxt,
00619               unsigned long how_many,
00620               CosNaming::BindingList_var& bl,
00621               CosNaming::BindingIterator_var& bi);
00622 
00623 
00624     //============================================================
00625     // interface of NamingContextExt
00626     //============================================================
00634     char* toString(const CosNaming::Name& name)
00635       throw(InvalidName);
00636     
00637 
00645     CosNaming::Name toName(const char* string_name)
00646       throw(InvalidName);
00647 
00648 
00656     char* toUrl(char* addr, char* string_name)
00657       throw(InvalidAddress, InvalidName);
00658 
00659 
00667     CORBA::Object_ptr resolveStr(const char* string_name)
00668       throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00669 
00670 
00671     //============================================================
00672     // Find functions
00673     //============================================================
00674 
00675     //    ObjectList find(const char* name, const char* kind);
00676     //    ObjectList findById(const char* name, const char* kind);
00677     //    ObjectList findByKind(const char* name, const char* kind);
00678 
00686     CORBA::Object_ptr bindOrResolve(CosNaming::NamingContext_ptr context,
00687                                     const CosNaming::Name& name,
00688                                     CORBA::Object_ptr obj);
00689     
00697     CosNaming::NamingContext_ptr
00698     bindOrResolveContext(CosNaming::NamingContext_ptr context,
00699                          const CosNaming::Name& name,
00700                          CosNaming::NamingContext_ptr new_context);
00701 
00702     
00710     CosNaming::NamingContext_ptr
00711     bindOrResolveContext(CosNaming::NamingContext_ptr context,
00712                          const CosNaming::Name& name);
00713 
00714 
00722     const char* getNameServer();
00723     
00731     CosNaming::NamingContext_ptr getRootContext();
00732 
00733     
00741     bool isNamingContext(CORBA::Object_ptr obj);
00742     
00750     bool isNamingContext(const CosNaming::Name& name);
00751     
00759     bool isNamingContext(const char* string_name);
00760     
00768     CosNaming::Name subName(const CosNaming::Name& name,
00769                             long begin,
00770                             long end = -1);
00771 
00772 
00773   protected:
00781     void nameToString(const CosNaming::Name& name, char* string_name,
00782                       unsigned long slen);
00790     CORBA::ULong getNameLength(const CosNaming::Name& name);
00791 
00799     unsigned int split(const std::string& input,
00800                        const std::string& delimiter,
00801                        std::vector<std::string>& results);
00802     
00803     CORBA::ORB_var m_varORB;
00804     std::string m_nameServer;
00805     CosNaming::NamingContextExt_var m_rootContext;
00806 
00807   private:
00808     CORBA::ULong m_blLength;
00809     
00810   }; // class CorbaNaming
00811 
00812 }; // namespace RTC
00813 
00814 #endif // end of __Naming_h__

Generated on Mon Jan 15 12:15:34 2007 for OpenRTM by  doxygen 1.4.1