00001
00020 #ifndef CorbaNaming_h
00021 #define CorbaNaming_h
00022
00023 #include <rtm/RTC.h>
00024
00025
00026 #include <map>
00027 #include <string>
00028 #include <vector>
00029
00045 #ifdef WIN32
00046 #pragma warning( disable : 4290 )
00047 #endif
00048
00049 namespace RTC
00050 {
00089 class CorbaNaming
00090 {
00091 public:
00107 CorbaNaming(CORBA::ORB_ptr orb);
00108
00126 CorbaNaming(CORBA::ORB_ptr orb, const char* name_server);
00127
00139 virtual ~CorbaNaming(void){};
00140
00160 void init(const char* name_server);
00161
00162 typedef CosNaming::NamingContext::NotFound NotFound;
00163 typedef CosNaming::NamingContext::CannotProceed CannotProceed;
00164 typedef CosNaming::NamingContext::InvalidName InvalidName;
00165 typedef CosNaming::NamingContext::AlreadyBound AlreadyBound;
00166 typedef CosNaming::NamingContext::NotEmpty NotEmpty;
00167 typedef CosNaming::NamingContextExt::InvalidAddress InvalidAddress;
00168 typedef std::vector<CORBA::Object_ptr> ObjectList;
00169
00252 void bind(const CosNaming::Name& name, CORBA::Object_ptr obj,
00253 const bool force = 1)
00254 throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00255
00294 void bindByString(const char* string_name, CORBA::Object_ptr obj,
00295 const bool force = 1)
00296 throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00297
00358 void bindRecursive(CosNaming::NamingContext_ptr context,
00359 const CosNaming::Name& name,
00360 CORBA::Object_ptr obj)
00361 throw(CannotProceed, InvalidName, AlreadyBound);
00362
00400 void rebind(const CosNaming::Name& name, CORBA::Object_ptr obj,
00401 const bool force = 1)
00402 throw(NotFound, CannotProceed, InvalidName);
00403
00440 void rebindByString(const char* string_name, CORBA::Object_ptr obj,
00441 const bool force = 1)
00442 throw(NotFound, CannotProceed, InvalidName);
00443
00481 void rebindRecursive(CosNaming::NamingContext_ptr context,
00482 const CosNaming::Name& name,
00483 CORBA::Object_ptr obj)
00484 throw(CannotProceed, InvalidName);
00485
00522 void bindContext(const CosNaming::Name& name,
00523 CosNaming::NamingContext_ptr name_cxt,
00524 const bool force = 1)
00525 throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00526
00564 void bindContext(const char* string_name,
00565 CosNaming::NamingContext_ptr name_cxt,
00566 const bool force = 1)
00567 throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00568
00594 void bindContextRecursive(CosNaming::NamingContext_ptr context,
00595 const CosNaming::Name& name,
00596 CosNaming::NamingContext_ptr name_cxt);
00597
00636 void rebindContext(const CosNaming::Name& name,
00637 CosNaming::NamingContext_ptr name_cxt,
00638 const bool force = 1)
00639 throw(NotFound, CannotProceed, InvalidName);
00640
00679 void rebindContext(const char* string_name,
00680 CosNaming::NamingContext_ptr name_cxt,
00681 const bool force = 1)
00682 throw(NotFound, CannotProceed, InvalidName);
00683
00709 void rebindContextRecursive(CosNaming::NamingContext_ptr context,
00710 const CosNaming::Name& name,
00711 CosNaming::NamingContext_ptr name_cxt);
00712
00754 CORBA::Object_ptr resolve(const CosNaming::Name& name)
00755 throw(NotFound, CannotProceed, InvalidName);
00756
00799 CORBA::Object_ptr resolve(const char* string_name)
00800 throw(NotFound, CannotProceed, InvalidName);
00801
00839 void unbind(const CosNaming::Name& name)
00840 throw(NotFound, CannotProceed, InvalidName);
00841
00884 void unbind(const char* string_name)
00885 throw(NotFound, CannotProceed, InvalidName);
00886
00908 CosNaming::NamingContext_ptr newContext();
00909
00949 CosNaming::NamingContext_ptr
00950 bindNewContext(const CosNaming::Name& name, bool force = true)
00951 throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00952
00993 CosNaming::NamingContext_ptr
00994 bindNewContext(const char* string_name, bool force = true)
00995 throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
00996
01024 void destroy(CosNaming::NamingContext_ptr context)
01025 throw(NotEmpty);
01026
01058 void destroyRecursive(CosNaming::NamingContext_ptr context)
01059 throw(NotEmpty, NotFound, CannotProceed, InvalidName);
01060
01074 void clearAll();
01075
01099 void list(CosNaming::NamingContext_ptr name_cxt,
01100 unsigned long how_many,
01101 CosNaming::BindingList_var& bl,
01102 CosNaming::BindingIterator_var& bi);
01103
01104
01105
01106
01132 char* toString(const CosNaming::Name& name)
01133 throw(InvalidName);
01134
01160 CosNaming::Name toName(const char* string_name)
01161 throw(InvalidName);
01162
01192 char* toUrl(char* addr, char* string_name)
01193 throw(InvalidAddress, InvalidName);
01194
01226 CORBA::Object_ptr resolveStr(const char* string_name)
01227 throw(NotFound, CannotProceed, InvalidName, AlreadyBound);
01228
01229
01230
01231
01232
01233
01234
01235
01236
01269 CORBA::Object_ptr bindOrResolve(CosNaming::NamingContext_ptr context,
01270 const CosNaming::Name& name,
01271 CORBA::Object_ptr obj);
01272
01306 CosNaming::NamingContext_ptr
01307 bindOrResolveContext(CosNaming::NamingContext_ptr context,
01308 const CosNaming::Name& name,
01309 CosNaming::NamingContext_ptr new_context);
01310
01341 CosNaming::NamingContext_ptr
01342 bindOrResolveContext(CosNaming::NamingContext_ptr context,
01343 const CosNaming::Name& name);
01344
01362 const char* getNameServer();
01363
01381 CosNaming::NamingContext_ptr getRootContext();
01382
01404 bool isNamingContext(CORBA::Object_ptr obj);
01405
01427 bool isNamingContext(const CosNaming::Name& name);
01428
01450 bool isNamingContext(const char* string_name);
01451
01481 CosNaming::Name subName(const CosNaming::Name& name,
01482 long begin,
01483 long end = -1);
01484
01485 protected:
01518 void nameToString(const CosNaming::Name& name, char* string_name,
01519 unsigned long slen);
01548 CORBA::ULong getNameLength(const CosNaming::Name& name);
01549
01575 unsigned int split(const std::string& input,
01576 const std::string& delimiter,
01577 std::vector<std::string>& results);
01578
01586 CORBA::ORB_var m_varORB;
01587
01595 std::string m_nameServer;
01603 CosNaming::NamingContextExt_var m_rootContext;
01604
01605 private:
01606 CORBA::ULong m_blLength;
01607
01608 };
01609 };
01610
01611 #ifdef WIN32
01612 #pragma warning( default : 4290 )
01613 #endif
01614
01615 #endif // end of __Naming_h__