diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-12-11 05:08:55 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-12-11 05:08:55 +0000 |
commit | 906621e8abcd41976a107a3e9e65acdd82319987 (patch) | |
tree | f0d7c8c18e8858c7564f91eee1a97f0c888f5990 | |
parent | dd00eabf59040f7cfb89907ffb8f193f4fe64427 (diff) | |
download | ATCD-906621e8abcd41976a107a3e9e65acdd82319987.tar.gz |
This files are in $TAO_ROOT/orbsvcs now
-rw-r--r-- | TAO/ORB_Services/Naming_Service/CosNaming.idl | 210 | ||||
-rw-r--r-- | TAO/ORB_Services/Naming_Service/NS_CosNaming.C | 678 | ||||
-rw-r--r-- | TAO/ORB_Services/Naming_Service/NS_CosNaming.h | 278 |
3 files changed, 0 insertions, 1166 deletions
diff --git a/TAO/ORB_Services/Naming_Service/CosNaming.idl b/TAO/ORB_Services/Naming_Service/CosNaming.idl deleted file mode 100644 index 80715b3115f..00000000000 --- a/TAO/ORB_Services/Naming_Service/CosNaming.idl +++ /dev/null @@ -1,210 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// cos -// -// = FILENAME -// CosNaming.idl -// -// = AUTHOR -// Marina Spivak -// -// ============================================================================ - -module CosNaming - // = TITLE - // This module provides interface for using COS Naming Service. -{ - typedef string Istring; - struct NameComponent - { - Istring id; - // This is the name that is used to identify object references. - - Istring kind; - // Stores any addtional info about the object reference. - }; - // This is a 'simple' name. - // NOTE: both id and kind fields are used in resolving names. - - typedef sequence <NameComponent> Name; - // This is a compound name: <c1; c2; c3; cn> where c1 to cn-1 are - // the names of the nested contexts, and cn is the name of the - // object bound in cn-1. - - enum BindingType - { - nobject, - // object binding. - - ncontext - // naming context binding. - }; - - struct Binding - { - Name binding_name; - BindingType binding_type; - }; - - typedef sequence <Binding> BindingList; - - interface BindingIterator; - // Forward declaration. - - interface NamingContext - // = TITLE - // Interface for managing name bindings and naming contexts. - { - // = Exceptions. - - enum NotFoundReason - { - missing_node, - not_context, - not_object - }; - - exception NotFound - { - NotFoundReason why; - Name rest_of_name; - }; - // Indicates that the name does not identify a binding. - - exception CannotProceed - { - //Commented out due to the bug in Orbix compiler - //NamingContext cxt; - Name rest_of_name; - }; - // Implementation has given up for some reason. The client, - // however, may be able to continue operation at the returned - // naming context. - - exception InvalidName {}; - // A name of length 0 is invalid. - // Implementations may place further restrictions. - - exception AlreadyBound {}; - // Indicates that the specified name is already bound to some - // object. Only one object can be bound to a particular name in - // a context. To change the binding, <rebind> and - // <rebind_context> can be used. - - exception NotEmpty {}; - // Indicates that the context is not empty. - - // = Binding operations. - - void bind (in Name n, in Object obj) - raises(NotFound, CannotProceed, InvalidName, AlreadyBound); - // create a binding for name <n> and object <obj> in the naming - // context. Compound names are treated as follows: ctx->bind - // (<c1; c2; c3; cn>, obj) = (ctx->resolve (<c1; c2; - // cn-1>))->bind (<cn>, obj) if the there already exists a - // binding for the specified name, <AlreadyBound> exception is - // thrown. Naming contexts should be bound using <bind_context> - // and <rebind_context> in order to participate in name - // resolution later. - - void rebind (in Name n, in Object obj) - raises(NotFound, CannotProceed, InvalidName); - // this is similar to <bind> operation above, except for when - // the binding for the specified name already exists in the - // specified context. In that case, the existing binding is - // replaced with the new one. - - void bind_context (in Name n, in NamingContext nc) - raises(NotFound, CannotProceed, InvalidName, AlreadyBound); - // This is the version of <bind> specifically for binding naming - // contexts, so that they will participate in name resolution - // when compound names are passed to be resolved. - - void rebind_context (in Name n, in NamingContext nc) - raises(NotFound, CannotProceed, InvalidName); - // This is a version of <rebind> specifically for naming - // contexts, so that they can participate in name resolution - // when compound names are passed. - - // = Resolving names. - - Object resolve (in Name n) - raises(NotFound, CannotProceed, InvalidName); - // Return object reference that is bound to the name. Compound - // name resolve is defined as follows: ctx->resolve (<c1; c2; - // cn>) = ctx->resolve (<c1; c2 cn-1>)->resolve (<cn>) The - // naming service does not return the type of the object. - // Clients are responsible for "narrowing" the object to the - // appropriate type. - - // = Unbinding names. - - void unbind (in Name n) - raises(NotFound, CannotProceed, InvalidName); - // Remove the name binding from the context. When compound - // names are used, unbind is defined as follows: ctx->unbind - // (<c1; c2; cn>) = (ctx->resolve (<c1; c2; cn-1>))->unbind - // (<cn>) - - // = Creating Naming Contexts. - - NamingContext new_context (); - // This operation returns a new naming context implemented by - // the same naming server in which the operation was invoked. - // The context is not bound. - - NamingContext bind_new_context (in Name n) - raises(NotFound, AlreadyBound, CannotProceed, InvalidName); - // This operation creates a new context and binds it to the name - // supplied as an argument. The newly-created context is - // implemented by the same server as the context in which it was - // bound (the name argument excluding the last component). - - // = Deleting contexts. - - void destroy () - raises (NotEmpty); - // Delete the naming context. NOTE: the user should <unbind> - // any bindings in which the given context is bound to some - // names before invoking <destroy> operation on it. Ignoring - // this rule may cause unexpected behaviour. <destroy> deletes - // the context object if it is not bound to any names in the - // given address space. <destroys> decrements the reference - // count of the context if bindings to it exist. - - // = Listing the naming context. - - void list (in unsigned long how_many, - out BindingList bl, out BindingIterator bi); - // Returns at most the requested number of bindings <how_many> - // in <bl>. If the naming context contains additional bindings, - // they are returned with a BindingIterator. In the naming - // context does not contain any additional bindings <bi> - // returned as null. - - void ref (in Object obj); - // temporary for debugging purposes. - }; - - interface BindingIterator - // = TITLE - // Interface for iterating over Bindings returned with the <list> - // operation. - { - boolean next_one (out Binding b); - // This operation returns the next binding. If there are no - // more bindings false is returned. - - boolean next_n (in unsigned long how_many, - out BindingList bl); - // This operation returns at most the requested number of - // bindings. - - void destroy (); - // This operation destroys the iterator. - }; -}; diff --git a/TAO/ORB_Services/Naming_Service/NS_CosNaming.C b/TAO/ORB_Services/Naming_Service/NS_CosNaming.C deleted file mode 100644 index bdcf2032150..00000000000 --- a/TAO/ORB_Services/Naming_Service/NS_CosNaming.C +++ /dev/null @@ -1,678 +0,0 @@ -// ============================================================================ -// -// = LIBRARY -// cos -// -// = FILENAME -// NS_CosNaming.C -// -// = AUTHOR -// Marina Spivak <marina@cs.wustl.edu> -// -// ============================================================================ - -#include "NS_CosNaming.h" - -NS_IntId::NS_IntId (void) - : type_ (CosNaming::nobject) -{ - ref_ = CORBA::Object::_nil (); -} - -NS_IntId::NS_IntId (CORBA::Object_ptr obj, - CosNaming::BindingType type) - : type_ (type) -{ - ref_ = obj->_duplicate (obj); -} - -NS_IntId::NS_IntId (const NS_IntId &rhs) -{ - type_ = rhs.type_; - ref_ = rhs.ref_->_duplicate (rhs.ref_); -} - -NS_IntId::~NS_IntId (void) -{ - CORBA::release (ref_); -} - -void -NS_IntId::operator= (const NS_IntId &rhs) -{ - // check for self assignment. - if (&rhs == this) - return; - - type_ = rhs.type_; - - CORBA::release (ref_); - ref_ = rhs.ref_->_duplicate (rhs.ref_); -} - -NS_ExtId::NS_ExtId (void) - : kind_ (), - id_ () -{ -} - -NS_ExtId::NS_ExtId (const char *id, - const char *kind) - : id_ (id), - kind_ (kind) -{ -} - -NS_ExtId::NS_ExtId (const NS_ExtId &rhs) -{ - id_ = rhs.id_; - kind_ = rhs.kind_; -} - -NS_ExtId::~NS_ExtId (void) -{ -} - -void -NS_ExtId::operator= (const NS_ExtId &rhs) -{ - // Check for self assignment. - if (&rhs == this) - return; - - id_ = rhs.id_; - kind_ = rhs.kind_; -} - -int -NS_ExtId::operator== (const NS_ExtId &rhs) const -{ - return id_ == rhs.id_ && kind_ == rhs.kind_; -} - -int -NS_ExtId::operator!= (const NS_ExtId &rhs) const -{ - return id_ != rhs.id_ || kind_ != rhs.kind_; -} - -u_long -NS_ExtId::hash (void) const -{ - ACE_CString temp (id_); - temp += kind_; - - return temp.hash (); -} - -NS_NamingContext::NS_NamingContext (void) -{ - if (context_.open (NS_MAP_SIZE) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "NS_NamingContext")); - // deal with fault -} - -void -NS_NamingContext::initialize (CosNaming::NamingContext_ptr tie_ref) -{ - tie_ref_ = tie_ref; -} - -NS_NamingContext::~NS_NamingContext (void) -{ -} - -CosNaming::NamingContext_ptr -NS_NamingContext::get_context (const CosNaming::Name &name) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::AlreadyBound) -{ - // create compound name to be resolved - // (<name> - last component) - CORBA::ULong len = name.length (); - CosNaming::Name comp_name (name); - comp_name.length (len - 1); - - // resolve - CORBA::Object_var cont_ref; - - try - { - cont_ref = resolve (comp_name); - } - // Deal with exceptions in resolve: basicly, add the last component - // of the name to <rest_of_name> and rethrow. - catch (CosNaming::NamingContext::NotFound &nf) - { - CORBA::ULong l = nf.rest_of_name.length (); - nf.rest_of_name.length (l + 1); - nf.rest_of_name[l] = name[len - 1]; - throw CosNaming::NamingContext::NotFound (nf); - } - catch (CosNaming::NamingContext::CannotProceed &cp) - { - CORBA::ULong l = cp.rest_of_name.length (); - cp.rest_of_name.length (l + 1); - cp.rest_of_name[l] = name[len - 1]; - throw CosNaming::NamingContext::CannotProceed (cp); - } - - // Reference to a context from <resolve> cannot be nil because - // cannot <bind> to a nil object. - - // Try narrowing object reference to a context type. - CosNaming::NamingContext_ptr c; - try - { - c = CosNaming::NamingContext::_narrow (cont_ref); - } - catch (CORBA::SystemException) - { - CosNaming::Name rest; - rest.length (2); - rest[0] = name[len - 2]; - rest[1] = name[len - 1]; - throw CosNaming::NamingContext::NotFound (CosNaming::NamingContext::not_context, rest); - } - - if (CORBA::is_nil (c)) - { - CosNaming::Name rest; - rest.length (2); - rest[0] = name[len - 2]; - rest[1] = name[len - 1]; - throw CosNaming::NamingContext::NotFound (CosNaming::NamingContext::not_context, rest); - } - return c; -} - -void -NS_NamingContext::bind (const CosNaming::Name& n, - CORBA::Object_ptr obj, - CORBA::Environment &IT_env) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::InvalidName, - CosNaming::NamingContext::AlreadyBound) -{ - // get the length of the name - CORBA::ULong len = n.length (); - - // Check for invalid name. - if (len == 0) - throw CosNaming::NamingContext::InvalidName (); - - // If we received compound name, resolve it to get the context in - // which the binding should take place, then perform the binding on - // target context. - if (len > 1) - { - CosNaming::NamingContext_var cont = get_context (n); - CosNaming::Name simple_name; - simple_name.length (1); - simple_name[0] = n[len - 1]; - cont->bind (simple_name, obj); - } - - // If we received a simple name, we need to bind it in this context. - else - { - NS_IntId entry (obj); - NS_ExtId name (n[0].id, n[0].kind); - - // Try binding the name. - if (context_.bind (name, entry) == -1) - throw CosNaming::NamingContext::AlreadyBound (); - // May need to add case dealing with -1. (Maybe throw cannot - // proceed). - } -} - -void -NS_NamingContext::rebind (const CosNaming::Name& n, - CORBA::Object_ptr obj, - CORBA::Environment &IT_env) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::InvalidName) -{ - // get the length of the name - CORBA::ULong len = n.length (); - - // check for invalid name. - if (len == 0) - throw CosNaming::NamingContext::InvalidName (); - - // If we received compound name, resolve it to get the context in - // which the rebinding should take place, then perform the rebinding - // on target context. - if (len > 1) - { - CosNaming::NamingContext_var cont = get_context (n); - CosNaming::Name simple_name; - simple_name.length (1); - simple_name[0] = n[len - 1]; - cont->rebind (simple_name, obj); - } - - // If we received a simple name, we need to rebind it in this context. - else - { - NS_IntId entry (obj); - NS_ExtId name (n[0].id, n[0].kind); - NS_IntId oldentry; - NS_ExtId oldname; - - // Try rebinding the name. - if (context_.rebind (name, entry, oldname, oldentry) == -1) - ; - // Deal with consequences. - } -} - -void -NS_NamingContext::bind_context (const CosNaming::Name &n, - CosNaming::NamingContext_ptr nc, - CORBA::Environment &IT_env) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::InvalidName, - CosNaming::NamingContext::AlreadyBound) -{ - // Get the length of the name. - CORBA::ULong len = n.length (); - - // Check for invalid name. - if (len == 0) - throw CosNaming::NamingContext::InvalidName (); - - // If we received compound name, resolve it to get the context in - // which the binding should take place, then perform the binding on - // target context. - if (len > 1) - { - CosNaming::NamingContext_var cont = get_context (n); - CosNaming::Name simple_name; - simple_name.length (1); - simple_name[0] = n[len - 1]; - cont->bind_context (simple_name, nc); - } - - // If we received a simple name, we need to bind it in this context. - else - { - CosNaming::NameComponent comp = n[0]; - NS_IntId entry (nc, CosNaming::ncontext); - NS_ExtId name (n[0].id, n[0].kind); - - // Try binding the name. - if (context_.bind (name, entry) == 1) - throw CosNaming::NamingContext::AlreadyBound (); - // May need to add case dealing with -1. - } -} - -void -NS_NamingContext::rebind_context (const CosNaming::Name &n, - CosNaming::NamingContext_ptr nc, - CORBA::Environment &IT_env) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::InvalidName) -{ - // Get the length of the name. - CORBA::ULong len = n.length (); - - // Check for invalid name. - if (len == 0) - throw CosNaming::NamingContext::InvalidName (); - - // If we received compound name, resolve it to get the context in - // which the rebinding should take place, then perform the rebinding - // on target context. - if (len > 1) - { - CosNaming::NamingContext_var cont = get_context (n); - CosNaming::Name simple_name; - simple_name.length (1); - simple_name[0] = n[len - 1]; - cont->rebind_context (simple_name, nc); - } - - // if we received a simple name, we need to rebind it in this context. - else - { - CosNaming::NameComponent comp = n[0]; - NS_IntId entry (nc, CosNaming::ncontext); - NS_ExtId name (n[0].id, n[0].kind); - NS_IntId oldentry; - NS_ExtId oldname; - - // try rebinding the name. - if (context_.rebind (name, entry, oldname, oldentry) < 0); - // deal with consequences - } -} - -CORBA::Object_ptr -NS_NamingContext::resolve (const CosNaming::Name& n, - CORBA::Environment &IT_env) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::InvalidName) -{ - // get the length of the name - CORBA::ULong len = n.length (); - - // check for invalid name. - if (len == 0) { - throw CosNaming::NamingContext::InvalidName (); - } - - // resolve the first component of the name - NS_ExtId name (n[0].id, n[0].kind); - NS_IntId entry; - if (context_.find (name, entry) == -1) { - throw CosNaming::NamingContext::NotFound (CosNaming::NamingContext::not_object, n); - } - CORBA::Object_ptr item = entry.ref_; - - // if the name we have to resolve is a compound name - // we need to recursively resolve it. - if (len > 1) - { - CosNaming::NamingContext_var cont; - if (entry.type_ == CosNaming::ncontext) - cont = CosNaming::NamingContext::_narrow (item); - else - throw CosNaming::NamingContext::NotFound (CosNaming::NamingContext::not_context, n); - - CosNaming::Name rest_of_name; - rest_of_name.length (len - 1); - for (CORBA::ULong i = 1; i < len; i++) - rest_of_name[i-1] = n[i]; - - return (cont->resolve (rest_of_name)); - } - - // if the name we had to resolve was simple, we just need - // to return the result. - return (item->_duplicate (item)); -} - -void -NS_NamingContext::unbind (const CosNaming::Name& n, - CORBA::Environment &IT_env) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::InvalidName) -{ - // if (do_operation (n, CORBA::_nil (), NS_NamingContext::unbind) == 0) - - // get the length of the name - CORBA::ULong len = n.length (); - - // check for invalid name. - if (len == 0) - throw CosNaming::NamingContext::InvalidName (); - - // If we received compound name, resolve it to get the context in - // which the unbinding should take place, then perform the unbinding - // on target context. - if (len > 1) - { - CosNaming::NamingContext_var cont = get_context (n); - CosNaming::Name simple_name; - simple_name.length (1); - simple_name[0] = n[len - 1]; - cont->unbind (simple_name); - } - - // If we received a simple name, we need to unbind it in this - // context. - { - NS_ExtId name (n[0].id, n[0].kind); - // try unbinding the name. - if (context_.unbind (name) == -1) - throw CosNaming::NamingContext::NotFound (CosNaming::NamingContext::not_object, n); - } -} - -CosNaming::NamingContext_ptr -NS_NamingContext::new_context (CORBA::Environment &IT_env) - throw (CORBA::SystemException) -{ - NS_NamingContext *c = new NS_NamingContext; - CosNaming::NamingContext_ptr cont - = new TIE_CosNaming_NamingContext (NS_NamingContext) (c); - - c->initialize (cont); - - return cont->_duplicate (cont); -} - -CosNaming::NamingContext_ptr -NS_NamingContext::bind_new_context (const CosNaming::Name& n, - CORBA::Environment &IT_env) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::AlreadyBound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::InvalidName) -{ - NS_NamingContext *c = new NS_NamingContext; - CosNaming::NamingContext_ptr cont = - new TIE_CosNaming_NamingContext (NS_NamingContext) (c); - - c->initialize (cont); - - try - { - bind_context (n, cont); - } - catch (CosNaming::NamingContext::NotFound &nf) - { - CORBA::release (cont); - throw CosNaming::NamingContext::NotFound (nf); - } - catch (CosNaming::NamingContext::CannotProceed &cp) - { - CORBA::release (cont); - throw CosNaming::NamingContext::CannotProceed (cp); - } - catch (CosNaming::NamingContext::InvalidName) - { - CORBA::release (cont); - throw CosNaming::NamingContext::InvalidName (); - } - catch (CosNaming::NamingContext::AlreadyBound) - { - CORBA::release (cont); - throw CosNaming::NamingContext::AlreadyBound (); - } - - return cont->_duplicate (cont); -} - -void -NS_NamingContext::destroy (CORBA::Environment &IT_env) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotEmpty) -{ - if (context_.current_size () != 0) - throw CosNaming::NamingContext::NotEmpty (); - - // destroy context - CORBA::release (tie_ref_); -} - -void -NS_NamingContext::list (CORBA::ULong how_many, - CosNaming::BindingList *&bl, - CosNaming::BindingIterator_ptr &bi, - CORBA::Environment &IT_env) - throw (CORBA::SystemException) -{ - // Dynamically allocate hash map iterator. - NS_NamingContext::HASH_MAP::ITERATOR *hash_iter = - new NS_NamingContext::HASH_MAP::ITERATOR (context_); - - // Number of bindings that will go into the BindingList. - CORBA::ULong n; - - if (context_.current_size () > how_many) - // number of bindings in the context is > <how_many> - // so need to return a BindingIterator. - { - NS_BindingIterator *bind_iter = new NS_BindingIterator (hash_iter); - - bind_iter->initialize (bi); - bi->_duplicate (bi); - - n = how_many; - } - else - { - // Number of bindings in the context is <= <how_many>, - // so do not need to return a BindingIterator. - bi = CosNaming::BindingIterator::_nil (); - n = context_.current_size (); - } - - // use hash iterator to populate a BindingList with - // bindings. - CosNaming::BindingList bindings; - bindings.length (n); - NS_NamingContext::HASH_MAP::ENTRY *hash_entry; - - for (CORBA::ULong i = 0; i < n; i++) - { - hash_iter->next (hash_entry); - hash_iter->advance (); - - bindings[i].binding_type = hash_entry->int_id_.type_; - - bindings[i].binding_name.length (1); - bindings[i].binding_name[0].id = - CORBA::string_dup (hash_entry->ext_id_.id_.fast_rep ()); - bindings[i].binding_name[0].kind = - CORBA::string_dup (hash_entry->ext_id_.kind_.fast_rep ()); - } - // Marina, please add check for memory failure. - bl = new CosNaming::BindingList (bindings); - - // If did not allocate BindingIterator, deallocate hash map - // iterator. - if (context_.current_size () <= how_many) - delete hash_iter; -} - -NS_BindingIterator::NS_BindingIterator (NS_NamingContext::HASH_MAP::ITERATOR *hash_iter) -{ - hash_iter_ = hash_iter; -} - -NS_BindingIterator::~NS_BindingIterator (void) -{ - delete hash_iter_; -} - -void -NS_BindingIterator::initialize (CosNaming::BindingIterator_ptr tie_ref) -{ - tie_ref_ = tie_ref; -} - -CORBA::Boolean -NS_BindingIterator::next_one (CosNaming::Binding*& b, - CORBA::Environment &IT_env) - throw (CORBA::SystemException) -{ - if (hash_iter_->done ()) { - b = new CosNaming::Binding; - return 0; - } - else - { - b = new CosNaming::Binding; - - NS_NamingContext::HASH_MAP::ENTRY *hash_entry; - hash_iter_->next (hash_entry); - hash_iter_->advance (); - - b->binding_type = hash_entry->int_id_.type_; - - b->binding_name.length (1); - b->binding_name[0].id = - CORBA::string_dup (hash_entry->ext_id_.id_.fast_rep ()); - b->binding_name[0].kind = - CORBA::string_dup (hash_entry->ext_id_.kind_.fast_rep ()); - - return 1; - } -} - -CORBA::Boolean -NS_BindingIterator::next_n (CORBA::ULong how_many, - CosNaming::BindingList *&bl, - CORBA::Environment &IT_env) - throw (CORBA::SystemException) -{ - if (hash_iter_->done ()) { - bl = new CosNaming::BindingList; - return 0; - } - else - { - // Statically allocate a BindingList. - CosNaming::BindingList bindings; - - // Initially assume that iterator has the requested number of - // bindings. - bindings.length (how_many); - - // Iterate and populate the BindingList. - NS_NamingContext::HASH_MAP::ENTRY *hash_entry; - for (CORBA::ULong i = 0; i < how_many; i++) - { - hash_iter_->next (hash_entry); - - bindings[i].binding_type = hash_entry->int_id_.type_; - - bindings[i].binding_name.length (1); - bindings[i].binding_name[0].id = - CORBA::string_dup (hash_entry->ext_id_.id_.fast_rep ()); - bindings[i].binding_name[0].kind = - CORBA::string_dup (hash_entry->ext_id_.kind_.fast_rep ()); - - if (hash_iter_->advance () == 0) - { - // If no more bindings left, reset length to the actual - // number of bindings populated and get out of the loop. - bindings.length (i + 1); - break; - } - } - - bl = new CosNaming::BindingList (bindings); - // Marina, please check for failed memory allocation. - return 1; - } -} - -void -NS_BindingIterator::destroy (CORBA::Environment &IT_env) - throw (CORBA::SystemException) -{ - CORBA::release (tie_ref_); -} - - diff --git a/TAO/ORB_Services/Naming_Service/NS_CosNaming.h b/TAO/ORB_Services/Naming_Service/NS_CosNaming.h deleted file mode 100644 index c347854ef8f..00000000000 --- a/TAO/ORB_Services/Naming_Service/NS_CosNaming.h +++ /dev/null @@ -1,278 +0,0 @@ -/* -*- C++ -*- */ - -// ============================================================================ -// -// = LIBRARY -// cos -// -// = FILENAME -// NS_CosNaming.h -// -// = AUTHOR -// Marina Spivak <marina@cs.wustl.edu> -// -// ============================================================================ - -#if !defined (NS_COSNAMING_H) -#define NS_COSNAMING_H - -#include "CosNaming.hh" -#include "ace/Hash_Map_Manager.h" -#include "ace/Synch.h" -#include "ace/SString.h" - -class NS_IntId - // = TITLE - // Stores information a context keeps for each bound name - // (object reference and the type of binding). - // - // = DESCRIPTION - // - // - // - // -{ -public: - // = Initialization and termination methods. - NS_IntId (void); - // default constructor. - - NS_IntId (CORBA::Object_ptr obj, - CosNaming::BindingType type = CosNaming::nobject); - // constructor. - - NS_IntId (const NS_IntId & rhs); - // copy constructor - - ~NS_IntId (void); - // destructor - - void operator= (const NS_IntId & rhs); - // Assignment operator (does copy memory). - - CORBA::Object_ptr ref_; - // CORBA object reference of the bound object. - - CosNaming::BindingType type_; - // Indicator of whether the object is a NamingContext that should - // participate in name resolution when compound names are used. -}; - -class NS_ExtId - // = TITLE - // Stores the name to which an object is bound. - // - // = DESCRIPTION - // - // - // - // -{ -public: - // = Initialization and termination methods. - NS_ExtId (void); - // default constructor. - - NS_ExtId (const char *id, - const char *kind); - // constructor. - - NS_ExtId (const NS_ExtId & rhs); - // copy constructor - - ~NS_ExtId (void); - // destructor - - void operator= (const NS_ExtId & rhs); - // Assignment operator (does copy memory). - - int operator== (const NS_ExtId &rhs) const; - // Equality comparison operator (must match both id_ and kind_). - - int operator!= (const NS_ExtId &rhs) const; - // Inequality comparison operator. - - u_long hash (void) const; - // This class has to have a hash for use with ACE_Hash_Map_Manager. - - ACE_CString kind_; - // any information user wants to store (not used by Naming Service). - - ACE_CString id_; - // any information user wants to store (not used by Naming Service). -}; - -class NS_NamingContext - // = TITLE - // This class implements the NamingContext interface that is part of the - // CosNaming idl module. - // - // = DESCRIPTION - // Extensive comments can be found in the idl file. -{ -public: - - enum - { - NS_MAP_SIZE = 23 - // The size of hash map for a NS_NamingContext object. - }; - - typedef ACE_Hash_Map_Manager<NS_ExtId, NS_IntId, ACE_Null_Mutex> HASH_MAP; - - NS_NamingContext (void); - // default constructor. - - ~NS_NamingContext (void); - // destructor. - - void bind (const CosNaming::Name &n, - CORBA::Object_ptr obj, - CORBA::Environment &IT_env = CORBA::default_environment) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::InvalidName, - CosNaming::NamingContext::AlreadyBound); - - void rebind (const CosNaming::Name &n, - CORBA::Object_ptr obj, - CORBA::Environment &IT_env = CORBA::default_environment) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::InvalidName); - - void bind_context (const CosNaming::Name &n, - CosNaming::NamingContext_ptr nc, - CORBA::Environment &IT_env = CORBA::default_environment) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::InvalidName, - CosNaming::NamingContext::AlreadyBound); - - void rebind_context (const CosNaming::Name &n, - CosNaming::NamingContext_ptr nc, - CORBA::Environment &IT_env = CORBA::default_environment) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::InvalidName); - - CORBA::Object_ptr resolve (const CosNaming::Name &n, - CORBA::Environment &IT_env = CORBA::default_environment) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::InvalidName); - - void unbind (const CosNaming::Name &n, - CORBA::Environment &IT_env = CORBA::default_environment) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::InvalidName); - - CosNaming::NamingContext_ptr new_context (CORBA::Environment &IT_env = CORBA::default_environment) - throw (CORBA::SystemException); - - CosNaming::NamingContext_ptr bind_new_context (const CosNaming::Name &n, - CORBA::Environment &IT_env = CORBA::default_environment) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::AlreadyBound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::InvalidName); - - void destroy (CORBA::Environment &IT_env = CORBA::default_environment) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotEmpty); - - void list (CORBA::ULong how_many, - CosNaming::BindingList *&bl, - CosNaming::BindingIterator_ptr &bi, - CORBA::Environment &IT_env = CORBA::default_environment) - throw (CORBA::SystemException); - - - void initialize (CosNaming::NamingContext_ptr tie_ref); - // This method is called after context constructor. It provides the - // implementation object with the reference to its TIE object. (This - // is needed for implementation of destroy method) - -protected: - // = These are the helper methods used by other methods. - - CosNaming::NamingContext_ptr get_context (const CosNaming::Name &name) - throw (CORBA::SystemException, - CosNaming::NamingContext::NotFound, - CosNaming::NamingContext::CannotProceed, - CosNaming::NamingContext::AlreadyBound); - // This is used by methods that need to resolve a compound name to - // get the reference to the target context before performing the - // actual operation (e.g. bind, unbind, etc.) Takes a full name - // (including the last component that doesn't need to be resolved) - // Returns a pointer to the target context. - -private: - - HASH_MAP context_; - // This implementation of NamingContext uses ACE thread-safe Hash - // Map for storage and manipulation of name-object bindings. - - CosNaming::NamingContext_ptr tie_ref_; - // Stores CORBA object reference to the TIE object this object - // implements. This is needed to implement the <destroy> method. -}; - -class NS_BindingIterator - // = TITLE - // This class implements the BindingIterator interface - // that is part of the CosNaming idl module. - // - // = DESCRIPTION - // NS_BindingIterator constructor expects a pointer to a - // DYNAMICALLY allocated hash map iterator. Destructor - // deallocates hash map iterator. -{ -public: - // = Intialization and termination methods. - NS_BindingIterator (NS_NamingContext::HASH_MAP::ITERATOR *hash_iter); - // constructor. - - ~NS_BindingIterator (void); - // destructor. - - void initialize (CosNaming::BindingIterator_ptr tie_ref); - // This method is called after the constructor. It provides - // implementation object with the reference to the TIE object it - // implements. - - // Marina, please add comments. - CORBA::Boolean next_one (CosNaming::Binding *&b, - CORBA::Environment &IT_env = CORBA::default_environment) - throw (CORBA::SystemException); - - CORBA::Boolean next_n (CORBA::ULong how_many, - CosNaming::BindingList *&bl, - CORBA::Environment &IT_env = CORBA::default_environment) - throw (CORBA::SystemException); - - - void destroy (CORBA::Environment &IT_env = CORBA::default_environment) - throw (CORBA::SystemException); - -private: - NS_NamingContext::HASH_MAP::ITERATOR *hash_iter_; - // A pointer to the hash map iterator. - - CosNaming::BindingIterator_ptr tie_ref_; - // A reference to the TIE object this object implements. this is - // used for implementation of <destroy>. -}; - -DEF_TIE_CosNaming_NamingContext (NS_NamingContext) -DEF_TIE_CosNaming_BindingIterator (NS_BindingIterator) - -#endif /* NS_COSNAMING_H */ |