#include "bench.h"
#ifdef _WINDOWS
#include <iostream>
#else
#include <iostream.h>
#endif

class Bench_impl : virtual public Bench_skel {
    Bench_var _bench;
    CORBA::Long _level;
public:
    void f ()
    {
    }
    void g ()
    {
	if (--_level > 0)
	    _bench->g();
    }
    void connect (Bench_ptr b, CORBA::Long l)
    {
	_bench = Bench::_duplicate (b);
	_level = l;
    }
};

class Bench_impl3 : virtual public POA_Bench {
public:
    Bench_var _bench;
    CORBA::Long _level;
public:
    void f ()
    {
    }
    void g ()
    {
	if (--_level > 0)
	    _bench->g();
    }
    void connect (Bench_ptr b, CORBA::Long l)
    {
	_bench = Bench::_duplicate (b);
	_level = l;
    }
};

#if 1
class Bench_impl2 : public CORBA::StaticImplementation {
public:
    Bench_impl2 ();
    virtual void invoke (CORBA::StaticServerRequest_ptr svreq,
			 CORBA::Environment &env);
    virtual void f ();
};

Bench_impl2::Bench_impl2 ()
{
    CORBA::ImplementationDef_var impl = _find_impl ("IDL:Bench:1.0", "Bench1");
    assert (!CORBA::is_nil (impl));

    _create_ref (CORBA::BOA::ReferenceData(),
		 CORBA::InterfaceDef::_nil(),
		 impl,
		 "IDL:Bench:1.0");
}

void
Bench_impl2::invoke (CORBA::StaticServerRequest_ptr svreq,
		  CORBA::Environment &env)
{
    if (!strcmp (svreq->op_name(), "f")) {
	// read arguments
	if (!svreq->read_args())
	    return;

	// call user code
	f ();

	// write results
	svreq->write_results();
    }
}

void
Bench_impl2::f ()
{
}
#endif
