// **********************************************************************
//
// Generated by the OmniBroker IDL-to-C++ Translator
//
// Copyright (c) 1997
// Object-Oriented Concepts, Inc.
// Billerica, MA, USA
//
// All Rights Reserved
//
// **********************************************************************

#include <OB/CORBA.h>
#include <OB/TemplateI.h>
#include "msg.h"

//
// IDL:otMessage:1.0
//
#ifndef HAVE_NO_EXPLICIT_TEMPLATES
template class OBObjVar< otMessage >;
template class OBObjForSeq< otMessage >;
#endif

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

        if(v)
            return _duplicate((otMessage_ptr)v);

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

    return _nil();
}

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

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

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

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

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

const OBTypeCodeConst _tc_otMessage(
"010000000E0000002A000000010000001200000049444C3A6F744D6573736167653A312E30000"
"0000A0000006F744D65737361676500"
);

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

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

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

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

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

        return true;
    }
    else
        return false;
}

//
// IDL:otMessage/ElementKind:1.0
//
const OBTypeCodeConst otMessage::_tc_ElementKind(
"0100000011000000BB000000010000001E00000049444C3A6F744D6573736167652F456C656D6"
"56E744B696E643A312E300000000C000000456C656D656E744B696E6400080000000D00000042"
"65674F66456C656D656E74000000000D000000456E644F66456C656D656E74000000000800000"
"0496E74656765720008000000426F6F6C65616E000A000000426974537472696E670000000A00"
"0000486578537472696E670000000C0000004F63746574537472696E67000B000000436861725"
"37472696E6700"
);

void
operator<<=(CORBA_Any& any, otMessage::ElementKind val)
{
    any.replace(otMessage::_tc_ElementKind, new CORBA_ULong((CORBA_ULong)val), true);
}

CORBA_Boolean
operator>>=(const CORBA_Any& any, otMessage::ElementKind& val)
{
    if(any.check_type(otMessage::_tc_ElementKind))
    {
        val = (otMessage::ElementKind)(*(CORBA_ULong*)any.value());
        return true;
    }
    else
        return false;
}

//
// IDL:otMessage/Element:1.0
//
#ifndef HAVE_NO_EXPLICIT_TEMPLATES
template class OBVarVar< otMessage::Element >;
#endif

#ifdef OB_CLEAR_MEM
otMessage::Element::Element()
{
    memset(&kind, 0, sizeof(kind));
    memset(&number, 0, sizeof(number));
}
#endif

otMessage::Element::Element(const otMessage::Element& val)
    : kind(val.kind),
      identifier(val.identifier),
      value(val.value),
      number(val.number)
{
}

otMessage::Element&
otMessage::Element::operator=(const Element& val)
{
    if(this != &val)
    {
        kind = val.kind;
        identifier = val.identifier;
        value = val.value;
        number = val.number;
    }
    return *this;
}

void
OBMarshal(const otMessage::Element& val, CORBA_Octet*& oct)
{
    OBMarshal(val.kind, oct);
    OBMarshal(val.identifier.in(), oct);
    OBMarshal(val.value.in(), oct);
    OBMarshal(val.number, oct);
}

void
OBMarshalCount(const otMessage::Element& val, CORBA_ULong& count)
{
    OBMarshalCount(val.kind, count);
    OBMarshalCount(val.identifier.in(), count);
    OBMarshalCount(val.value.in(), count);
    OBMarshalCount(val.number, count);
}

void
OBUnmarshal(otMessage::Element& val, const CORBA_Octet*& coct, bool swap)
{
    OBUnmarshal(val.kind, coct, swap);
    OBUnmarshal(val.identifier.inout(), coct, swap);
    OBUnmarshal(val.value.inout(), coct, swap);
    OBUnmarshal(val.number, coct, swap);
}

const OBTypeCodeConst otMessage::_tc_Element(
"010000000F00000040010000010000001A00000049444C3A6F744D6573736167652F456C656D6"
"56E743A312E3000000008000000456C656D656E740004000000050000006B696E640000000011"
"000000BB000000010000001E00000049444C3A6F744D6573736167652F456C656D656E744B696"
"E643A312E300000000C000000456C656D656E744B696E6400080000000D0000004265674F6645"
"6C656D656E74000000000D000000456E644F66456C656D656E740000000008000000496E74656"
"765720008000000426F6F6C65616E000A000000426974537472696E670000000A000000486578"
"537472696E670000000C0000004F63746574537472696E67000B00000043686172537472696E6"
"700000B0000006964656E746966696572000012000000000000000600000076616C7565000000"
"1200000000000000070000006E756D626572000003000000"
);

#ifndef HAVE_NO_EXPLICIT_TEMPLATES
template class OBInfo< otMessage::Element >;
#endif

void
operator<<=(CORBA_Any& any, otMessage::Element* p)
{
    static const OBInfo< otMessage::Element > info;
    any.replace(otMessage::_tc_Element, p, true, &info);
}

void
operator<<=(CORBA_Any& any, const otMessage::Element& val)
{
    otMessage::Element* p = new otMessage::Element(val);
    static const OBInfo< otMessage::Element > info;
    any.replace(otMessage::_tc_Element, p, true, &info);
}

CORBA_Boolean
operator>>=(const CORBA_Any& any, otMessage::Element*& p)
{
    if(any.check_type(otMessage::_tc_Element))
    {
        if(!any.info())
        {
            const CORBA_Octet* coct = (CORBA_Octet*)any.value() + 4;
            otMessage::Element* v = new otMessage::Element;
            OBUnmarshal(*v, coct, false);
            (CORBA_Any&)any <<= v;
        }

        p = (otMessage::Element*)any.value();
        return true;
    }
    else
        return false;
}

//
// IDL:otMessage/SerializedMessage:1.0
//
const OBTypeCodeConst otMessage::_tc_SerializedMessage(
"01000000150000009C010000010000002400000049444C3A6F744D6573736167652F536572696"
"16C697A65644D6573736167653A312E30001200000053657269616C697A65644D657373616765"
"0000001300000050010000010000000F00000040010000010000001A00000049444C3A6F744D6"
"573736167652F456C656D656E743A312E3000000008000000456C656D656E7400040000000500"
"00006B696E640000000011000000BB000000010000001E00000049444C3A6F744D65737361676"
"52F456C656D656E744B696E643A312E300000000C000000456C656D656E744B696E6400080000"
"000D0000004265674F66456C656D656E74000000000D000000456E644F66456C656D656E74000"
"0000008000000496E74656765720008000000426F6F6C65616E000A000000426974537472696E"
"670000000A000000486578537472696E670000000C0000004F63746574537472696E67000B000"
"00043686172537472696E6700000B0000006964656E7469666965720000120000000000000006"
"00000076616C75650000001200000000000000070000006E756D6265720000030000000000000"
"0"
);

//
// IDL:otMessage/ParameterList:1.0
//
const OBTypeCodeConst otMessage::_tc_ParameterList(
"0100000015000000F0010000010000002000000049444C3A6F744D6573736167652F506172616"
"D657465724C6973743A312E30000E000000506172616D657465724C69737400000013000000AC"
"01000001000000150000009C010000010000002400000049444C3A6F744D6573736167652F536"
"57269616C697A65644D6573736167653A312E30001200000053657269616C697A65644D657373"
"6167650000001300000050010000010000000F00000040010000010000001A00000049444C3A6"
"F744D6573736167652F456C656D656E743A312E3000000008000000456C656D656E7400040000"
"00050000006B696E640000000011000000BB000000010000001E00000049444C3A6F744D65737"
"36167652F456C656D656E744B696E643A312E300000000C000000456C656D656E744B696E6400"
"080000000D0000004265674F66456C656D656E74000000000D000000456E644F66456C656D656"
"E740000000008000000496E74656765720008000000426F6F6C65616E000A0000004269745374"
"72696E670000000A000000486578537472696E670000000C0000004F63746574537472696E670"
"00B00000043686172537472696E6700000B0000006964656E7469666965720000120000000000"
"00000600000076616C75650000001200000000000000070000006E756D6265720000030000000"
"000000000000000"
);

//
// IDL:otMessage/MessageList:1.0
//
const OBTypeCodeConst otMessage::_tc_MessageList(
"010000001500000050000000010000001E00000049444C3A6F744D6573736167652F4D6573736"
"167654C6973743A312E300000000C0000004D6573736167654C69737400130000001000000001"
"000000120000000000000000000000"
);

//
// IDL:otMessage/AlreadyConnected:1.0
//
otMessage::AlreadyConnected::AlreadyConnected(const otMessage::AlreadyConnected& val)
    : CORBA_UserException(val)
{
}

otMessage::AlreadyConnected&
otMessage::AlreadyConnected::operator=(const AlreadyConnected&)
{
    return *this;
}

otMessage::AlreadyConnected*
otMessage::AlreadyConnected::_narrow(CORBA_Exception* p)
{
#ifdef HAVE_NO_RTTI
    if(p)
        return (AlreadyConnected*)(p -> _OB_narrowHelp("IDL:otMessage/AlreadyConnected:1.0"));
    else
        return 0;
#else
    return dynamic_cast<otMessage::AlreadyConnected*>(p);
#endif
}

#ifdef HAVE_NO_RTTI
void*
otMessage::AlreadyConnected::_OB_narrowHelp(const char* _ob_id) const
{
    if(strcmp("IDL:otMessage/AlreadyConnected:1.0", _ob_id) == 0)
        return (void*)this;
    else
        return CORBA_UserException::_OB_narrowHelp(_ob_id);
}
#endif

const char*
otMessage::AlreadyConnected::_OB_typeId() const
{
    return "IDL:otMessage/AlreadyConnected:1.0";
}

CORBA_Exception*
otMessage::AlreadyConnected::_OB_clone() const
{
    return new AlreadyConnected(*this);
}

void
OBMarshal(const otMessage::AlreadyConnected&, CORBA_Octet*& oct)
{
    OBMarshal("IDL:otMessage/AlreadyConnected:1.0", oct);
}

void
OBMarshalCount(const otMessage::AlreadyConnected&, CORBA_ULong& count)
{
    OBMarshalCount("IDL:otMessage/AlreadyConnected:1.0", count);
}

void
OBUnmarshal(otMessage::AlreadyConnected&, const CORBA_Octet*& coct, bool swap)
{
    CORBA_String_var id;
    OBUnmarshal(id.inout(), coct, swap);
    assert(strcmp(id, "IDL:otMessage/AlreadyConnected:1.0") == 0);
}

const OBTypeCodeConst otMessage::_tc_AlreadyConnected(
"010000001600000048000000010000002300000049444C3A6F744D6573736167652F416C72656"
"16479436F6E6E65637465643A312E30000011000000416C7265616479436F6E6E656374656400"
"00000000000000"
);

#ifndef HAVE_NO_EXPLICIT_TEMPLATES
template class OBInfo< otMessage::AlreadyConnected >;
#endif

void
operator<<=(CORBA_Any& any, otMessage::AlreadyConnected* p)
{
    static const OBInfo< otMessage::AlreadyConnected > info;
    any.replace(otMessage::_tc_AlreadyConnected, p, true, &info);
}

void
operator<<=(CORBA_Any& any, const otMessage::AlreadyConnected& val)
{
    otMessage::AlreadyConnected* p = new otMessage::AlreadyConnected(val);
    static const OBInfo< otMessage::AlreadyConnected > info;
    any.replace(otMessage::_tc_AlreadyConnected, p, true, &info);
}

CORBA_Boolean
operator>>=(const CORBA_Any& any, otMessage::AlreadyConnected*& p)
{
    if(any.check_type(otMessage::_tc_AlreadyConnected))
    {
        if(!any.info())
        {
            const CORBA_Octet* coct = (CORBA_Octet*)any.value() + 4;
            otMessage::AlreadyConnected* v = new otMessage::AlreadyConnected;
            OBUnmarshal(*v, coct, false);
            (CORBA_Any&)any <<= v;
        }

        p = (otMessage::AlreadyConnected*)any.value();
        return true;
    }
    else
        return false;
}

//
// IDL:otMessage/NotImplemented:1.0
//
otMessage::NotImplemented::NotImplemented(const otMessage::NotImplemented& val)
    : CORBA_UserException(val)
{
}

otMessage::NotImplemented&
otMessage::NotImplemented::operator=(const NotImplemented&)
{
    return *this;
}

otMessage::NotImplemented*
otMessage::NotImplemented::_narrow(CORBA_Exception* p)
{
#ifdef HAVE_NO_RTTI
    if(p)
        return (NotImplemented*)(p -> _OB_narrowHelp("IDL:otMessage/NotImplemented:1.0"));
    else
        return 0;
#else
    return dynamic_cast<otMessage::NotImplemented*>(p);
#endif
}

#ifdef HAVE_NO_RTTI
void*
otMessage::NotImplemented::_OB_narrowHelp(const char* _ob_id) const
{
    if(strcmp("IDL:otMessage/NotImplemented:1.0", _ob_id) == 0)
        return (void*)this;
    else
        return CORBA_UserException::_OB_narrowHelp(_ob_id);
}
#endif

const char*
otMessage::NotImplemented::_OB_typeId() const
{
    return "IDL:otMessage/NotImplemented:1.0";
}

CORBA_Exception*
otMessage::NotImplemented::_OB_clone() const
{
    return new NotImplemented(*this);
}

void
OBMarshal(const otMessage::NotImplemented&, CORBA_Octet*& oct)
{
    OBMarshal("IDL:otMessage/NotImplemented:1.0", oct);
}

void
OBMarshalCount(const otMessage::NotImplemented&, CORBA_ULong& count)
{
    OBMarshalCount("IDL:otMessage/NotImplemented:1.0", count);
}

void
OBUnmarshal(otMessage::NotImplemented&, const CORBA_Octet*& coct, bool swap)
{
    CORBA_String_var id;
    OBUnmarshal(id.inout(), coct, swap);
    assert(strcmp(id, "IDL:otMessage/NotImplemented:1.0") == 0);
}

const OBTypeCodeConst otMessage::_tc_NotImplemented(
"010000001600000044000000010000002100000049444C3A6F744D6573736167652F4E6F74496"
"D706C656D656E7465643A312E30000000000F0000004E6F74496D706C656D656E746564000000"
"000000"
);

#ifndef HAVE_NO_EXPLICIT_TEMPLATES
template class OBInfo< otMessage::NotImplemented >;
#endif

void
operator<<=(CORBA_Any& any, otMessage::NotImplemented* p)
{
    static const OBInfo< otMessage::NotImplemented > info;
    any.replace(otMessage::_tc_NotImplemented, p, true, &info);
}

void
operator<<=(CORBA_Any& any, const otMessage::NotImplemented& val)
{
    otMessage::NotImplemented* p = new otMessage::NotImplemented(val);
    static const OBInfo< otMessage::NotImplemented > info;
    any.replace(otMessage::_tc_NotImplemented, p, true, &info);
}

CORBA_Boolean
operator>>=(const CORBA_Any& any, otMessage::NotImplemented*& p)
{
    if(any.check_type(otMessage::_tc_NotImplemented))
    {
        if(!any.info())
        {
            const CORBA_Octet* coct = (CORBA_Octet*)any.value() + 4;
            otMessage::NotImplemented* v = new otMessage::NotImplemented;
            OBUnmarshal(*v, coct, false);
            (CORBA_Any&)any <<= v;
        }

        p = (otMessage::NotImplemented*)any.value();
        return true;
    }
    else
        return false;
}

//
// IDL:otMessage/DecodeError:1.0
//
otMessage::DecodeError::DecodeError(const otMessage::DecodeError& val)
    : CORBA_UserException(val)
{
}

otMessage::DecodeError&
otMessage::DecodeError::operator=(const DecodeError&)
{
    return *this;
}

otMessage::DecodeError*
otMessage::DecodeError::_narrow(CORBA_Exception* p)
{
#ifdef HAVE_NO_RTTI
    if(p)
        return (DecodeError*)(p -> _OB_narrowHelp("IDL:otMessage/DecodeError:1.0"));
    else
        return 0;
#else
    return dynamic_cast<otMessage::DecodeError*>(p);
#endif
}

#ifdef HAVE_NO_RTTI
void*
otMessage::DecodeError::_OB_narrowHelp(const char* _ob_id) const
{
    if(strcmp("IDL:otMessage/DecodeError:1.0", _ob_id) == 0)
        return (void*)this;
    else
        return CORBA_UserException::_OB_narrowHelp(_ob_id);
}
#endif

const char*
otMessage::DecodeError::_OB_typeId() const
{
    return "IDL:otMessage/DecodeError:1.0";
}

CORBA_Exception*
otMessage::DecodeError::_OB_clone() const
{
    return new DecodeError(*this);
}

void
OBMarshal(const otMessage::DecodeError&, CORBA_Octet*& oct)
{
    OBMarshal("IDL:otMessage/DecodeError:1.0", oct);
}

void
OBMarshalCount(const otMessage::DecodeError&, CORBA_ULong& count)
{
    OBMarshalCount("IDL:otMessage/DecodeError:1.0", count);
}

void
OBUnmarshal(otMessage::DecodeError&, const CORBA_Octet*& coct, bool swap)
{
    CORBA_String_var id;
    OBUnmarshal(id.inout(), coct, swap);
    assert(strcmp(id, "IDL:otMessage/DecodeError:1.0") == 0);
}

const OBTypeCodeConst otMessage::_tc_DecodeError(
"01000000160000003C000000010000001E00000049444C3A6F744D6573736167652F4465636F6"
"4654572726F723A312E300000000C0000004465636F64654572726F720000000000"
);

#ifndef HAVE_NO_EXPLICIT_TEMPLATES
template class OBInfo< otMessage::DecodeError >;
#endif

void
operator<<=(CORBA_Any& any, otMessage::DecodeError* p)
{
    static const OBInfo< otMessage::DecodeError > info;
    any.replace(otMessage::_tc_DecodeError, p, true, &info);
}

void
operator<<=(CORBA_Any& any, const otMessage::DecodeError& val)
{
    otMessage::DecodeError* p = new otMessage::DecodeError(val);
    static const OBInfo< otMessage::DecodeError > info;
    any.replace(otMessage::_tc_DecodeError, p, true, &info);
}

CORBA_Boolean
operator>>=(const CORBA_Any& any, otMessage::DecodeError*& p)
{
    if(any.check_type(otMessage::_tc_DecodeError))
    {
        if(!any.info())
        {
            const CORBA_Octet* coct = (CORBA_Octet*)any.value() + 4;
            otMessage::DecodeError* v = new otMessage::DecodeError;
            OBUnmarshal(*v, coct, false);
            (CORBA_Any&)any <<= v;
        }

        p = (otMessage::DecodeError*)any.value();
        return true;
    }
    else
        return false;
}

//
// IDL:otMessage/send:1.0
//
void
otMessage::send(const char* _ob_a0,
                const SerializedMessage& _ob_a1)
{
    if(CORBA_is_nil(_ob_con_))
        throw CORBA_NO_IMPLEMENT();

    CORBA_ULong _ob_off = _ob_con_ -> offset(this, "send");
    CORBA_ULong _ob_cnt = _ob_off;
    OBMarshalCount(_ob_a0, _ob_cnt);
    OBMarshalCount(_ob_a1, _ob_cnt);

    OBFixSeq< CORBA_Octet > _ob_seq(_ob_cnt);
    _ob_seq.length(_ob_cnt);
#ifdef OB_CLEAR_MEM
    memset(_ob_seq.data(), 0, _ob_seq.length());
#endif
    CORBA_Octet* _ob_o = _ob_seq.data() + _ob_off;
    OBMarshal(_ob_a0, _ob_o);
    OBMarshal(_ob_a1, _ob_o);

    bool _ob_sw, _ob_ex, _ob_fo;
    _ob_off = _ob_con_ -> request(this, "send", _ob_seq, _ob_sw, _ob_ex, _ob_fo, _ob_tout_);

    const CORBA_Octet* _ob_co = _ob_seq.data() + _ob_off;

    if(_ob_fo)
    {
        _OB_forward(_ob_co, _ob_sw);
        send(_ob_a0, _ob_a1);
        return;
    }

    if(_ob_ex)
    {
        CORBA_String_var _ob_id;
        const CORBA_Octet* _ob_coid = _ob_co;
        OBUnmarshal(_ob_id.inout(), _ob_coid, _ob_sw);

        if(strcmp(_ob_id, "IDL:otMessage/NotImplemented:1.0") == 0)
        {
            NotImplemented _ob_except;
            OBUnmarshal(_ob_except, _ob_co, _ob_sw);

            throw _ob_except;
        }
        else if(strcmp(_ob_id, "IDL:otMessage/DecodeError:1.0") == 0)
        {
            DecodeError _ob_except;
            OBUnmarshal(_ob_except, _ob_co, _ob_sw);

            throw _ob_except;
        }
        else
            throw CORBA_UNKNOWN();
    }
}

//
// IDL:otMessage/sendTwoWay:1.0
//
otMessage::SerializedMessage*
otMessage::sendTwoWay(const char* _ob_a0,
                      const ParameterList& _ob_a1)
{
    if(CORBA_is_nil(_ob_con_))
        throw CORBA_NO_IMPLEMENT();

    CORBA_ULong _ob_off = _ob_con_ -> offset(this, "sendTwoWay");
    CORBA_ULong _ob_cnt = _ob_off;
    OBMarshalCount(_ob_a0, _ob_cnt);
    OBMarshalCount(_ob_a1, _ob_cnt);

    OBFixSeq< CORBA_Octet > _ob_seq(_ob_cnt);
    _ob_seq.length(_ob_cnt);
#ifdef OB_CLEAR_MEM
    memset(_ob_seq.data(), 0, _ob_seq.length());
#endif
    CORBA_Octet* _ob_o = _ob_seq.data() + _ob_off;
    OBMarshal(_ob_a0, _ob_o);
    OBMarshal(_ob_a1, _ob_o);

    bool _ob_sw, _ob_ex, _ob_fo;
    _ob_off = _ob_con_ -> request(this, "sendTwoWay", _ob_seq, _ob_sw, _ob_ex, _ob_fo, _ob_tout_);

    const CORBA_Octet* _ob_co = _ob_seq.data() + _ob_off;

    if(_ob_fo)
    {
        _OB_forward(_ob_co, _ob_sw);
        return sendTwoWay(_ob_a0, _ob_a1);
    }

    if(_ob_ex)
    {
        CORBA_String_var _ob_id;
        const CORBA_Octet* _ob_coid = _ob_co;
        OBUnmarshal(_ob_id.inout(), _ob_coid, _ob_sw);

        if(strcmp(_ob_id, "IDL:otMessage/NotImplemented:1.0") == 0)
        {
            NotImplemented _ob_except;
            OBUnmarshal(_ob_except, _ob_co, _ob_sw);

            throw _ob_except;
        }
        else if(strcmp(_ob_id, "IDL:otMessage/DecodeError:1.0") == 0)
        {
            DecodeError _ob_except;
            OBUnmarshal(_ob_except, _ob_co, _ob_sw);

            throw _ob_except;
        }
        else
            throw CORBA_UNKNOWN();
    }

    SerializedMessage* _ob_r = new SerializedMessage;
    OBUnmarshal(*_ob_r, _ob_co, _ob_sw);
    return _ob_r;
}

//
// OBVarSeq< otMessage::Element >
//
#ifdef OB_use_OBVarSeq_otMessage_Element_from_msg_h

#ifndef HAVE_NO_EXPLICIT_TEMPLATES
template class OBVarSeq< otMessage::Element >;
template class OBSeqVar< OBVarSeq< otMessage::Element > >;
#endif

void
OBMarshal(const OBVarSeq< otMessage::Element >& seq, CORBA_Octet*& oct)
{
    OBMarshal(seq.length(), oct);
    for(CORBA_ULong i = 0 ; i < seq.length() ; i++)
        OBMarshal(seq[i], oct);
}

void
OBMarshalCount(const OBVarSeq< otMessage::Element >& seq, CORBA_ULong& count)
{
    OBMarshalCount(seq.length(), count);
    for(CORBA_ULong i = 0 ; i < seq.length() ; i++)
        OBMarshalCount(seq[i], count);
}

void
OBUnmarshal(OBVarSeq< otMessage::Element >& seq, const CORBA_Octet*& coct, bool swap)
{
    CORBA_ULong len;
    OBUnmarshal(len, coct, swap);
    seq.length(len);
    for(CORBA_ULong i = 0 ; i < len ; i++)
        OBUnmarshal(seq[i], coct, swap);
}

static const OBTypeCodeConst _tc_OBVarSeq_otMessage_Element(
"010000001300000050010000010000000F00000040010000010000001A00000049444C3A6F744"
"D6573736167652F456C656D656E743A312E3000000008000000456C656D656E74000400000005"
"0000006B696E640000000011000000BB000000010000001E00000049444C3A6F744D657373616"
"7652F456C656D656E744B696E643A312E300000000C000000456C656D656E744B696E64000800"
"00000D0000004265674F66456C656D656E74000000000D000000456E644F66456C656D656E740"
"000000008000000496E74656765720008000000426F6F6C65616E000A00000042697453747269"
"6E670000000A000000486578537472696E670000000C0000004F63746574537472696E67000B0"
"0000043686172537472696E6700000B0000006964656E74696669657200001200000000000000"
"0600000076616C75650000001200000000000000070000006E756D62657200000300000000000"
"000"
);

#ifndef HAVE_NO_EXPLICIT_TEMPLATES
template class OBInfo< OBVarSeq< otMessage::Element > >;
#endif

void
operator<<=(CORBA_Any& any, OBVarSeq< otMessage::Element >* p)
{
    static const OBInfo< OBVarSeq< otMessage::Element > > info;
    any.replace(_tc_OBVarSeq_otMessage_Element, p, true, &info);
}

void
operator<<=(CORBA_Any& any, const OBVarSeq< otMessage::Element >& seq)
{
    static const OBInfo< OBVarSeq< otMessage::Element > > info;
    OBVarSeq< otMessage::Element >* p = new OBVarSeq< otMessage::Element >(seq);
    any.replace(_tc_OBVarSeq_otMessage_Element, p, true, &info);
}

CORBA_Boolean
operator>>=(const CORBA_Any& any, OBVarSeq< otMessage::Element >*& p)
{
    if(any.check_type(_tc_OBVarSeq_otMessage_Element))
    {
        if(!any.info())
        {
            const CORBA_Octet* coct = (CORBA_Octet*)any.value() + 4;
            OBVarSeq< otMessage::Element >* v = new OBVarSeq< otMessage::Element >;
            OBUnmarshal(*v, coct, false);
            (CORBA_Any&)any <<= v;
        }

        p = (OBVarSeq< otMessage::Element >*)any.value();
        return true;
    }
    else
        return false;
}

#endif

//
// OBVarSeq< OBVarSeq< otMessage::Element > >
//
#ifdef OB_use_OBVarSeq_OBVarSeq_otMessage_Element_from_msg_h

#ifndef HAVE_NO_EXPLICIT_TEMPLATES
template class OBVarSeq< OBVarSeq< otMessage::Element > >;
template class OBSeqVar< OBVarSeq< OBVarSeq< otMessage::Element > > >;
#endif

void
OBMarshal(const OBVarSeq< OBVarSeq< otMessage::Element > >& seq, CORBA_Octet*& oct)
{
    OBMarshal(seq.length(), oct);
    for(CORBA_ULong i = 0 ; i < seq.length() ; i++)
        OBMarshal(seq[i], oct);
}

void
OBMarshalCount(const OBVarSeq< OBVarSeq< otMessage::Element > >& seq, CORBA_ULong& count)
{
    OBMarshalCount(seq.length(), count);
    for(CORBA_ULong i = 0 ; i < seq.length() ; i++)
        OBMarshalCount(seq[i], count);
}

void
OBUnmarshal(OBVarSeq< OBVarSeq< otMessage::Element > >& seq, const CORBA_Octet*& coct, bool swap)
{
    CORBA_ULong len;
    OBUnmarshal(len, coct, swap);
    seq.length(len);
    for(CORBA_ULong i = 0 ; i < len ; i++)
        OBUnmarshal(seq[i], coct, swap);
}

static const OBTypeCodeConst _tc_OBVarSeq_OBVarSeq_otMessage_Element(
"0100000013000000AC01000001000000150000009C010000010000002400000049444C3A6F744"
"D6573736167652F53657269616C697A65644D6573736167653A312E3000120000005365726961"
"6C697A65644D6573736167650000001300000050010000010000000F000000400100000100000"
"01A00000049444C3A6F744D6573736167652F456C656D656E743A312E3000000008000000456C"
"656D656E740004000000050000006B696E640000000011000000BB000000010000001E0000004"
"9444C3A6F744D6573736167652F456C656D656E744B696E643A312E300000000C000000456C65"
"6D656E744B696E6400080000000D0000004265674F66456C656D656E74000000000D000000456"
"E644F66456C656D656E740000000008000000496E74656765720008000000426F6F6C65616E00"
"0A000000426974537472696E670000000A000000486578537472696E670000000C0000004F637"
"46574537472696E67000B00000043686172537472696E6700000B0000006964656E7469666965"
"72000012000000000000000600000076616C75650000001200000000000000070000006E756D6"
"265720000030000000000000000000000"
);

#ifndef HAVE_NO_EXPLICIT_TEMPLATES
template class OBInfo< OBVarSeq< OBVarSeq< otMessage::Element > > >;
#endif

void
operator<<=(CORBA_Any& any, OBVarSeq< OBVarSeq< otMessage::Element > >* p)
{
    static const OBInfo< OBVarSeq< OBVarSeq< otMessage::Element > > > info;
    any.replace(_tc_OBVarSeq_OBVarSeq_otMessage_Element, p, true, &info);
}

void
operator<<=(CORBA_Any& any, const OBVarSeq< OBVarSeq< otMessage::Element > >& seq)
{
    static const OBInfo< OBVarSeq< OBVarSeq< otMessage::Element > > > info;
    OBVarSeq< OBVarSeq< otMessage::Element > >* p = new OBVarSeq< OBVarSeq< otMessage::Element > >(seq);
    any.replace(_tc_OBVarSeq_OBVarSeq_otMessage_Element, p, true, &info);
}

CORBA_Boolean
operator>>=(const CORBA_Any& any, OBVarSeq< OBVarSeq< otMessage::Element > >*& p)
{
    if(any.check_type(_tc_OBVarSeq_OBVarSeq_otMessage_Element))
    {
        if(!any.info())
        {
            const CORBA_Octet* coct = (CORBA_Octet*)any.value() + 4;
            OBVarSeq< OBVarSeq< otMessage::Element > >* v = new OBVarSeq< OBVarSeq< otMessage::Element > >;
            OBUnmarshal(*v, coct, false);
            (CORBA_Any&)any <<= v;
        }

        p = (OBVarSeq< OBVarSeq< otMessage::Element > >*)any.value();
        return true;
    }
    else
        return false;
}

#endif

//
// OBStrSeq
//
#ifdef OB_use_OBStrSeq_from_msg_h

static const OBTypeCodeConst _tc_OBStrSeq(
"01000000130000001000000001000000120000000000000000000000"
);

#ifndef HAVE_NO_EXPLICIT_TEMPLATES
template class OBInfo< OBStrSeq >;
#endif

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

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

CORBA_Boolean
operator>>=(const CORBA_Any& any, OBStrSeq*& p)
{
    if(any.check_type(_tc_OBStrSeq))
    {
        if(!any.info())
        {
            const CORBA_Octet* coct = (CORBA_Octet*)any.value() + 4;
            OBStrSeq* v = new OBStrSeq;
            OBUnmarshal(*v, coct, false);
            (CORBA_Any&)any <<= v;
        }

        p = (OBStrSeq*)any.value();
        return true;
    }
    else
        return false;
}

#endif
