// This file contains OMG IDL and PIDL for the Common Object Services.
// CosNaming Module, p 3-6 CORBAservices, Naming Service V1.0, 3/94

// A few minor changes for the JacORB distribution:
//
// added am enclosing COSS module and changed scoped names accordingly
//
// corrected a few syntax errors
//
// commented out:
//	#includes
//	forward declaration of Object

#include "Corba.idl"

module COSS {

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;

        interface NamingContext {

                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{};                                                                        
                exception AlreadyBound {};
                exception NotEmpty{};

                void bind(in Name n, in Object obj)             
                         raises(NotFound, CannotProceed, InvalidName, AlreadyBound);
                void rebind(in Name n, in Object obj)   
                         raises(NotFound, CannotProceed, InvalidName);
                void bind_context(in Name n, in NamingContext nc)               
                         raises(NotFound, CannotProceed, InvalidName, AlreadyBound);
                void rebind_context(in Name n, in NamingContext nc)     
                         raises(NotFound, CannotProceed, InvalidName);
                Object resolve (in Name n)
                         raises(NotFound, CannotProceed, InvalidName);
                void unbind(in Name n)
                         raises(NotFound, CannotProceed, InvalidName);
                NamingContext new_context();
                NamingContext bind_new_context(in Name n)
                         raises(NotFound, AlreadyBound, CannotProceed, InvalidName);
                void destroy( )
                         raises(NotEmpty);
                void list (in unsigned long how_many, 
                                        out BindingList bl, out BindingIterator bi);
        };

        interface BindingIterator {
                boolean next_one(out Binding b);
                boolean next_n(in unsigned long how_many, 
                                        out BindingList bl);
                void destroy();
        };
};

// Names Library interface in PIDL,   CORBAservices p 3- 14, Naming Service V1.0 3/94 
/*
interface LNameComponent {                                                              // PIDL
        exception NotSet{};
        string get_id() 
                raises(NotSet);
        void set_id(in string i);
        string get_kind() 
                raises(NotSet);
        void set_kind(in string k);
        void destroy();
};

interface LName {                                                                                               // PIDL
        exception NoComponent{};
        exception OverFlow{};
        exception InvalidName{};                                
        LName insert_component(in unsigned long i, 
                                        in LNameComponent n) 
                        raises(NoComponent, OverFlow);
        LNameComponent get_component(in unsigned long i)
                 raises(NoComponent);                           
        LNameComponent delete_component(in unsigned long i)
                 raises(NoComponent);                           
        unsigned long num_components();
        boolean equal(in LName ln);
        boolean less_than(in LName ln);
        Name to_idl_form()
                        raises(InvalidName);                             
        void from_idl_form(in Name n);
        void destroy();
};

LName create_lname();                      // C/C++
LNameComponent create_lname_component();   // C/C++
*/

// CosEventComm Module, CORBAservices p 4-8, Event Service V1.0 3/94

module CosEventComm {

        exception Disconnected{};

        interface PushConsumer {
                void push (in any data) raises(Disconnected);
                void disconnect_push_consumer(); 
        };

    interface PushSupplier {
                void disconnect_push_supplier();
        };

        interface PullSupplier {
                any pull () raises(Disconnected);
                any try_pull (out boolean has_event) 
                        raises(Disconnected);
                void     disconnect_pull_supplier(); 
        };

        interface PullConsumer {
                void disconnect_pull_consumer();
        };

};

// CosEventChannelAdmin Module, p 4-15 CORBAservices, Event
// Service V1.0, 3/94

// #include "CosEventComm.idl"

module CosEventChannelAdmin {

        exception AlreadyConnected {};
        exception TypeError {};

        interface ProxyPushConsumer: ::COSS::CosEventComm::PushConsumer {
                void connect_push_supplier(
                                in ::COSS::CosEventComm::PushSupplier push_supplier)
                        raises(AlreadyConnected);
        };

        interface ProxyPullSupplier: ::COSS::CosEventComm::PullSupplier {
                void connect_pull_consumer(
                                in ::COSS::CosEventComm::PullConsumer pull_consumer)
                        raises(AlreadyConnected);
        };

        interface ProxyPullConsumer: ::COSS::CosEventComm::PullConsumer {
                void connect_pull_supplier(
                                in ::COSS::CosEventComm::PullSupplier pull_supplier)
                        raises(AlreadyConnected,TypeError);
        };

        interface ProxyPushSupplier: ::COSS::CosEventComm::PushSupplier {
	  void connect_push_consumer(
				     in ::COSS::CosEventComm::PushConsumer 
				     push_consumer)
	    raises(AlreadyConnected, TypeError);
        };

	
        interface ConsumerAdmin {
	  ProxyPushSupplier obtain_push_supplier();
	  ProxyPullSupplier obtain_pull_supplier();
        };

        interface SupplierAdmin {
                ProxyPushConsumer obtain_push_consumer();
                ProxyPullConsumer obtain_pull_consumer();
        };

        interface EventChannel {
                ConsumerAdmin for_consumers();
                SupplierAdmin for_suppliers();
                void destroy();
        };

};


// CosTyped Event Module, p 4-22 CORBAservices, Event Service
// V1.0, 3/94

// // #include "CosEventComm.idl" 

module CosTypedEventComm {

        interface TypedPushConsumer : ::COSS::CosEventComm::PushConsumer {
                Object get_typed_consumer(); 
        };

        interface TypedPullSupplier : ::COSS::CosEventComm::PullSupplier {               
                Object get_typed_supplier();
        };

}; 

// CosTypedEventChannelAdmin Module, p 4- 25 CORBAservices,
// Event Service V1.0, 3/94

// // #include "CosEventChannel.idl" 
// // #include "CosTypedEventComm.idl"
module CosTypedEventChannelAdmin {       
        exception InterfaceNotSupported {}; 
        exception NoSuchImplementation {}; 
        typedef string Key; 

        interface TypedProxyPushConsumer :      
                        ::COSS::CosEventChannelAdmin::ProxyPushConsumer,        
                        ::COSS::CosTypedEventComm::TypedPushConsumer  { }; 

        interface TypedProxyPullSupplier :
                        ::COSS::CosEventChannelAdmin::ProxyPullSupplier,        
                        ::COSS::CosTypedEventComm::TypedPullSupplier { }; 

        interface TypedSupplierAdmin :                  
                        ::COSS::CosEventChannelAdmin::SupplierAdmin { 
                TypedProxyPushConsumer obtain_typed_push_consumer(
                                in Key supported_interface)                 
                        raises(InterfaceNotSupported); 
                ::COSS::CosEventChannelAdmin::ProxyPullConsumer obtain_typed_pull_consumer ( 
                                in Key uses_interface)             
                         raises(NoSuchImplementation); 
        }; 

        interface TypedConsumerAdmin : 
                        ::COSS::CosEventChannelAdmin::ConsumerAdmin { 
                TypedProxyPullSupplier obtain_typed_pull_supplier( 
                                in Key supported_interface)                 
                        raises (InterfaceNotSupported); 
                ::COSS::CosEventChannelAdmin::ProxyPushSupplier obtain_typed_push_supplier(                   
                                in Key uses_interface)              
                        raises(NoSuchImplementation); 
        }; 

        interface TypedEventChannel { 
                TypedConsumerAdmin for_consumers();             
                TypedSupplierAdmin for_suppliers();                
                void destroy (); 
        }; 
};


// CosPersistencePID Module, p 5-20 CORBAservices, 
// Persistent Object Service V1.0, 3/94

//#ifndef __COSPERSISTENCE
//#define __COSPERSISTENCE

module CosPersistencePID {

        interface PID {
                attribute string datastore_type;
                string get_PIDString();
        };
};


// CosPersistencePDS Module, p 5-20 CORBAservices, 
// Persistent Object Service V1.0, 3/94

// #include "CosPersistencePID.idl"

module CosPersistencePDS {

// interface Object;
        interface PDS {
                PDS     connect (in Object obj, 
                        in ::COSS::CosPersistencePID::PID p);
                void disconnect (in Object obj, 
                        in ::COSS::CosPersistencePID::PID p);
                void store (in Object obj, 
                        in ::COSS::CosPersistencePID::PID p);
                void restore (in Object obj, 
                        in ::COSS::CosPersistencePID::PID p);
                void delete (in Object obj, 
                        in ::COSS::CosPersistencePID::PID p);
        };
};


// CosPersistencePO Module, p 5-12 CORBAservices,
// Persistent Object Service V1.0, 3/94

// // #include "CosPersistencePDS.idl"
// CosPersistencePDS.idl 
// // #includes CosPersistencePID.idl

module CosPersistencePO {

        interface PO {
                attribute ::COSS::CosPersistencePID::PID p;
                ::COSS::CosPersistencePDS::PDS connect (
                        in ::COSS::CosPersistencePID::PID p);
                void disconnect (in ::COSS::CosPersistencePID::PID p);
                void store (in ::COSS::CosPersistencePID::PID p);
                void restore (in ::COSS::CosPersistencePID::PID p);
                void delete (in ::COSS::CosPersistencePID::PID p);
        };

        interface SD {
                void pre_store();
                void post_restore();
        };
};


// CosPersistencePOM Module, p 5-15 CORBAservices,
// Persistent Object Service V1.0, 3/94

// #include "CosPersistencePDS.idl"

// CosPersistencePDS.idl // #includes CosPersistencePID.idl

module CosPersistencePOM {

// interface Object;        

	interface POM {
                ::COSS::CosPersistencePDS::PDS connect (
                        in Object obj, 
                        in ::COSS::CosPersistencePID::PID p);
                void disconnect (
                        in Object obj, 
                        in ::COSS::CosPersistencePID::PID p);
                void store (
                        in Object obj, 
                        in ::COSS::CosPersistencePID::PID p);
                void restore (
                        in Object obj, 
                        in ::COSS::CosPersistencePID::PID p);
                void delete (
                        in Object obj, 
                        in ::COSS::CosPersistencePID::PID p);
 	       };
	};

// CosPersistencePDS_DA Module, p 5-22 CORBAservices,
// Persistent Object Service, V1.0, 3/94

// #include "CosPersistencePDS.idl"
// CosPersistencePDS.idl // #includes CosPersistencePID.idl

module CosPersistencePDS_DA {

        typedef string DAObjectID;

        interface PID_DA : ::COSS::CosPersistencePID::PID {
                attribute DAObjectID oid;
        };
        
        interface DAObject {
                boolean dado_same(in DAObject d);
                DAObjectID dado_oid();
                PID_DA dado_pid();
                void dado_remove();
                void dado_free();
        };

        interface DAObjectFactory {
                DAObject create();
        };

        interface DAObjectFactoryFinder {
                DAObjectFactory find_factory(in string key);
        };

        interface PDS_DA : ::COSS::CosPersistencePDS::PDS {
                DAObject get_data();
                void set_data(in DAObject new_data);
                DAObject lookup(in DAObjectID id);
                PID_DA get_pid();
                PID_DA get_object_pid(in DAObject dao);
                DAObjectFactoryFinder data_factories();
        };

        typedef sequence<string> AttributeNames;
        interface DynamicAttributeAccess {
                AttributeNames attribute_names();
                any attribute_get(in string name);
                void attribute_set(in string name, in any value);
        };

        typedef string ClusterID;
        typedef sequence<ClusterID> ClusterIDs;
        interface PDS_ClusteredDA : PDS_DA{
                ClusterID cluster_id();
                string cluster_kind();
                ClusterIDs clusters_of();
                PDS_ClusteredDA create_cluster(in string kind);
                PDS_ClusteredDA open_cluster(in ClusterID cluster);
                PDS_ClusteredDA copy_cluster(
                        in PDS_DA source);
        };
};

// CosPersistenceDDO Module, p 5-32 CORBAservices, Persistent Object Service V1.0, 3/94

// #include "CosPersistencePID.idl"
module CosPersistenceDDO {

        interface DDO {
                attribute string object_type;
                attribute ::COSS::CosPersistencePID::PID p;
                short add_data();
                short add_data_property (in short data_id);
                short get_data_count();
                short get_data_property_count (in short data_id);
                void get_data_property (in short data_id,
                        in short property_id,
                        out string property_name,
                        out any property_value);
                void set_data_property (in short data_id,
                        in short property_id,
                        in string property_name,
                        in any property_value);
                void get_data (in short data_id,
                        out string data_name,
                        out any data_value);
                void set_data (in short data_id,
                        in string data_name,
                        in any data_value);
        };
};

// CosPersistenceDS_CLI module, p 5-34 CORBAservices,
// Persistent Object Service V1.0, 3/94

// #include "CosPersistenceDDO.idl"
// CosPersistenceDDO.idl // #includes CosPersistencePID.idl

module CosPersistenceDS_CLI {
        interface UserEnvironment {
                void set_option (in long option,in any value);
                void get_option (in long option,out any value);
                void release();
        };

        interface Connection {
                void set_option (in long option,in any value);
                void get_option (in long option,out any value);
        };

        interface ConnectionFactory {
                Connection create_object (
                        in UserEnvironment user_envir);
        };

        interface Cursor { 
                void set_position (in long position,in any value);
                ::COSS::CosPersistenceDDO::DDO fetch_object();
        };

        interface CursorFactory {
                Cursor create_object (
                        in Connection connection);
        };

        interface PID_CLI : ::COSS::CosPersistencePID::PID {
                attribute string datastore_id;
                attribute string id;
        };



        interface Datastore_CLI {
                void connect (in Connection connection,
                        in string datastore_id,
                        in string user_name,
                        in string authentication);
                void disconnect (in Connection connection);
                Connection get_connection (
                        in string datastore_id,
                        in string user_name);
                void add_object (in Connection connection,
                        in ::COSS::CosPersistenceDDO::DDO data_obj);
                void delete_object (
                        in Connection connection,
                        in ::COSS::CosPersistenceDDO::DDO data_obj);
                void update_object (
                        in Connection connection,
                        in ::COSS::CosPersistenceDDO::DDO data_obj);
                void retrieve_object(
                        in Connection connection,
                        in ::COSS::CosPersistenceDDO::DDO data_obj);
                Cursor select_object(
                        in Connection connection,
                        in string key);
                void transact (in UserEnvironment user_envir,
                        in short completion_type);
                void assign_PID (in PID_CLI p);
                void assign_PID_relative (
                        in PID_CLI source_pid,
                        in PID_CLI target_pid);
                boolean is_identical_PID (
                        in PID_CLI pid_1,
                        in PID_CLI pid_2);
                string get_object_type (in PID_CLI p);
                void register_mapping_schema (in string schema_file); 
                Cursor execute (in Connection connection,
                        in string command); 
        };

};


// CosLifeCycle Module, p 6-10 CORBAservices, LifeCycle Service V1.0, 3/94

// #include "Naming.idl"

module CosLifeCycle 
{
        typedef ::COSS::CosNaming::Name Key; 
        typedef Object Factory;
        typedef sequence <Factory> Factories;
        typedef struct NVP {     
                ::COSS::CosNaming::Istring  name; 
                any     value; 
        } NameValuePair;
        typedef sequence <NameValuePair> Criteria;

        exception NoFactory {
                Key search_key;
        };
        exception NotCopyable { string reason; };
        exception NotMovable { string reason; };
        exception NotRemovable { string reason; };
        exception InvalidCriteria{ 
                Criteria invalid_criteria;
        };
        exception CannotMeetCriteria {
                Criteria unmet_criteria;
        };


        interface FactoryFinder {
                Factories find_factories(in Key factory_key)
                        raises(NoFactory);
        };

        interface LifeCycleObject {
                LifeCycleObject copy(in FactoryFinder there, 
                                in Criteria the_criteria)
                        raises(NoFactory, NotCopyable, InvalidCriteria,
                                 CannotMeetCriteria);
                void move(in FactoryFinder there, 
                                in Criteria the_criteria)
                        raises(NoFactory, NotMovable, InvalidCriteria,
                                 CannotMeetCriteria);
                void remove()
                        raises(NotRemovable);
        };

        interface GenericFactory {              
                boolean supports(in Key k);
                Object create_object(                   
                                in Key k, 
                                in Criteria the_criteria)                          
                        raises (NoFactory, InvalidCriteria,                                                                             
                                CannotMeetCriteria);
        };
};



// LifeCycleService Module, p 6- 55 CORBAservices, Life Cycle
// Service V1.0, 3/94

// #include "LifeCycle.idl" 

module LifeCycleService {

        typedef sequence <::COSS::CosLifeCycle::NameValuePair> PolicyList;
        typedef sequence <::COSS::CosLifeCycle::Key> Keys;
        typedef sequence <::COSS::CosLifeCycle::NameValuePair> PropertyList; 
        typedef sequence <::COSS::CosNaming::NameComponent> NameComponents;

        interface LifeCycleServiceAdmin {

                attribute PolicyList policies;

                void bind_generic_factory(
                                in ::COSS::CosLifeCycle::GenericFactory gf,
                                in ::COSS::CosNaming::NameComponent name,
                                in Keys key_set,
                                in PropertyList other_properties)
                        raises (::COSS::CosNaming::NamingContext::AlreadyBound, ::COSS::CosNaming::NamingContext::InvalidName);

                void unbind_generic_factory(
                                in ::COSS::CosNaming::NameComponent name)
                        raises (::COSS::CosNaming::NamingContext::NotFound, ::COSS::CosNaming::NamingContext::InvalidName);

               ::COSS::CosLifeCycle::GenericFactory resolve_generic_factory(
                                in ::COSS::CosNaming::NameComponent name)
                        raises (::COSS::CosNaming::NamingContext::NotFound, ::COSS::CosNaming::NamingContext::InvalidName);

                NameComponents list_generic_factories();

                boolean match_service (in ::COSS::CosLifeCycle::GenericFactory f);

                string get_hint();

                void get_link_properties(
                                in ::COSS::CosNaming::NameComponent name,
                                out Keys key_set,
                                out PropertyList other_properties)
                        raises (::COSS::CosNaming::NamingContext::NotFound, ::COSS::CosNaming::NamingContext::InvalidName);
        };
};

// CosTransactions Module, p 10-66
// CORBAservices, Transaction Service V1.0, 3/94

module CosTransactions {
// DATATYPES
enum Status {
        StatusActive,
        StatusMarkedRollback,
        StatusPrepared,
        StatusCommitted,
        StatusRolledBack,
        StatusUnknown,
        StatusNoTransaction
};

enum Vote {
        VoteCommit,
        VoteRollback,
        VoteReadOnly
};

// Standard exceptions
exception TransactionRequired {};
exception TransactionRolledBack {};
exception InvalidTransaction {};

// Heuristic exceptions
exception HeuristicRollback {};
exception HeuristicCommit {};
exception HeuristicMixed {};
exception HeuristicHazard {};

// Exception from Orb operations
exception WrongTransaction {};

// Other transaction-specific exceptions
exception SubtransactionsUnavailable {};
exception NotSubtransaction {};
exception Inactive {};
exception NotPrepared {};
exception NoTransaction {};
exception InvalidControl {};
exception Unavailable {};

// Forward references for interfaces defined later in module
interface Control;
interface Terminator;
interface Coordinator;
interface Resource;
interface RecoveryCoordinator;
interface SubtransactionAwareResource;
interface TransactionFactory; 
interface TransactionalObject; 
interface Current;

// Current transaction pseudo object (PIDL)
	interface Current {
        void begin()
                raises(SubtransactionsUnavailable);
        void commit(in boolean report_heuristics)
                raises(
                        NoTransaction,
                        HeuristicMixed,
                        HeuristicHazard
                );
        void rollback()
                raises(NoTransaction);
        void rollback_only()
                raises(NoTransaction);

        Status get_status();
        string get_transaction_name();
        void set_timeout(in unsigned long seconds);

        Control get_control();
        Control suspend();
        void resume(in Control which)
                raises(InvalidControl);
	};

	interface TransactionFactory {
	        Control create(in unsigned long time_out);
	};

	interface Control {
 	       Terminator get_terminator()
  	              raises(Unavailable);
   	     Coordinator get_coordinator()
    	            raises(Unavailable);
	};

	interface Terminator {
	        void commit(in boolean report_heuristics)
                raises(
                        HeuristicMixed,
                        HeuristicHazard
                );
     	   void rollback();
	};


	interface Coordinator {

        Status get_status();
        Status get_parent_status();
        Status get_top_level_status();

        boolean is_same_transaction(in Coordinator tc);
        boolean is_related_transaction(in Coordinator tc);
        boolean is_ancestor_transaction(in Coordinator tc);
        boolean is_descendant_transaction(in Coordinator tc);
        boolean is_top_level_transaction();

        unsigned long hash_transaction();
        unsigned long hash_top_level_tran();

        RecoveryCoordinator register_resource(in Resource r)
                raises(Inactive);

        void register_subtran_aware(in SubtransactionAwareResource r)
                raises(Inactive, NotSubtransaction);

        void rollback_only()
                raises(Inactive);

        string get_transaction_name();

        Control create_subtransaction()
                raises(SubtransactionsUnavailable, Inactive);
	};

	interface RecoveryCoordinator {
     	   Status replay_completion(in Resource r)
                raises(NotPrepared);
	};

}; // end module CosTransactions


// CosConcurrency Control Module, p 7-8 CORBAservices, 
// Concurrency Control Service V1.0, 3/94

// #include <CosTransactions.idl>
module CosConcurrencyControl {

    enum lock_mode {
        read,
        write,
        upgrade,
        intention_read,
        intention_write
    };

    exception LockNotHeld{};

    interface LockCoordinator
    {
                void drop_locks();
    };

    interface LockSet
    {
        void lock(in lock_mode mode);
        boolean try_lock(in lock_mode mode);

        void unlock(in lock_mode mode)
            raises(LockNotHeld);
        void change_mode(in lock_mode held_mode,
                         in lock_mode new_mode)
           raises(LockNotHeld);
        LockCoordinator get_coordinator(
            in ::COSS::CosTransactions::Coordinator which);
    };

    interface TransactionalLockSet
    {
        void lock(in ::COSS::CosTransactions::Coordinator current,
                  in lock_mode mode);
        boolean try_lock(in ::COSS::CosTransactions::Coordinator current,
                         in lock_mode mode);
        void unlock(in ::COSS::CosTransactions::Coordinator current,
                    in lock_mode mode)
           raises(LockNotHeld);
        void change_mode(in ::COSS::CosTransactions::Coordinator current,
                         in lock_mode held_mode,
                         in lock_mode new_mode)
           raises(LockNotHeld);
        LockCoordinator get_coordinator(
            in ::COSS::CosTransactions::Coordinator which);
    };

    interface LockSetFactory
    {
        LockSet create();
        LockSet create_related(in LockSet which);
        TransactionalLockSet create_transactional();
        TransactionalLockSet create_transactional_related(in
            TransactionalLockSet which);
    };
};

// CosObjectIdentity Module, p 9-19 CORBAservices, Relationship
// Service V1.0, 3/94


module CosObjectIdentity {

        typedef unsigned long ObjectIdentifier;

        interface IdentifiableObject {
                        readonly attribute ObjectIdentifier constant_random_id;
                        boolean is_identical (
                                in IdentifiableObject other_object);
        };

};


// CosRelationships Module, p 9-21 CORBAservices, Relationship
// Service V1.0, 3/94

// #include <ObjectIdentity.idl>

module CosRelationships {

        interface RoleFactory; 
        interface RelationshipFactory; 
        interface Relationship; 
        interface Role;
        interface RelationshipIterator;

        typedef Object RelatedObject;
        typedef sequence<Role> Roles;
        typedef string RoleName;
        typedef sequence<RoleName> RoleNames;

        struct NamedRole {RoleName name; Role aRole;};
        typedef sequence<NamedRole> NamedRoles;

        struct RelationshipHandle {
                        Relationship the_relationship;
                        ::COSS::CosObjectIdentity::ObjectIdentifier constant_random_id;
        };
        typedef sequence<RelationshipHandle> RelationshipHandles;

        interface RelationshipFactory {
                        struct NamedRoleType {
                                RoleName name;
                                        ::CORBA::InterfaceDef named_role_type;
                        };
                        typedef sequence<NamedRoleType> NamedRoleTypes;
                        readonly attribute ::CORBA::InterfaceDef relationship_type;
                        readonly attribute unsigned short degree;
                        readonly attribute NamedRoleTypes named_role_types;
                        exception RoleTypeError {NamedRoles culprits;};
                        exception MaxCardinalityExceeded {
                                NamedRoles culprits;};
                        exception DegreeError {unsigned short required_degree;};
                        exception DuplicateRoleName {NamedRoles culprits;};
                        exception UnknownRoleName {NamedRoles culprits;};

                        Relationship create (in NamedRoles named_roles)
                                        raises (RoleTypeError,
                                                MaxCardinalityExceeded,
                                                DegreeError,
                                                DuplicateRoleName,
                                                UnknownRoleName);
        };

        interface Relationship :                                                
                                ::COSS::CosObjectIdentity::IdentifiableObject {
                        exception CannotUnlink {
                                Roles offending_roles;
                        };
                        readonly attribute NamedRoles named_roles;
                        void destroy () raises(CannotUnlink);
        };

        interface Role {
                        exception UnknownRoleName {};
                        exception UnknownRelationship {};
                        exception RelationshipTypeError {};
                        exception CannotDestroyRelationship {
                                RelationshipHandles offenders;
                        };
                        exception ParticipatingInRelationship {
                                RelationshipHandles the_relationships;
                        };
                        readonly attribute RelatedObject related_object;
                        RelatedObject get_other_related_object (
                                                in RelationshipHandle rel,
                                                in RoleName target_name)
                                raises (UnknownRoleName,
                                                UnknownRelationship);
                        Role get_other_role (in RelationshipHandle rel, 
                                                in RoleName target_name)
                                raises (UnknownRoleName, UnknownRelationship);
                        void get_relationships (
                                                in unsigned long how_many,
                                                out RelationshipHandles rels,
                                                out RelationshipIterator iterator);
                        void destroy_relationships()
                                raises(CannotDestroyRelationship);
                        void destroy() raises(ParticipatingInRelationship);
                        boolean check_minimum_cardinality ();
                        void link (in RelationshipHandle rel,
                                                in NamedRoles named_roles)
                                        raises(RelationshipFactory::MaxCardinalityExceeded,
                                                RelationshipTypeError);
                        void unlink (in RelationshipHandle rel)
                                raises (UnknownRelationship);
        };

        interface RoleFactory {
                        exception NilRelatedObject {};
                        exception RelatedObjectTypeError {};
                        readonly attribute ::CORBA::InterfaceDef role_type;
                        readonly attribute unsigned long max_cardinality;
                        readonly attribute unsigned long min_cardinality;
// the following isn't allowed in IDL,
//  readonly attribute sequence <::CORBA::InterfaceDef> related_object_types;
			typedef sequence <::CORBA::InterfaceDef> InterfaceDefSeq;
			readonly attribute InterfaceDefSeq related_object_types;
                        Role create_role (in RelatedObject related_object)
                                raises (NilRelatedObject, RelatedObjectTypeError);
        };

        interface RelationshipIterator {
                        boolean next_one (out RelationshipHandle rel);
                        boolean next_n (in unsigned long how_many,
                                                out RelationshipHandles rels);
                        void destroy ();
        };

};

// CosCompoundExternalization Module, p 8-20 CORBAservices,
// Externalization Service V1.0, 3/94

// #include <Graphs.idl>
// #include <Stream.idl>

// CosGraphs Module, p 9-39 CORBAservices, Relationship Service
// V1.0, 3/94

// #include <Relationships.idl>
// #include <ObjectIdentity.idl>

module CosGraphs {

                interface TraversalFactory; 
                interface Traversal;
                interface TraversalCriteria;
                interface Node;
                interface NodeFactory;
                interface Role; 
                interface EdgeIterator; 
                                
                struct NodeHandle {
                        Node the_node;
                        ::COSS::CosObjectIdentity::ObjectIdentifier constant_random_id;
                };
                typedef sequence<NodeHandle> NodeHandles;
                                
                struct NamedRole {
                        Role the_role;  
		  ::COSS::CosRelationships::RoleName the_name;
                };
                typedef sequence<NamedRole> NamedRoles;

                struct EndPoint {
                        NodeHandle the_node;
                        NamedRole the_role;
                };
                typedef sequence<EndPoint> EndPoints;

                struct Edge {
                        EndPoint from;
                        ::COSS::CosRelationships::RelationshipHandle the_relationship;
                        EndPoints relatives;
                };
                typedef sequence<Edge> Edges;

                enum PropagationValue {deep, shallow, none, inhibit};
                enum Mode {depthFirst, breadthFirst, bestFirst};

                interface TraversalFactory {
                        Traversal create_traversal_on (
                                        in NodeHandle root_node,
                                        in TraversalCriteria the_criteria,
                                        in Mode how);
                };

                interface Traversal {
                        typedef unsigned long TraversalScopedId;
                        struct ScopedEndPoint {
                                EndPoint point;
                                TraversalScopedId id;
                        };
                        typedef sequence<ScopedEndPoint> ScopedEndPoints;
                        struct ScopedRelationship {
                                ::COSS::CosRelationships::RelationshipHandle
                                        scoped_relationship;
                                TraversalScopedId id;
                        };
                        struct ScopedEdge {
                                ScopedEndPoint from;
                                ScopedRelationship the_relationship;
                                ScopedEndPoints relatives;
                        };
                        typedef sequence<ScopedEdge> ScopedEdges;
                        boolean next_one (out ScopedEdge the_edge);
                        boolean next_n (in short how_many,
                                        out ScopedEdges the_edges);
                        void destroy ();
                };
                                
                interface TraversalCriteria {
                        struct WeightedEdge {
                                Edge the_edge;
                                unsigned long weight;
                                sequence<NodeHandle> next_nodes;
                        };
                        typedef sequence<WeightedEdge> WeightedEdges;
                        void visit_node(in NodeHandle a_node,
                                        in Mode search_mode);
                        boolean next_one (out WeightedEdge the_edge);
                        boolean next_n (in short how_many, 
                                        out WeightedEdges the_edges);
                        void destroy();
                };
                                
                interface Node: ::COSS::CosObjectIdentity::IdentifiableObject {
                        typedef sequence<Role> Roles;
                        exception NoSuchRole {};
                        exception DuplicateRoleType {};
                                
                        readonly attribute ::COSS::CosRelationships::RelatedObject
                                 related_object;
                        readonly attribute Roles roles_of_node;
                        Roles roles_of_type ( 
                                        in ::CORBA::InterfaceDef role_type);
                        void add_role (in Role a_role)
                                        raises (DuplicateRoleType);
                        void remove_role (in ::CORBA::InterfaceDef of_type)
                                raises (NoSuchRole);
                };
                                
                interface NodeFactory {
                        Node create_node (in Object related_object);
                };
                                
                interface Role : ::COSS::CosRelationships::Role {
                        void get_edges ( in long how_many,
                                        out Edges the_edges,
                                        out EdgeIterator the_rest);
                };
                                
                interface EdgeIterator {
                        boolean next_one (out Edge the_edge);
                        boolean next_n ( in unsigned long how_many,
                                        out Edges the_edges);
                        void destroy ();
                };
                                
};



// CosStream Module, 8-15 CORBAservices, 
// Externalization Service V1.0, 3/94

// #include <LifeCycle.idl>
// #include <ObjectIdentity.idl>
// #include <CompoundExternalization.idl>
module CosStream {
                exception ObjectCreationError{};
                exception StreamDataFormatError{};
                interface StreamIO;

                interface Streamable: ::COSS::CosObjectIdentity::IdentifiableObject
		{
                        readonly attribute ::COSS::CosLifeCycle::Key external_form_id;
                        void externalize_to_stream(
                                        in StreamIO targetStreamIO);
                        void internalize_from_stream(
                                        in StreamIO sourceStreamIO,
                                        in ::COSS::CosLifeCycle::FactoryFinder there)
				raises( ::COSS::CosLifeCycle::NoFactory,
                                        ObjectCreationError,
                                        StreamDataFormatError );
                };

                interface StreamableFactory {
                        Streamable create_uninitialized();
                };


                interface StreamIO {
                        void write_string(in string aString);
                        void write_char(in char aChar);
                        void write_octet(in octet anOctet);
                        void write_unsigned_long(
                                        in unsigned long anUnsignedLong);
                        void write_unsigned_short(
                                        in unsigned short anUnsignedShort);
                        void write_long(in long aLong);
                        void write_short(in short aShort);
                        void write_float(in float aFloat);
                        void write_double(in double aDouble);
                        void write_boolean(in boolean aBoolean);
                        void write_object(in Streamable aStreamable);
			//                        void write_graph(in ::COSS::CosCompoundExternalization::Node aNode);
                        string read_string() 
                                raises(StreamDataFormatError);
                        char read_char()                        
                                raises(StreamDataFormatError );
                        octet read_octet()
                                raises(StreamDataFormatError );
                        unsigned long read_unsigned_long() 
                                        raises(StreamDataFormatError );
                        unsigned short read_unsigned_short()
                                raises(         StreamDataFormatError );
                        long read_long()                
                                raises(StreamDataFormatError );
                        short read_short()
                                raises(StreamDataFormatError );
                        float read_float()
                                raises(StreamDataFormatError );
                        double read_double()
                                raises(StreamDataFormatError );
                        boolean read_boolean()
                                raises(StreamDataFormatError );
                        Streamable read_object(
                                        in ::COSS::CosLifeCycle::FactoryFinder there,
                                        in Streamable aStreamable)
                                raises(StreamDataFormatError );
//                         void read_graph(
//                                         in ::COSS::CosCompoundExternalization::Node starting_node,
//                                         in ::COSS::CosLifeCycle::FactoryFinder there)
//                                 raises(StreamDataFormatError );
                };
};

module CosCompoundExternalization {
        interface Node;
        interface Role;
        interface Relationship;
        interface PropagationCriteriaFactory;
        
        struct RelationshipHandle {
                        Relationship theRelationship;
                        ::COSS::CosObjectIdentity::ObjectIdentifier constantRandomId;
        };

        interface Node : ::COSS::CosGraphs::Node, ::COSS::CosStream::Streamable{
                        void externalize_node (in ::COSS::CosStream::StreamIO sio);
                        void internalize_node (in ::COSS::CosStream::StreamIO sio,
                                                in ::COSS::CosLifeCycle::FactoryFinder there,
                                                out ::COSS::CosGraphs::Node::Roles rolesOfNode)
                                raises (::COSS::CosLifeCycle::NoFactory);
                };

        interface Role : ::COSS::CosGraphs::Role {
                        void externalize_role (in ::COSS::CosStream::StreamIO sio); 
                        void internalize_role (in ::COSS::CosStream::StreamIO sio); 
                        ::COSS::CosGraphs::PropagationValue externalize_propagation (
                                                in RelationshipHandle rel,
                                                in ::COSS::CosRelationships::RoleName toRoleName,
                                                out boolean sameForAll);
                };

        interface Relationship : 
                                ::COSS::CosRelationships::Relationship {
                  void externalize_relationship (
			in ::COSS::CosStream::StreamIO sio);
			void internalize_relationship(
				in ::COSS::CosStream::StreamIO sio,
				in ::COSS::CosGraphs::NamedRoles newRoles);
                        ::COSS::CosGraphs::PropagationValue externalize_propagation (
				in ::COSS::CosRelationships::RoleName fromRoleName,
				in ::COSS::CosRelationships::RoleName toRoleName,
				out boolean sameForAll);
        };

        interface PropagationCriteriaFactory {
                        ::COSS::CosGraphs::TraversalCriteria create_for_externalize( );
        };

};

// CosExternalization Module, 8-12 CORBAservices,
// Externalization Service V1.0, 3/94


// #include <LifeCycle.idl>
// #include <Stream.idl>
module CosExternalization {
                exception InvalidFileNameError{};
                exception ContextAlreadyRegistered{};
                interface Stream: ::COSS::CosLifeCycle::LifeCycleObject{
                        void externalize(
                                        in ::COSS::CosStream::Streamable theObject);
                        ::COSS::CosStream::Streamable internalize( 
                                        in ::COSS::CosLifeCycle::FactoryFinder there)
                                raises( ::COSS::CosLifeCycle::NoFactory,
                                        ::COSS::CosStream::StreamDataFormatError );
                        void begin_context()
                                raises( ContextAlreadyRegistered);
                        void end_context(); 
                        void flush();
                };
                interface StreamFactory {
                        Stream create();
                };
                interface FileStreamFactory {
                        Stream create(
                                        in string theFileName) 
                                raises( InvalidFileNameError );
                };
};

// CosContainment Module, p 9- 48 CORBAservices, Relationship
// Service V1.0, 3/94

// #include <Graphs.idl>

module CosContainment {

        interface Relationship :
                        ::COSS::CosRelationships::Relationship {};

        interface ContainsRole : ::COSS::CosGraphs::Role {};

        interface ContainedInRole : ::COSS::CosGraphs::Role {};

};

//  CosExternalizationContainment Module, p 8-26 CORBAservices,
// Externalization Service V1.0, 3/94

// #include <Containment.idl>
// #include <CompoundExternalization.idl>

module CosExternalizationContainment {

        interface Relationship : 
                        ::COSS::CosCompoundExternalization::Relationship,
                        ::COSS::CosContainment::Relationship {};

        interface ContainsRole : 
                        ::COSS::CosCompoundExternalization::Role,
                        ::COSS::CosContainment::ContainsRole {};

        interface ContainedInRole : 
                        ::COSS::CosCompoundExternalization::Role,
                        ::COSS::CosContainment::ContainedInRole {};
};

// CosReference Module, p 9-50 CORBAservices,
//  Relationship Service V1.0, 3/94

// #include <Graphs.idl>

module CosReference {

        interface Relationship : 
                        ::COSS::CosRelationships::Relationship {};

        interface ReferencesRole : ::COSS::CosGraphs::Role {};

        interface ReferencedByRole : ::COSS::CosGraphs::Role {};

};

// CosExternalizationReference Module, p 8-28 CORBAservices, 
// Externalization Service V1.0, 3/94

// #include <Reference.idl>
// #include <CompoundExternalization.idl>

module CosExternalizationReference {

        interface Relationship : 
                        ::COSS::CosCompoundExternalization::Relationship,
                        ::COSS::CosReference::Relationship {};

        interface ReferencesRole : 
                        ::COSS::CosCompoundExternalization::Role,
                        ::COSS::CosReference::ReferencesRole {};

        interface ReferencedByRole : 
                        ::COSS::CosCompoundExternalization::Role,
                        ::COSS::CosReference::ReferencedByRole {};
};

// PIDL for CosTSInteroperation Module, p 10-59 
// CORBAservices, Transaction Service V1.0, 3/94
module CosTSInteroperation { // PIDL
        struct otid_t {
                long formatID; /*format identifier. 0 is OSI TP */
                long bequal_length;
                sequence <octet> tid;
	};
        struct TransIdentity {
                ::COSS::CosTransactions::Coordinator coordinator;
                ::COSS::CosTransactions::Terminator terminator;
                otid_t otid;
	};
        struct PropagationContext {
                unsigned long timeout;
                TransIdentity current;
                sequence <TransIdentity> parents;
                any implementation_specific_data;
        };
};

// PIDL for CosTSPortability Module, p 10-63 
// CORBAservices, Transaction Service V1.0, 3/94

module CosTSPortability { // PIDL
        typedef long ReqId;

        interface Sender {
                void sending_request(in ReqId id,
                        out ::COSS::CosTSInteroperation::PropagationContext ctx);
                void received_reply(in ReqId id,
                        in ::COSS::CosTSInteroperation::PropagationContext ctx, 
                        in ::CORBA::Environment env);
        };

        interface Receiver {
                void received_request(in ReqId id,
                        in ::COSS::CosTSInteroperation::PropagationContext ctx);
                void sending_reply(in ReqId id,
                        out::COSS::CosTSInteroperation::PropagationContext ctx);
        };
};

// CosCompoundLifeCycle Module, p 6-30 CORBAservices,
// Life Cycle Service V1.0, 3/94

// #include <LifeCycle.idl>
// #include <Relationships.idl>
// #include <Graphs.idl>

module CosCompoundLifeCycle {
        interface OperationsFactory; 
        interface Operations;
        interface Node;
        interface Role;
        interface Relationship;
        interface PropagationCriteriaFactory;
        
        enum Operation {copy, move, remove};

        struct RelationshipHandle {
                        Relationship the_relationship;
                        ::COSS::CosObjectIdentity::ObjectIdentifier constant_random_id;
        };

        interface OperationsFactory {
                        Operations create_compound_operations();
        };

        interface Operations {
                        Node copy (
                                                in Node starting_node,
                                                in ::COSS::CosLifeCycle::FactoryFinder there,
                                                in ::COSS::CosLifeCycle::Criteria the_criteria)
                                raises (::COSS::CosLifeCycle::NoFactory,
                                                ::COSS::CosLifeCycle::NotCopyable,
                                                ::COSS::CosLifeCycle::InvalidCriteria,
                                                ::COSS::CosLifeCycle::CannotMeetCriteria);
                        void move (
                                                in Node starting_node,
                                                in ::COSS::CosLifeCycle::FactoryFinder there,
                                                in ::COSS::CosLifeCycle::Criteria the_criteria)
                                raises (::COSS::CosLifeCycle::NoFactory,
                                                ::COSS::CosLifeCycle::NotMovable,
                                                ::COSS::CosLifeCycle::InvalidCriteria,
                                                ::COSS::CosLifeCycle::CannotMeetCriteria);
                        void remove (in Node starting_node)
                                raises (::COSS::CosLifeCycle::NotRemovable);
                        void destroy();
                };

        interface Node : ::COSS::CosGraphs::Node {
                        exception NotLifeCycleObject {};
                        void copy_node ( in ::COSS::CosLifeCycle::FactoryFinder there,
                                                in ::COSS::CosLifeCycle::Criteria the_criteria,
                                                out Node new_node,
                                                out ::COSS::CosGraphs::Node::Roles roles_of_new_node)
                                raises (::COSS::CosLifeCycle::NoFactory,
                                                ::COSS::CosLifeCycle::NotCopyable,
                                                ::COSS::CosLifeCycle::InvalidCriteria,
                                                ::COSS::CosLifeCycle::CannotMeetCriteria);
                        void move_node (in ::COSS::CosLifeCycle::FactoryFinder there, 
                                                in ::COSS::CosLifeCycle::Criteria the_criteria)
                                raises (::COSS::CosLifeCycle::NoFactory,
                                                ::COSS::CosLifeCycle::NotMovable,
                                                ::COSS::CosLifeCycle::InvalidCriteria,
                                                ::COSS::CosLifeCycle::CannotMeetCriteria);
                        void remove_node ()
                                raises (::COSS::CosLifeCycle::NotRemovable);
                        ::COSS::CosLifeCycle::LifeCycleObject get_life_cycle_object()
                                raises (NotLifeCycleObject);
                };

        interface Role : ::COSS::CosGraphs::Role {
                        Role copy_role (in ::COSS::CosLifeCycle::FactoryFinder there, 
                                                in ::COSS::CosLifeCycle::Criteria the_criteria)
                                raises (::COSS::CosLifeCycle::NoFactory,
                                                ::COSS::CosLifeCycle::NotCopyable,
                                                ::COSS::CosLifeCycle::InvalidCriteria,
                                                ::COSS::CosLifeCycle::CannotMeetCriteria);
                        void move_role (in ::COSS::CosLifeCycle::FactoryFinder there, 
                                                in ::COSS::CosLifeCycle::Criteria the_criteria)
                                raises (::COSS::CosLifeCycle::NoFactory,
                                                ::COSS::CosLifeCycle::NotMovable,
                                                ::COSS::CosLifeCycle::InvalidCriteria,
                                                ::COSS::CosLifeCycle::CannotMeetCriteria);
                        ::COSS::CosGraphs::PropagationValue life_cycle_propagation (
                                                in Operation op,
                                                in RelationshipHandle rel,
                                                in ::COSS::CosRelationships::RoleName to_role_name,
                                                out boolean same_for_all);
                };

        interface Relationship : 
                                ::COSS::CosRelationships::Relationship {
                        Relationship copy_relationship (
                                                in ::COSS::CosLifeCycle::FactoryFinder there,
                                                in ::COSS::CosLifeCycle::Criteria the_criteria,
                                                in ::COSS::CosGraphs::NamedRoles new_roles)
                                raises (::COSS::CosLifeCycle::NoFactory,
                                                ::COSS::CosLifeCycle::NotCopyable,
                                                ::COSS::CosLifeCycle::InvalidCriteria,
                                                ::COSS::CosLifeCycle::CannotMeetCriteria);
                        void move_relationship (
                                                in ::COSS::CosLifeCycle::FactoryFinder there,
                                                in ::COSS::CosLifeCycle::Criteria the_criteria)
                                raises (::COSS::CosLifeCycle::NoFactory,
                                                ::COSS::CosLifeCycle::NotMovable,
                                                ::COSS::CosLifeCycle::InvalidCriteria,
                                                ::COSS::CosLifeCycle::CannotMeetCriteria);
                        ::COSS::CosGraphs::PropagationValue life_cycle_propagation (
                                                in Operation op,
                                                in ::COSS::CosRelationships::RoleName from_role_name,
                                                in ::COSS::CosRelationships::RoleName to_role_name,
                                                out boolean same_for_all);
        };

        interface PropagationCriteriaFactory {
                        ::COSS::CosGraphs::TraversalCriteria create(in Operation op);
        };

};

//  CosLifeCycleContainment Module, p 6-42 CORBAservices,
//  Life Cycle Service V1.0, 3/94

// #include <Containment.idl>
// #include <CompoundLifeCycle.idl>

module CosLifeCycleContainment {

        interface Relationship : 
                        ::COSS::CosCompoundLifeCycle::Relationship,
                        ::COSS::CosContainment::Relationship {};

        interface ContainsRole : 
                        ::COSS::CosCompoundLifeCycle::Role,
                        ::COSS::CosContainment::ContainsRole {};

        interface ContainedInRole : 
                        ::COSS::CosCompoundLifeCycle::Role,
                        ::COSS::CosContainment::ContainedInRole {};
};

// CosLifeCycleReference Module, p 6-44 CORBAservices,
// Life Cycle Service V1.0, 3/94

// #include <Reference.idl>
// #include <CompoundLifeCycle.idl>

module CosLifeCycleReference {

        interface Relationship : 
                        ::COSS::CosCompoundLifeCycle::Relationship,
                        ::COSS::CosReference::Relationship {};

        interface ReferencesRole : 
                        ::COSS::CosCompoundLifeCycle::Role,
                        ::COSS::CosReference::ReferencesRole {};

        interface ReferencedByRole : 
                        ::COSS::CosCompoundLifeCycle::Role,
                        ::COSS::CosReference::ReferencedByRole {};
};


}; // end module COSS