//
//   COMPONENT_NAME: somnm
//
//   ORIGINS: 27
//
//
//    25H7912  (C)  COPYRIGHT International Business Machines Corp. 1992,1996,1996
//   All Rights Reserved
//   Licensed Materials - Property of IBM
//   US Government Users Restricted Rights - Use, duplication or
//   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//
//#  @(#) 1.8 src/somnm/naming/naming.idl, somnm, som3.0 12/15/96 18:01:04 [12/22/96 21:32:10]


#ifndef naming_idl
#define naming_idl


#include <somobj.idl>


module CosNaming {


        typedef string Istring;
        struct NameComponent {
                Istring id;
                Istring kind;
        };
        typedef sequence <NameComponent> Name;
        enum BindingType {nobject, ncontext};
        struct Binding {
                Name binding_name;
                BindingType binding_type;
        };
        typedef sequence <Binding> BindingList;


        interface BindingIterator : SOMObject {

                boolean next_one(out Binding b);
                // returns the next binding. FALSE is returned if
                // there are no more bindings

                boolean next_n(in unsigned long how_many,
                                out BindingList bl);
                // returns at most the "how_many" number of bindings.
                // Returns FALSE if there are no more bindings

                void destroy();
                // destroys the iterator


                #ifdef __SOMIDL__
                implementation {
                        functionprefix=BI_;
                        releaseorder: next_one, next_n, destroy;
                        dllname = "somnmf.dll";
                        majorversion = 3;
                        minorversion = 0;
                };
                #endif
        };

        interface NamingContext : SOMObject {

                enum NotFoundReason {missing_node, not_context, not_object};

                exception NotFound {
                        NotFoundReason why;
                        Name rest_of_name;
                };

                exception CannotProceed {
                        NamingContext cxt;
                        Name rest_of_name;
                };

                exception InvalidName {
                        Name name;
                };
                exception AlreadyBound { };
                exception NotEmpty { };

                void bind(in Name n, in SOMObject obj)
                        raises(NotFound, CannotProceed,
                                InvalidName, AlreadyBound);
                // creates a binding of a name and an object in
                // the target naming context. Naming Contexts that are
                // bound using bind do not participate in name resolution
                // when compound name resolution is done

                void rebind(in Name n, in SOMObject obj)
                        raises(NotFound, CannotProceed, InvalidName);
                // creates a binding of the name and an object even if
                // the name is already bound in the context. Naming
                // contexts that are bound using rebind do not participate
                // in name resolution process when compound names are
                // passed to be resolved.

                void bind_context(in Name n, in NamingContext nc)
                        raises(NotFound, CannotProceed,
                                InvalidName, AlreadyBound);
                // binds a naming context to the name. Naming contexts
                // that are bound using bind_context participate in
                // name resolution when compound names are resolved

                void rebind_context(in Name n, in NamingContext nc)
                        raises(NotFound, CannotProceed, InvalidName);
                // creates a binding between a name and a naming context
                // in the target naming context even if the name is
                // already bound in the context. Naming contexts that
                // are bound using rebind_context participate in name
                // resolution when compound names are resolved

                SOMObject resolve(in Name n)
                        raises(NotFound, CannotProceed, InvalidName);
                //retrieves an object bound to a name in the context
                // Since names can be compound, name resolution can
                // traverse multiple naming contexts

                void unbind(in Name n)
                        raises(NotFound, CannotProceed, InvalidName);
                // removes a name binding from a context

                NamingContext new_context();
                // Returns a new naming context in the same process as
                // the context on which the operation was invoked
                // The new context is not bound to any name

                NamingContext bind_new_context(in Name n)
                        raises(NotFound, CannotProceed,
                                InvalidName, AlreadyBound);
                // Creates a name naming context and binds it to the name
                // supplied as the argument.
                // The naming context is created in the same process as
                // the context on which the bind_new_context was invoked

                void destroy()
                        raises(NotEmpty);
                // destroys the naming context. If the naming context has
                // bindings, a NotEmpty exception is raised. It is the
                // responsibilty of the caller to make sure that there
                // are no refernces to this naming context.

                void list(in unsigned long how_many, out BindingList bl,
                        out BindingIterator bi);
                // returns at most "how_many" number of bindings in bl.
                // If the naming context contains additional bindings, a
                // BindingIterator is returned. If the naming context
                // does not contain additional bindings, the binding
                // iterator is a "nil" object reference


                #ifdef __SOMIDL__
                implementation {
                        functionprefix=NC_;
                        releaseorder: bind, rebind, bind_context,
                                rebind_context, resolve, unbind,
                                new_context,bind_new_context,destroy,list,
                                        resolvex;

                        dllname = "somnmf.dll";
                        majorversion = 3;
                        minorversion = 0;
                        somDefaultInit: override, init;
                        somDestruct: override;
                };
                #endif
        };


}; /* end module CosNaming */

#endif /* ifndef  */
