21 #define ACE_HAS_WINSOCK2 0 38 : m_varORB(orb), m_nameServer(
""),
39 m_rootContext(CosNaming::NamingContextExt::_nil()),
56 CORBA::Object_var obj;
66 throw std::bad_alloc();
81 CORBA::Object_var obj;
124 #else // ORB_IS_RTORB 125 force ?
bindRecursive(e.cxt(), e.rest_of_name(), obj) :
throw e;
126 #endif // ORB_IS_RTORB 152 const CosNaming::Name& name,
153 CORBA::Object_ptr obj)
156 CORBA::ULong len(name.length());
157 CosNaming::NamingContext_var cxt;
158 cxt = CosNaming::NamingContext::_duplicate(context);
160 for (CORBA::ULong i = 0; i < len; ++i)
164 cxt->bind(
subName(name, i, i), obj);
186 CORBA::Object_ptr obj,
202 #else // ORB_IS_RTORB 204 #endif // ORB_IS_RTORB 216 CORBA::Object_ptr obj,
231 const CosNaming::Name& name,
232 CORBA::Object_ptr obj)
235 CORBA::ULong len(name.length());
236 CosNaming::NamingContext_var cxt;
237 cxt = CosNaming::NamingContext::_duplicate(context);
239 for (CORBA::ULong i = 0; i < len; ++i)
243 cxt->rebind(
subName(name, i, i), obj);
252 cxt = cxt->bind_new_context(
subName(name, i, i));
259 _narrow(cxt->resolve(
subName(name, i, i)));
277 CosNaming::NamingContext_ptr name_cxt,
281 bind(name, name_cxt, force);
292 CosNaming::NamingContext_ptr name_cxt,
308 const CosNaming::Name& name,
309 CosNaming::NamingContext_ptr name_cxt)
323 CosNaming::NamingContext_ptr name_cxt,
327 rebind(name, name_cxt, force);
339 CosNaming::NamingContext_ptr name_cxt,
355 const CosNaming::Name& name,
356 CosNaming::NamingContext_ptr name_cxt)
433 CosNaming::NamingContext_ptr
449 #else // ORB_IS_RTORB 452 #endif // ORB_IS_RTORB 454 return CosNaming::NamingContext::_nil();
464 CosNaming::NamingContext_ptr
494 CosNaming::BindingList_var bl;
495 CosNaming::BindingIterator_var bi;
496 CORBA::Boolean cont(
true);
499 context->list(
m_blLength, bl.out(), bi.out());
500 #else // ORB_IS_RTORB 502 context->list(
m_blLength, (CosNaming::BindingList_out)bl,
503 (CosNaming::BindingIterator_ptr)bi);
504 #endif // ORB_IS_RTORB 508 CORBA::ULong len(bl->length());
510 for (CORBA::ULong i = 0; i < len; ++i)
512 if (bl[i].binding_type == CosNaming::ncontext)
514 CosNaming::NamingContext_var next_context;
515 next_context = CosNaming::NamingContext::
516 _narrow(context->resolve(bl[i].binding_name));
520 context->unbind(bl[i].binding_name);
521 next_context->destroy();
523 else if (bl[i].binding_type == CosNaming::nobject)
525 context->unbind(bl[i].binding_name);
531 if (CORBA::is_nil(bi)) cont =
false;
535 if (!CORBA::is_nil(bi)) bi->destroy();
559 CORBA::ULong how_many,
560 CosNaming::BindingList_var& bl,
561 CosNaming::BindingIterator_var& bi)
564 name_cxt->list(how_many, bl.out(), bi.out());
565 #else // ORB_IS_RTORB 566 name_cxt->list(how_many, (CosNaming::BindingList_out)bl,
567 (CosNaming::BindingIterator_ptr)bi);
568 #endif // ORB_IS_RTORB 582 if (name.length() == 0)
585 CORBA::ULong slen = 0;
588 CORBA::String_var string_name = CORBA::string_alloc(slen);
591 return string_name._retn();
607 std::string string_name(sname);
608 std::vector<std::string> name_comps;
611 CORBA::ULong nc_length = 0;
612 nc_length =
split(string_name, std::string(
"/"), name_comps);
616 CosNaming::Name_var name =
new CosNaming::Name();
617 name->length(nc_length);
620 for (CORBA::ULong i = 0; i < nc_length; ++i)
622 std::string::size_type pos;
623 pos = name_comps[i].find_last_of(
".");
624 if (pos != name_comps[i].npos)
627 CORBA::string_dup(name_comps[i].substr(0, pos).c_str());
629 CORBA::string_dup(name_comps[i].substr(pos + 1).c_str());
633 name[i].id = CORBA::string_dup(name_comps[i].c_str());
636 #else // ORB_IS_RTORB 637 name[i].kind = (
char*)
"";
638 #endif // ORB_IS_RTORB 682 const CosNaming::Name& name,
683 CORBA::Object_ptr obj)
687 context->bind(name, obj);
693 return context->resolve(name);
695 return CORBA::Object::_nil();
705 CosNaming::NamingContext_ptr
707 const CosNaming::Name& name,
708 CosNaming::NamingContext_ptr new_context)
710 return CosNaming::NamingContext
721 CosNaming::NamingContext_ptr
723 const CosNaming::Name& name)
761 CosNaming::NamingContext_var nc;
762 nc = CosNaming::NamingContext::_narrow(obj);
763 return CORBA::is_nil(nc) ? false :
true;
801 if (end < 0) end = name.length() - 1;
803 CosNaming::Name sub_name;
804 CORBA::ULong sub_len(end - (begin - 1));
807 sub_name.length(sub_len);
815 for (CORBA::ULong i = 0; i < sub_len; ++i)
817 sub_name[i] = name[begin + i];
836 char* s = string_name;
837 for (CORBA::ULong i = 0; i < name.length(); ++i)
840 for (
const char*
id = name[i].
id; *
id !=
'\0'; ++
id)
842 if (*
id ==
'/' || *
id ==
'.' || *
id ==
'\\') *s++ =
'\\';
846 if (((
const char*)(name[i].
id ))[0] ==
'\0' ||
847 ((
const char*)(name[i].kind))[0] !=
'\0')
850 for (
const char* kind = name[i].kind; *kind !=
'\0'; ++kind)
852 if (*kind ==
'/' || *kind ==
'.' || *kind ==
'\\')
859 string_name[slen-1] =
'\0';
871 CORBA::ULong slen = 0;
873 for (CORBA::ULong i = 0; i < name.length(); ++i)
876 for (
const char*
id = name[i].
id; *
id; ++
id)
879 if (*
id ==
'/' || *
id ==
'.' || *
id ==
'\\') slen++;
883 if (((
const char*)(name[i].
id ))[0] ==
'\0' ||
884 ((
const char*)(name[i].kind))[0] !=
'\0')
889 for (
const char* kind = name[i].kind; *kind; kind++)
891 if (*kind ==
'/' || *kind ==
'.' || *kind ==
'\\') slen++;
908 const std::string& delimiter,
909 std::vector<std::string>& results)
911 typedef std::string::size_type size;
912 size delim_size = delimiter.size();
913 size found_pos(0), begin_pos(0), pre_pos(0), substr_size(0);
915 if (input.substr(0, delim_size) == delimiter)
916 begin_pos = pre_pos = delim_size;
921 found_pos = input.find(delimiter, begin_pos);
922 if (found_pos == std::string::npos)
924 results.push_back(input.substr(pre_pos));
927 if (
'\\' == input.at(found_pos - 1))
929 begin_pos = found_pos + delim_size;
933 substr_size = found_pos - pre_pos;
937 results.push_back(input.substr(pre_pos, substr_size));
939 begin_pos = found_pos + delim_size;
940 pre_pos = found_pos + delim_size;
942 return results.size();
bool isNamingContext(CORBA::Object_ptr obj)
Determine whether the object is NamingContext.
CosNaming::NamingContext::CannotProceed CannotProceed
void destroyRecursive(CosNaming::NamingContext_ptr context)
Destroy the naming context recursively.
CORBA::Object_ptr resolveStr(const char *string_name)
Resolve from name of string representation and get object.
void rebindRecursive(CosNaming::NamingContext_ptr context, const CosNaming::Name &name, CORBA::Object_ptr obj)
Bind intermediate context recursively and rebind object.
void nameToString(const CosNaming::Name &name, char *string_name, CORBA::ULong slen)
Get string representation of name component.
CORBA::SystemException SystemException
CosNaming::NamingContext_ptr bindNewContext(const CosNaming::Name &name, bool force=true)
Bind new NamingContext.
CORBA::ORB_var m_varORB
ORB.
const char * getNameServer()
Get the name of name server.
void rebind(const CosNaming::Name &name, CORBA::Object_ptr obj, const bool force=1)
Rebind object.
unsigned int split(const std::string &input, const std::string &delimiter, std::vector< std::string > &results)
Split of string.
CosNaming::NamingContext_ptr getRootContext()
Get the root context.
CORBA::Object_ptr resolve(const CosNaming::Name &name)
Return object bound on the specified NameComponent.
std::string m_nameServer
Name of the name server.
CorbaNaming(CORBA::ORB_ptr orb)
Consructor.
void bindContextRecursive(CosNaming::NamingContext_ptr context, const CosNaming::Name &name, CosNaming::NamingContext_ptr name_cxt)
Bind intermediate context recursively and bind NamingContext.
void bindByString(const char *string_name, CORBA::Object_ptr obj, const bool force=1)
Bind object on specified string name position.
void list(CosNaming::NamingContext_ptr name_cxt, CORBA::ULong how_many, CosNaming::BindingList_var &bl, CosNaming::BindingIterator_var &bi)
Get Binding of the given NamingContext.
CORBA::ULong getNameLength(const CosNaming::Name &name)
Get string length of the name component's string representation.
void unbind(const CosNaming::Name &name)
Unbind a binding specified by NameComponent.
CosNaming::Name subName(const CosNaming::Name &name, CORBA::Long begin, CORBA::Long end=-1)
Get subset of given name component.
CosNaming::NamingContext::NotFound NotFound
CORBA naming service helper class.
void rebindContextRecursive(CosNaming::NamingContext_ptr context, const CosNaming::Name &name, CosNaming::NamingContext_ptr name_cxt)
Rebind intermediate context recursively and rebind NamingContext.
void init(const char *name_server)
Initialize the Naming Service.
void bindContext(const CosNaming::Name &name, CosNaming::NamingContext_ptr name_cxt, const bool force=1)
Bind NamingContext.
CosNaming::NamingContext_ptr newContext()
Create new NamingContext.
void bind(const CosNaming::Name &name, CORBA::Object_ptr obj, const bool force=1)
Bind object on specified name component position.
CosNaming::NamingContextExt_var m_rootContext
The root context of specified name server.
CosNaming::NamingContext::NotEmpty NotEmpty
CosNaming::Name toName(const char *string_name)
Resolve given string representation to NameComponent.
CosNaming::NamingContext::AlreadyBound AlreadyBound
CosNaming::NamingContext_ptr bindOrResolveContext(CosNaming::NamingContext_ptr context, const CosNaming::Name &name, CosNaming::NamingContext_ptr new_context)
Bind or resolve the given name component.
CosNaming::NamingContextExt::InvalidAddress InvalidAddress
CosNaming::NamingContext::InvalidName InvalidName
char * toUrl(char *addr, char *string_name)
Get URL representation from given addr and string_name.
void bindRecursive(CosNaming::NamingContext_ptr context, const CosNaming::Name &name, CORBA::Object_ptr obj)
Bind intermediate context recursively and bind object.
CORBA::Object_ptr bindOrResolve(CosNaming::NamingContext_ptr context, const CosNaming::Name &name, CORBA::Object_ptr obj)
Bind or resolve the given name component.
char * toString(const CosNaming::Name &name)
Get string representation of given NameComponent.
void destroy(CosNaming::NamingContext_ptr context)
Destroy the naming context.
void rebindContext(const CosNaming::Name &name, CosNaming::NamingContext_ptr name_cxt, const bool force=1)
Rebind NamingContext.
void clearAll()
Destroy all bindings.
void rebindByString(const char *string_name, CORBA::Object_ptr obj, const bool force=1)
Rebind Object.