//File: ConcurrencyControl.idl
//The only module of the Concurrency Control Service

#ifndef _COS_CONCURRENCY_CONTROL_IDL_
#define _COS_CONCURRENCY_CONTROL_IDL_

// omniORB specific pragmas to insert extra includes into the stub header.
#pragma hh #include "COS_sysdep.h"

#include <orb.idl>
#pragma prefix "omg.org"

#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 CosTransactions::Coordinator which);
    };

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

    interface LockSetFactory
    {
        LockSet create();
        LockSet create_related(in LockSet which);
        TransactionalLockSet create_transactional();
        TransactionalLockSet create_transactional_related(
			in TransactionalLockSet which);
    };
};
#endif /* ifndef _COS_CONCURRENCY_CONTROL_IDL_ */
