/*  -*- mode: c++; c-basic-offset: 4; -*-
 *
*/
// IDL  
#include <mico/TimeBase.idl>
#include <mico/ioptypes.idl>
#include <mico/policy.idl>
#include <mico/current.idl>

#pragma prefix "omg.org"   

#ifdef HAS_TO_BE_MOVED
module CORBA {
    module IOP {
	const ServiceID RTCorbaPriority = 10;
	// <number to be assigned by OMG>
	const ServiceID RTCorbaPriorityRange = 11;
	// <number to be assigned by OMG>
    };
};
#endif

module RT_CORBA {

    typedef short NativePriority;
    typedef short Priority;

    const Priority minPriority = 0;
    const Priority maxPriority = 32767;

#ifdef NOT_NEEDED
    native PriorityMapping;
    native PriorityTransform; 
#endif

    // Threadpool types 
    typedef unsigned long ThreadpoolId;

    struct ThreadpoolLane {
	Priority       lane_priority; 
	unsigned long  static_threads; 
	unsigned long  dynamic_threads;
    };

    typedef sequence <ThreadpoolLane> ThreadpoolLanes;

    // Priority Model Policy 
    const CORBA::PolicyType       PRIORITY_MODEL_POLICY_TYPE = 12;

    enum PriorityModel {
	CLIENT_PROPAGATED,
	SERVER_DECLARED };

    interface PriorityModelPolicy: CORBA::Policy {
	readonly attribute PriorityModel priority_model;
	readonly attribute Priority server_priority;
    }; 

    // Threadpool Policy 
    const CORBA::PolicyType THREADPOOL_POLICY_TYPE = 13;

    interface ThreadpoolPolicy : CORBA::Policy {
	readonly attribute ThreadpoolId threadpool; 
    };

#ifdef NOT_YET
    // Locality Constrained interface 
    interface ProtocolProperties {};

    struct Protocol {
	CORBA::IOP::ProfileId          protocol_type;
	ProtocolProperties orb_protocol_properties;
	ProtocolProperties transport_protocol_properties;
    };

    typedef sequence <Protocol> ProtocolList;

    // Server Protocol Policy
    const CORBA::PolicyType SERVER_PROTOCOL_POLICY_TYPE = 14;

    // locality constrained interface 
    interface ServerProtocolPolicy : CORBA::Policy {
	readonly attribute ProtocolList protocols;
    };

    // Client Protocol Policy
    const CORBA::PolicyType CLIENT_PROTOCOL_POLICY_TYPE = 15;

    // locality constrained interface 
    interface ClientProtocolPolicy : CORBA::Policy {
	readonly attribute ProtocolList protocols;
    };

    // Private Connection Policy 
    const CORBA::PolicyType PRIVATE_CONNECTION_POLICY_TYPE = 16;

    // locality constrained interface 
    interface PrivateConnectionPolicy : CORBA::Policy {};

    interface TCPProtocolProperties : ProtocolProperties {
	attribute long     send_buffer_size;
	attribute long     recv_buffer_size; 
	attribute boolean  keep_alive;
	attribute boolean  dont_route;
	attribute boolean  no_delay;
    };

    interface GIOPProtocolProperties : ProtocolProperties { };

    struct PriorityBand {
	Priority low;
	Priority high;
    };

    typedef sequence <PriorityBand> PriorityBands; 

    // PriorityBandedConnectionPolicy
    const CORBA::PolicyType PRIORITY_BANDED_CONNECTION_POLICY_TYPE = 17;

    interface PriorityBandedConnectionPolicy : CORBA::Policy {
	readonly attribute PriorityBands priority_bands; 
    };
#endif

    interface Current : CORBA::Current {
	attribute Priority the_priority; 
    };

    interface Mutex {};
#ifdef DONT_LIKE_IT
    // locality constrained interface
    interface Mutex {
	void lock( ); 
	void unlock( );
	boolean try_lock ( in TimeBase::TimeT max_wait ); 
	// if max_wait = 0 then return immediately
    };
#endif

    // locality constrained interface 
    interface RTORB {
	Mutex create_mutex( );
	void destroy_mutex( in Mutex the_mutex );

	exception InvalidThreadpool {}; 
	ThreadpoolId create_threadpool ( in unsigned long  stacksize,
					 in unsigned long  static_threads,
					 in unsigned long  dynamic_threads,
					 in Priority       default_priority,
					 in boolean        allow_request_buffering,
					 in unsigned long  max_buffered_requests,
					 in unsigned long  max_request_buffer_size );
	
	ThreadpoolId create_threadpool_with_lanes ( in unsigned long   stacksize,
						    in ThreadpoolLanes lanes,
						    in boolean         allow_borrowing,
						    in boolean         allow_request_buffering,
						    in unsigned long   max_buffered_requests,
						    in unsigned long   max_request_buffer_size );

	void destroy_threadpool ( in ThreadpoolId threadpool )
	    raises (InvalidThreadpool);

	PriorityModelPolicy create_priority_model_policy ( in PriorityModel priority_model,
							   in Priority server_priority );

	ThreadpoolPolicy create_threadpool_policy ( in ThreadpoolId threadpool );

#ifdef NOT_YET
	PriorityBandedConnectionPolicy
	    create_priority_banded_connection_policy ( in PriorityBands priority_bands );

	ServerProtocolPolicy create_server_protocol_policy ( in ProtocolList protocols );
	ClientProtocolPolicy create_client_protocol_policy ( in ProtocolList protocols );
	PrivateConnectionPolicy create_private_connection_policy ( );
#endif
    }; // End interface RTORB
}; // End module RT_CORBA 


#ifdef NOT_YET
// IDL
module RTPortableServer {

// locality constrained object 
    interface POA : PortableServer::POA {

	Object create_reference_with_priority ( in CORBA::RepositoryId intf,
						in RT_CORBA::Priority priority )
	    raises ( WrongPolicy );

	Object create_reference_with_id_and_priority ( in PortableServer::ObjectId oid,
						       in CORBA::RepositoryId intf,
						       in RT_CORBA::Priority priority )
	    raises ( WrongPolicy );

	ObjectId activate_object_with_priority ( in PortableServer::Servant p_servant,
						 in RT_CORBA::Priority priority )
	    raises ( ServantAlreadyActive, WrongPolicy );

	void activate_object_with_id_and_priority ( in PortableServer::ObjectId oid,
						    in PortableServer::Servant p_servant,
						    in RT_CORBA::Priority priority )
	    raises ( ServantAlreadyActive, ObjectAlreadyActive, WrongPolicy );
    };
};
#endif
