// **********************************************************************
//
// 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 <hello.h>

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

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

        if(v)
            return _duplicate((Hello_ptr)v);

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

    return _nil();
}

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

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

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

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

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

const OBTypeCodeConst _tc_Hello(
"010000000E00000022000000010000000E00000049444C3A48656C6C6F3A312E3000000006000"
"00048656C6C6F00"
);

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

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

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

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

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

        return true;
    }
    else
        return false;
}

//
// IDL:Hello/hello:1.0
//
void
Hello::hello()
{
    if(CORBA_is_nil(_ob_con_))
        throw CORBA_NO_IMPLEMENT();

    CORBA_ULong _ob_off = _ob_con_ -> offset(this, "hello");
    CORBA_ULong _ob_cnt = _ob_off;

    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

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

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

    if(_ob_ex)
        throw CORBA_UNKNOWN();
}

