// **********************************************************************
//
// Generated by the ORBacus IDL-to-C++ Translator
//
// Copyright (c) 1998
// Object-Oriented Concepts, Inc.
// Billerica, MA, USA
//
// Copyright (c) 1998
// Object-Oriented Concepts GmbH
// Ettlingen, Germany
//
// All Rights Reserved
//
// **********************************************************************

// Version: 3.0.1
// License: non-commercial

#include <OB/CORBA.h>
#include <OB/TemplateI.h>
#include <bisupclient.h>

//
// IDL:msgSequence:1.0
//
OBTypeCodeConst _tc_msgSequence(
"010000001500000040000000010000001400000049444c3a6d736753657175656e63653a312e3"
"0000c0000006d736753657175656e636500130000000c000000010000000200000000000000"
);

//
// IDL:bisupClientInterface:1.0
//
#ifndef HAVE_NO_EXPLICIT_TEMPLATES
template class OBObjVar< bisupClientInterface >;
template class OBObjForSeq< bisupClientInterface >;
#else
#ifdef HAVE_PRAGMA_DEFINE
#pragma define(OBObjVar< bisupClientInterface >)
#pragma define(OBObjForSeq< bisupClientInterface >)
#endif
#endif

void
OBDuplicate(bisupClientInterface_ptr p)
{
    if(p)
        p -> _OB_incRef();
}

void
OBRelease(bisupClientInterface_ptr p)
{
    if(p)
        p -> _OB_decRef();
}

bisupClientInterface_ptr
bisupClientInterface::_narrow(CORBA_Object_ptr p)
{
    if(!CORBA_is_nil(p))
    {
        void* v = p -> _OB_narrowHelp("IDL:bisupClientInterface:1.0");

        if(v)
            return _duplicate((bisupClientInterface_ptr)v);

        if(p -> _OB_remoteIsA("IDL:bisupClientInterface:1.0"))
        {
            bisupClientInterface_ptr val = new bisupClientInterface;
            val -> _OB_copyFrom(p);
            return val;
        }
    }

    return _nil();
}

void*
bisupClientInterface::_OB_narrowHelp(const char* _ob_id) const
{
    if(strcmp("IDL:bisupClientInterface:1.0", _ob_id) == 0)
        return (void*)this;
    else
        return CORBA_Object::_OB_narrowHelp(_ob_id);
}

const char*
bisupClientInterface::_OB_typeId() const
{
    return "IDL:bisupClientInterface:1.0";
}

void
OBUnmarshal(bisupClientInterface_ptr& val, const CORBA_Octet*& coct, bool swap)
{
    bisupClientInterface_var old = val;
    CORBA_Object_var p;
    OBUnmarshal(p.inout(), coct, swap);

    if(!CORBA_is_nil(p))
    {
        void* v = p -> _OB_narrowHelp("IDL:bisupClientInterface:1.0");

        if(v)
            val = bisupClientInterface::_duplicate((bisupClientInterface_ptr)v);
        else
        {
            assert_nca(!(p -> _is_local() && p -> _is_dynamic()), OBNCADynamicAsStatic);
            assert(!p -> _is_local());
            val = new bisupClientInterface;
            val -> _OB_copyFrom(p);
        }
    }
    else
        val = bisupClientInterface::_nil();
}

OBTypeCodeConst _tc_bisupClientInterface(
"010000000e00000041000000010000001d00000049444c3a6269737570436c69656e74496e746"
"572666163653a312e3000000000150000006269737570436c69656e74496e7465726661636500"
);

void
operator<<=(CORBA_Any& any, bisupClientInterface_ptr val)
{
    OBObjAny* o = new OBObjAny;
    o -> b = CORBA_Object::_duplicate(val);
    o -> d = CORBA_Object::_duplicate(val);
    any.replace(_tc_bisupClientInterface, o, true);
}

void
operator<<=(CORBA_Any& any, bisupClientInterface_ptr* val)
{
    OBObjAny* o = new OBObjAny;
    o -> b = *val;
    o -> d = CORBA_Object::_duplicate(*val);
    any.replace(_tc_bisupClientInterface, o, true);
}

CORBA_Boolean
operator>>=(const CORBA_Any& any, bisupClientInterface_ptr& val)
{
    if(any.check_type(_tc_bisupClientInterface))
    {
        OBObjAny* o = (OBObjAny*)any.value();
        assert(o);

        if(!CORBA_is_nil(o -> d))
        {
            void* v = o -> d -> _OB_narrowHelp("IDL:bisupClientInterface:1.0");

            if(v)
                val = (bisupClientInterface_ptr)v;
            else
            {
                assert_nca(!(o -> d -> _is_local() && o -> d -> _is_dynamic()), OBNCADynamicAsStatic);
                assert(!o -> d -> _is_local());
                val = new bisupClientInterface;
                val -> _OB_copyFrom(o -> d);
                OBObjAny* no = new OBObjAny;
                no -> b = CORBA_Object::_duplicate(o -> b);
                no -> d = val;
                ((CORBA_Any&)any).replace(_tc_bisupClientInterface, no, true);
            }
        }
        else
            val = bisupClientInterface::_nil();

        return true;
    }
    else
        return false;
}

//
// IDL:bisupClientInterface/start:1.0
//
void
bisupClientInterface::start(CORBA_Long _ob_a0)
{
    if(CORBA_is_nil(_ob_clt_))
        throw CORBA_NO_IMPLEMENT();

    CORBA_ULong _ob_off = _ob_clt_ -> offset(this, "start");
    CORBA_ULong _ob_cnt = _ob_off;
    OBMarshalCount(_ob_a0, _ob_cnt);

    OBBuffer _ob_buf(_ob_cnt);
    CORBA_Octet* _ob_o = _ob_buf.data + _ob_off;
    OBMarshal(_ob_a0, _ob_o);

    bool _ob_sw, _ob_ex, _ob_fo;
    _ob_off = _ob_clt_ -> request(this, "start", _ob_buf, _ob_sw, _ob_ex, _ob_fo, _ob_tout_);

    if(_ob_fo)
    {
        const CORBA_Octet* _ob_co = _ob_buf.data + _ob_off;
        _OB_forward(_ob_co, _ob_sw);
        start(_ob_a0);
        return;
    }

    if(_ob_ex)
        throw CORBA_UNKNOWN();
}

//
// OBFixSeq< CORBA_Short >
//
#ifdef OB_use_OBFixSeq_CORBA__Short_from_bisupclient_h

static OBTypeCodeConst _tc_OBFixSeq_CORBA__Short(
"01000000130000000c000000010000000200000000000000"
);

#ifndef HAVE_NO_EXPLICIT_TEMPLATES
template class OBInfo< OBFixSeq< CORBA_Short > >;
#else
#ifdef HAVE_PRAGMA_DEFINE
#pragma define(OBInfo< OBFixSeq< CORBA_Short > >)
#endif
#endif

void
operator<<=(CORBA_Any& any, OBFixSeq< CORBA_Short >* p)
{
    static const OBInfo< OBFixSeq< CORBA_Short > > info;
    any.replace(_tc_OBFixSeq_CORBA__Short, p, true, &info);
}

void
operator<<=(CORBA_Any& any, const OBFixSeq< CORBA_Short >& seq)
{
    static const OBInfo< OBFixSeq< CORBA_Short > > info;
    OBFixSeq< CORBA_Short >* p = new OBFixSeq< CORBA_Short >(seq);
    any.replace(_tc_OBFixSeq_CORBA__Short, p, true, &info);
}

CORBA_Boolean
operator>>=(const CORBA_Any& any, OBFixSeq< CORBA_Short >*& p)
{
    if(any.check_type(_tc_OBFixSeq_CORBA__Short))
    {
        if(!any.info())
        {
            const OBBuffer* bufp = (const OBBuffer*)any.value();
            const CORBA_Octet* coct = bufp -> data;
            OBFixSeq< CORBA_Short >* v = new OBFixSeq< CORBA_Short >;
            OBUnmarshal(*v, coct, false);
            (CORBA_Any&)any <<= v;
        }

        p = (OBFixSeq< CORBA_Short >*)any.value();
        return true;
    }
    else
        return false;
}

#endif
