// **********************************************************************
//
// Copyright (c) 1999
// Object Oriented Concepts, Inc.
// Billerica, MA, USA
//
// All Rights Reserved
//
// **********************************************************************

#ifndef OB_NAMING_IDL
#define OB_NAMING_IDL

#include <CosNaming.idl>

//
// The OOC Extended NamingService
//
#pragma prefix "ooc.com"

module CosNaming
{

/**********************************************************************
 *
 * An interface for forwarding changes in bindings to
 * BindingListener clients.
 *
 * @version 1.1
 * @author Uwe Seimet
 *
 **********************************************************************/

interface BindingListener
{
    /**
     *
     * A context binding was added.
     *
     * @param parent_ctx The naming context the binding was added to.
     * @param child_ctx The new context.
     * @param name The new context's name.
     *
     **/
    oneway void context_added(in NamingContext parent_ctx,
			      in NamingContext child_ctx,
			      in NameComponent name);

    /**
     *
     * A context binding was removed.
     *
     * @param parent_ctx The naming context the binding was removed from.
     * @param name The context's name.
     *
     **/
    oneway void context_removed(in NamingContext parent_ctx,
				in NameComponent name);

    /**
     *
     * A context binding has changed.
     *
     * @param parent_ctx The parent of the naming context that was changed.
     * @param child_ctx The context that was changed.
     * @param old_name The context's old name.
     * @param new_name The context's new name.
     *
     **/
    oneway void context_changed(in NamingContext parent_ctx,
				in NamingContext child_ctx,
				in NameComponent old_name,
				in NameComponent new_name);

    /**
     *
     * An object binding was added.
     *
     * @param parent_ctx The naming context the binding was added to.
     * @param child_ctx The new object.
     * @param name The object's name.
     *
     **/
    oneway void object_added(in NamingContext parent_ctx,
			     in Object child_obj,
			     in NameComponent name);

    /**
     *
     * An object binding was removed.
     *
     * @param parent_ctx The naming context the binding was removed from.
     * @param name The object's name.
     *
     **/
    oneway void object_removed(in NamingContext parent_ctx,
			       in NameComponent name);

    /**
     *
     * An object binding was changed.
     *
     * @param parent_ctx The naming context the binding is contained in.
     * @param child The object that was changed.
     * @param old_name The object's old name.
     * @param new_name The object's new name.
     *
     **/
    oneway void object_changed(in NamingContext parent_ctx,
			       in Object child,
			       in NameComponent old_name,
			       in NameComponent new_name);
}; // End interface BindingListener

/**********************************************************************
 *
 * An interface providing extensions to the standard CORBA naming
 * context interface. An extended naming context propagates changes
 * to a list of ContextListeners.
 *
 * @version 1.2
 * @author Uwe Seimet
 *
 **********************************************************************/

interface OBNamingContext : NamingContextExt
{
    union NcOrObj switch(BindingType)
    {
    case ncontext: CosNaming::NamingContext nc;
    case nobject: Object obj;
    };

    /**
     *
     * Extended binding with additional information
     *
     * @member binding_name The standard binding name.
     * @member ncOrObj The bound object.
     * @member timestamp Time of last modification in seconds.
     *
     **/
    struct ExtendedBinding
    {
	Name binding_name;
	NcOrObj ncOrObj;
	long timestamp;
    };

    /**
     *
     * A sequence of extended bindings.
     *
     **/
    typedef sequence<ExtendedBinding> ExtendedBindingList;

    /**
     *
     * Lists all extended bindings
     *
     * @return The list with all extended bindings for this context.
     *
     **/
    ExtendedBindingList list_extended();

    /**
     *
     * Rename context or objext.
     *
     * @param old_name The object's old name.
     * @param new_name The object's new name.
     * 
     **/
    void rename(in Name old_name, in Name new_name)
        raises(NamingContext::NotFound, NamingContext::AlreadyBound,
	       NamingContext::CannotProceed, NamingContext::InvalidName);

    /**
     *
     * Add listener
     *
     * @param listener A new listener to report changes to.
     *
     **/
    boolean add_listener(in BindingListener listener);

    /**
     *
     * Remove listener
     *
     * @param listener The listener to be removed.
     *
     **/
    boolean remove_listener(in BindingListener listener);

    /**
     *
     * Returns information on the callback mechanism status.
     *
     * @return True, if the callback mechanism is active, i. e.
     * if listeners are actually called back when a change occurs.
     *
     **/
    boolean callbacks_active();

}; // End interface OBNamingContext

}; // End module CosNaming

#endif
