/*  -*- mode: c++; c-basic-offset: 4; -*-
 *
 *  MICO --- a free CORBA implementation
 *  Copyright (C) 1999 Andreas Schultz
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public
 *  License along with this library; if not, write to the Free
 *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  Send comments and/or bug reports to:
 *                 mico@informatik.uni-frankfurt.de      
 *
 */

#ifndef __RT_MICO_IMPL_H__
#define __RT_MICO_IMPL_H__

class PriorityModelPolicy_impl : virtual public Policy_impl,
				 virtual public RT_CORBA::PriorityModelPolicy {
protected:                                             
    RT_CORBA::PriorityModel pm;
    RT_CORBA::Priority      sp;

public:
    PriorityModelPolicy_impl ( RT_CORBA::PriorityModel, RT_CORBA::Priority );
    virtual ~PriorityModelPolicy_impl ();
 
    CORBA::Policy_ptr copy ();

    RT_CORBA::PriorityModel priority_model();
    RT_CORBA::Priority server_priority();
};     

class ThreadpoolPolicy_impl : virtual public Policy_impl,
			      virtual public RT_CORBA::ThreadpoolPolicy {
protected:                                             
    RT_CORBA::ThreadpoolId _tp;
public:
    ThreadpoolPolicy_impl ( RT_CORBA::ThreadpoolId );
    virtual ~ThreadpoolPolicy_impl ();
 
    CORBA::Policy_ptr copy ();

    RT_CORBA::ThreadpoolId threadpool();
};     

class RTCurrent_impl: public RT_CORBA::Current {
protected:
    MICOMT::Thread *thr;
public:
    RTCurrent_impl( MICOMT::Thread * );
    virtual ~RTCurrent_impl();

    RT_CORBA::Priority the_priority();
    void the_priority( RT_CORBA::Priority value );
};

class RTORB_impl: public RT_CORBA::RTORB {
protected:
    CORBA::ORB *orb;
public:
    RTORB_impl(CORBA::ORB *_orb) { orb = _orb; };
    ~RTORB_impl() {};

    RT_CORBA::Mutex_ptr create_mutex() {
	return new RT_CORBA::Mutex();
    };
    void destroy_mutex( RT_CORBA::Mutex_ptr the_mutex ) {
	delete the_mutex;
    };

    //FIXME: this is only a temporary solution !
    RT_CORBA::ThreadpoolId create_threadpool( CORBA::ULong stacksize,
					      CORBA::ULong static_threads,
					      CORBA::ULong dynamic_threads,
					      RT_CORBA::Priority default_priority,
					      CORBA::Boolean allow_request_buffering,
					      CORBA::ULong max_buffered_requests,
					      CORBA::ULong max_request_buffer_size )
	{
	    ThreadPool *tp = new ThreadPool( static_threads + dynamic_threads, 0, static_threads );
	    tp->start_threads();
	    return _tpm->register_new_tp( *tp );
	};
    RT_CORBA::ThreadpoolId create_threadpool_with_lanes( CORBA::ULong stacksize,
							 const RT_CORBA::ThreadpoolLanes& lanes,
							 CORBA::Boolean allow_borrowing,
							 CORBA::Boolean allow_request_buffering,
							 CORBA::ULong max_buffered_requests,
							 CORBA::ULong max_request_buffer_size )
	{
	    assert( 0 );
            return 0;   // keep HP aCC happy...
	}
    void destroy_threadpool( RT_CORBA::ThreadpoolId threadpool ) {
	assert ( 0 );
    };

    RT_CORBA::PriorityModelPolicy_ptr create_priority_model_policy(RT_CORBA::PriorityModel pm,
								   RT_CORBA::Priority sp ) {
	return new PriorityModelPolicy_impl(pm, sp);
    };
    RT_CORBA::ThreadpoolPolicy_ptr create_threadpool_policy( RT_CORBA::ThreadpoolId threadpool ) {
	return new ThreadpoolPolicy_impl( threadpool );
    };
};

#endif // __RT_MICO_IMPL_H__
