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

// Version: 4.0.1
// License: non-commercial

#include 
#include 

#ifndef OB_INTEGER_VERSION
#   error No ORBacus version defined!
#endif

#ifndef OB_NO_VERSION_CHECK
#   if (OB_INTEGER_VERSION != 4000100L)
#       error ORBacus version mismatch!
#   endif
#endif

OB::TypeCodeConst _tc_ProcessHitsCollection(
"010102080e00000042000000012e302e1e00000049444c3a50726f6365737348697473436f6c6"
"c656374696f6e3a312e3000babe1600000050726f6365737348697473436f6c6c656374696f6e"
"00"
);

OB::TypeCodeConst ProcessHitsCollection::_tc_Hit(
"010102080f00000088000000012e302e2200000049444c3a50726f6365737348697473436f6c6"
"c656374696f6e2f4869743a312e30003460040000004869740004000000080000004564657041"
"627300070000000f000000547261636b4c656e677468416273000007000000080000004564657"
"047617000070000000f000000547261636b4c656e677468476170000007000000"
);

OB::TypeCodeConst ProcessHitsCollection::_tc_HitsCollection(
"011d100815000000ec000000010b17402d00000049444c3a50726f6365737348697473436f6c6"
"c656374696f6e2f48697473436f6c6c656374696f6e3a312e30000000000f0000004869747343"
"6f6c6c656374696f6e00081300000098000000010000000f00000088000000010001052200000"
"049444c3a50726f6365737348697473436f6c6c656374696f6e2f4869743a312e300000000400"
"00004869740004000000080000004564657041627300070000000f000000547261636b4c656e6"
"77468416273000007000000080000004564657047617000070000000f000000547261636b4c65"
"6e67746847617000000700000000000000"
);

//
// IDL:ProcessHitsCollection:1.0
//
const char* ProcessHitsCollection::ids_[] =
{
    "IDL:ProcessHitsCollection:1.0",
    0
};

OB::MarshalStubImpl_ptr
ProcessHitsCollection::_OB_createMarshalStubImpl()
{
    return new OBMarshalStubImpl_ProcessHitsCollection;
}

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

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

ProcessHitsCollection_ptr
ProcessHitsCollection::_narrow(CORBA::Object_ptr p)
{
    if(!CORBA::is_nil(p))
    {
        ProcessHitsCollection_ptr v = dynamic_cast(p)
;
        if(v)
            return _duplicate(v);

        if(p -> _is_a(ids_[0]))
        {
            ProcessHitsCollection_ptr val = new ProcessHitsCollection;
            val -> _OB_copyFrom(p);
            return val;
        }
    }

    return _nil();
}

ProcessHitsCollection_ptr
ProcessHitsCollection::_narrow(CORBA::AbstractBase_ptr p)
{
    if(!CORBA::is_nil(p))
    {
        CORBA::Object_var obj = p -> _to_object();
        return _narrow(obj);
    }
    return _nil();
}

const char**
ProcessHitsCollection::_OB_ids() const
{
    return ids_;
}

const char**
ProcessHitsCollection::_OB_staticIds()
{
    return ids_;
}

void
OBMarshal(ProcessHitsCollection_ptr _ob_v, OB::OutputStreamImpl* _ob_out)
{
    _ob_out -> write_Object(_ob_v);
}

void
OBUnmarshal(ProcessHitsCollection_ptr& _ob_v, OB::InputStreamImpl* _ob_in)
{
    ProcessHitsCollection_var old = _ob_v;
    CORBA::Object_var p = _ob_in -> read_Object();

    if(!CORBA::is_nil(p))
    {
        _ob_v = new ProcessHitsCollection;
        _ob_v -> _OB_copyFrom(p);
    }
    else
        _ob_v = ProcessHitsCollection::_nil();
}

void
operator<<=(CORBA::Any& any, ProcessHitsCollection_ptr* v)
{
    any.replace(_tc_ProcessHitsCollection, (CORBA::Object_ptr)*v, true);
}

void
operator<<=(CORBA::Any& any, ProcessHitsCollection_ptr v)
{
    ProcessHitsCollection_ptr val = ProcessHitsCollection::_duplicate(v);
    any <<= &val;
}

CORBA::Boolean
operator>>=(const CORBA::Any& any, ProcessHitsCollection_ptr& v)
{
    if(any.check_type(_tc_ProcessHitsCollection))
    {
        CORBA::Object_ptr val = (CORBA::Object_ptr)any.value();

        if(!CORBA::is_nil(val))
        {
            if(!(v = dynamic_cast(val)))
            {
                v = new ProcessHitsCollection;
                v -> _OB_copyFrom(val);
                (CORBA::Any&)any <<= &v;
            }
        }
        else
            v = ProcessHitsCollection::_nil();

        return true;
    }
    else
        return false;
}

//
// IDL:ProcessHitsCollection/Hit:1.0
//
void
ProcessHitsCollection::Hit::_OB_marshal(OB::OutputStreamImpl* _ob_out) const
{
    _ob_out -> write_double(EdepAbs);
    _ob_out -> write_double(TrackLengthAbs);
    _ob_out -> write_double(EdepGap);
    _ob_out -> write_double(TrackLengthGap);
}

void
ProcessHitsCollection::Hit::_OB_unmarshal(Hit& _ob_v, OB::InputStreamImpl* _ob_i
n)
{
    _ob_v.EdepAbs = _ob_in -> read_double();
    _ob_v.TrackLengthAbs = _ob_in -> read_double();
    _ob_v.EdepGap = _ob_in -> read_double();
    _ob_v.TrackLengthGap = _ob_in -> read_double();
}

void
operator<<=(CORBA::Any& any, ProcessHitsCollection::Hit* v)
{
    static const OB::Info< ProcessHitsCollection::Hit > info;
    any.replace(ProcessHitsCollection::_tc_Hit, v, true, &info);
}

void
operator<<=(CORBA::Any& any, const ProcessHitsCollection::Hit& v)
{
    any <<= new ProcessHitsCollection::Hit(v);
}

CORBA::Boolean
operator>>=(const CORBA::Any& any, const ProcessHitsCollection::Hit*& v)
{
    if(any.check_type(ProcessHitsCollection::_tc_Hit))
    {
        if(!any.info())
        {
            OB::InputStream_var in = any.create_input_stream();
            ProcessHitsCollection::Hit* val = new ProcessHitsCollection::Hit;
            ProcessHitsCollection::Hit::_OB_unmarshal(*val, in);
            (CORBA::Any&)any <<= val;
        }

        v = (ProcessHitsCollection::Hit*)any.value();
        return true;
    }
    else
        return false;
}

//
// IDL:ProcessHitsCollection/HitsCollection:1.0
//
void
ProcessHitsCollection::OBInfo_HitsCollection::marshal(const void* _ob_v, OB::Out
putStreamImpl* _ob_out) const
{
    const ProcessHitsCollection::HitsCollection& _ob_seq = *(const ProcessHitsCo
llection::HitsCollection*)_ob_v;
    CORBA::ULong _ob_len0 = _ob_seq.length();
    _ob_out -> write_ulong(_ob_len0);
    ProcessHitsCollection::Hit const * _ob_buf0 = _ob_seq.get_buffer();
    for(CORBA::ULong _ob_i0 = 0 ; _ob_i0 < _ob_len0 ; _ob_i0++)
    {
        _ob_buf0[_ob_i0]._OB_marshal(_ob_out);
    }
}

void
ProcessHitsCollection::OBInfo_HitsCollection::unmarshal(void* _ob_v, OB::InputSt
reamImpl* _ob_in) const
{
    ProcessHitsCollection::HitsCollection& _ob_seq = *(ProcessHitsCollection::Hi
tsCollection*)_ob_v;
    CORBA::ULong _ob_len0 = _ob_in -> read_ulong();
    _ob_seq.length(_ob_len0);
    ProcessHitsCollection::Hit * _ob_buf0 = _ob_seq.get_buffer();
    for(CORBA::ULong _ob_i0 = 0 ; _ob_i0 < _ob_len0 ; _ob_i0++)
    {
        ProcessHitsCollection::Hit::_OB_unmarshal(_ob_buf0[_ob_i0], _ob_in);
    }
}

void
operator<<=(CORBA::Any& any, ProcessHitsCollection::HitsCollection* v)
{
    static const ProcessHitsCollection::OBInfo_HitsCollection info;
    any.replace(ProcessHitsCollection::_tc_HitsCollection, v, true, &info);
}

void
operator<<=(CORBA::Any& any, const ProcessHitsCollection::HitsCollection& v)
{
    any <<= new ProcessHitsCollection::HitsCollection(v);
}

CORBA::Boolean
operator>>=(const CORBA::Any& any, const ProcessHitsCollection::HitsCollection*&
 v)
{
    if(any.check_type(ProcessHitsCollection::_tc_HitsCollection))
    {
        if(!any.info())
        {
            OB::InputStream_var _ob_in = any.create_input_stream();
            ProcessHitsCollection::HitsCollection* val = new ProcessHitsCollecti
on::HitsCollection;
            CORBA::ULong _ob_len0 = _ob_in -> read_ulong();
            (*val).length(_ob_len0);
            ProcessHitsCollection::Hit * _ob_buf0 = (*val).get_buffer();
            for(CORBA::ULong _ob_i0 = 0 ; _ob_i0 < _ob_len0 ; _ob_i0++)
            {
                ProcessHitsCollection::Hit::_OB_unmarshal(_ob_buf0[_ob_i0], _ob_
in);
            }
            (CORBA::Any&)any <<= val;
        }

        v = (ProcessHitsCollection::HitsCollection*)any.value();
        return true;
    }
    else
        return false;
}

//
// IDL:ProcessHitsCollection/process:1.0
//
void
ProcessHitsCollection::process(const HitsCollection& _ob_a0)
{
    bool _ob_retry = true;
    while(true)
    {
        OB::StubImplBase_var _ob_stubImplBase = _OB_getStubImpl();
        OBStubImpl_ProcessHitsCollection_ptr _ob_stubImpl = dynamic_cast(_ob_stubImplBase.in());
        try
        {
            _ob_stubImpl -> process(_ob_a0);
            return;
        }
        catch(const OB::ExceptionBase& _ob_ex)
        {
            _OB_handleException(_ob_ex, _ob_retry);
        }
    }
}

//
// IDL:ProcessHitsCollection:1.0
//
void
OBDuplicate(OBStubImpl_ProcessHitsCollection_ptr p)
{
    if(p)
        p -> _OB_incRef();
}

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

//
// IDL:ProcessHitsCollection/process:1.0
//
void
OBMarshalStubImpl_ProcessHitsCollection::process(const ProcessHitsCollection::Hi
tsCollection& _ob_a0)
{
    while(true)
    {
        OB::Downcall_var _ob_down = _OB_createDowncall("process", true);
        try
        {
            OB::OutputStreamImpl* _ob_out = _OB_preMarshal(_ob_down);
            try
            {
                CORBA::ULong _ob_len0 = _ob_a0.length();
                _ob_out -> write_ulong(_ob_len0);
                ProcessHitsCollection::Hit const * _ob_buf0 = _ob_a0.get_buffer(
);
                for(CORBA::ULong _ob_i0 = 0 ; _ob_i0 < _ob_len0 ; _ob_i0++)
                {
                    _ob_buf0[_ob_i0]._OB_marshal(_ob_out);
                }
            }
            catch(const CORBA::SystemException& _ob_ex)
            {
                _OB_marshalEx(_ob_down, _ob_ex);
            }
            _OB_postMarshal(_ob_down);
            _OB_request(_ob_down);
            _OB_preUnmarshal(_ob_down);
            _OB_postUnmarshal(_ob_down);
            return;
        }
        catch(const OB::FailureException& _ob_ex)
        {
            _OB_handleFailureException(_ob_down, _ob_ex);
        }
    }
}