// -*- C++ -*-
//
// $Id$

// ****  Code generated by the The ACE ORB (TAO) IDL Compiler ****
// TAO and the TAO IDL Compiler have been developed by:
//       Center for Distributed Object Computing
//       Washington University
//       St. Louis, MO
//       USA
//       http://www.cs.wustl.edu/~schmidt/doc-center.html
// and
//       Distributed Object Computing Laboratory
//       University of California at Irvine
//       Irvine, CA
//       USA
//       http://doc.ece.uci.edu/
// and
//       Institute for Software Integrated Systems
//       Vanderbilt University
//       Nashville, TN
//       USA
//       http://www.isis.vanderbilt.edu/
//
// Information about TAO is available at:
//     http://www.cs.wustl.edu/~schmidt/TAO.html

// TAO_IDL - Generated from
// be/be_codegen.cpp:303


#include "RtecDefaultEventDataC.h"
#include "tao/CDR.h"
#include "tao/ORB_Core.h"
#include "tao/Typecode.h"
#include "tao/Any_Dual_Impl_T.h"

#if defined (__BORLANDC__)
#pragma option -w-rvl -w-rch -w-ccc -w-aus -w-sig
#endif /* __BORLANDC__ */

#if !defined (__ACE_INLINE__)
#include "RtecDefaultEventDataC.inl"
#endif /* !defined __ACE_INLINE__ */

// TAO_IDL - Generated from
// be/be_visitor_arg_traits.cpp:64

// Arg traits specializations.
namespace TAO
{
}


// TAO_IDL - Generated from 
// be/be_visitor_sequence/sequence_cs.cpp:65

#if !defined (_EVENTPAYLOAD_CS_)
#define _EVENTPAYLOAD_CS_

EventPayload::EventPayload (void)
{}

EventPayload::EventPayload (
    CORBA::ULong max
  )
  : TAO_Unbounded_Sequence<
        CORBA::Octet
      >
    (max)
{}

EventPayload::EventPayload (
    CORBA::ULong max,
    CORBA::ULong length,
    CORBA::Octet * buffer,
    CORBA::Boolean release
  )
  : TAO_Unbounded_Sequence<
        CORBA::Octet
      >
    (max, length, buffer, release)
{}

EventPayload::EventPayload (
    const EventPayload &seq
  )
  : TAO_Unbounded_Sequence<
        CORBA::Octet
      >
    (seq)
{}

EventPayload::~EventPayload (void)
{}

void EventPayload::_tao_any_destructor (
    void * _tao_void_pointer
  )
{
  EventPayload * _tao_tmp_pointer =
    static_cast<EventPayload *> (_tao_void_pointer);
  delete _tao_tmp_pointer;
}

#endif /* end #if !defined */

// TAO_IDL - Generated from
// be/be_visitor_typecode/typecode_defn.cpp:290

static const CORBA::Long _oc_EventPayload[] =
{
    TAO_ENCAP_BYTE_ORDER, // byte order
  21,
  ACE_NTOHL (0x49444c3a), 
  ACE_NTOHL (0x4576656e), 
  ACE_NTOHL (0x74506179), 
  ACE_NTOHL (0x6c6f6164), 
  ACE_NTOHL (0x3a312e30), 
  ACE_NTOHL (0x0),  // repository ID = IDL:EventPayload:1.0
    13,
  ACE_NTOHL (0x4576656e), 
  ACE_NTOHL (0x74506179), 
  ACE_NTOHL (0x6c6f6164), 
  ACE_NTOHL (0x0),  // name = EventPayload
    CORBA::tk_sequence, // typecode kind
  12, // encapsulation length
    TAO_ENCAP_BYTE_ORDER, // byte order
    CORBA::tk_octet,

    0U,

};

static CORBA::TypeCode _tc_TAO_tc_EventPayload (
    CORBA::tk_alias,
    sizeof (_oc_EventPayload),
    (char *) &_oc_EventPayload,
    0,
    sizeof (EventPayload)
  );

::CORBA::TypeCode_ptr _tc_EventPayload =
  &_tc_TAO_tc_EventPayload;

// TAO_IDL - Generated from
// be/be_visitor_typecode/typecode_defn.cpp:290

static const CORBA::Long _oc_RtecEventData[] =
{
    TAO_ENCAP_BYTE_ORDER, // byte order
  22,
  ACE_NTOHL (0x49444c3a), 
  ACE_NTOHL (0x52746563), 
  ACE_NTOHL (0x4576656e), 
  ACE_NTOHL (0x74446174), 
  ACE_NTOHL (0x613a312e), 
  ACE_NTOHL (0x30000000),  // repository ID = IDL:RtecEventData:1.0
    14,
  ACE_NTOHL (0x52746563), 
  ACE_NTOHL (0x4576656e), 
  ACE_NTOHL (0x74446174), 
  ACE_NTOHL (0x61000000),  // name = RtecEventData
  3, // member count
    5,
  ACE_NTOHL (0x70616431), 
  ACE_NTOHL (0x0),  // name = pad1
    CORBA::tk_long,

  8,
  ACE_NTOHL (0x7061796c), 
  ACE_NTOHL (0x6f616400),  // name = payload
    CORBA::tk_alias, // typecode kind for typedefs
  72, // encapsulation length
    TAO_ENCAP_BYTE_ORDER, // byte order
    21,
    ACE_NTOHL (0x49444c3a), 
    ACE_NTOHL (0x4576656e), 
    ACE_NTOHL (0x74506179), 
    ACE_NTOHL (0x6c6f6164), 
    ACE_NTOHL (0x3a312e30), 
    ACE_NTOHL (0x0),  // repository ID = IDL:EventPayload:1.0
        13,
    ACE_NTOHL (0x4576656e), 
    ACE_NTOHL (0x74506179), 
    ACE_NTOHL (0x6c6f6164), 
    ACE_NTOHL (0x0),  // name = EventPayload
        CORBA::tk_sequence, // typecode kind
    12, // encapsulation length
      TAO_ENCAP_BYTE_ORDER, // byte order
      CORBA::tk_octet,

      0U,


  10,
  ACE_NTOHL (0x616e795f), 
  ACE_NTOHL (0x76616c75), 
  ACE_NTOHL (0x65000000),  // name = any_value
    CORBA::tk_any,

};

static CORBA::TypeCode _tc_TAO_tc_RtecEventData (
    CORBA::tk_struct,
    sizeof (_oc_RtecEventData),
    (char *) &_oc_RtecEventData,
    0,
    sizeof (RtecEventData)
  );

::CORBA::TypeCode_ptr _tc_RtecEventData =
  &_tc_TAO_tc_RtecEventData;

// TAO_IDL - Generated from 
// be/be_visitor_structure/structure_cs.cpp:66

void 
RtecEventData::_tao_any_destructor (
    void *_tao_void_pointer
  )
{
  RtecEventData *_tao_tmp_pointer =
    static_cast<RtecEventData *> (_tao_void_pointer);
  delete _tao_tmp_pointer;
}

// TAO_IDL - Generated from 
// be/be_visitor_sequence/any_op_cs.cpp:54

// Copying insertion.
void operator<<= (
    CORBA::Any &_tao_any,
    const EventPayload &_tao_elem
  )
{
  TAO::Any_Dual_Impl_T<EventPayload>::insert_copy (
      _tao_any,
      EventPayload::_tao_any_destructor,
      _tc_EventPayload,
      _tao_elem
    );
}

// Non-copying insertion.
void operator<<= (
    CORBA::Any &_tao_any,
    EventPayload *_tao_elem
  )
{
  TAO::Any_Dual_Impl_T<EventPayload>::insert (
      _tao_any,
      EventPayload::_tao_any_destructor,
      _tc_EventPayload,
      _tao_elem
    );
}

// Extraction to non-const pointer (deprecated).
CORBA::Boolean operator>>= (
    const CORBA::Any &_tao_any,
    EventPayload *&_tao_elem
  )
{
  return _tao_any >>= const_cast<
      const EventPayload *&> (
      _tao_elem
    );
}

// Extraction to const pointer.
CORBA::Boolean operator>>= (
    const CORBA::Any &_tao_any,
    const EventPayload *&_tao_elem
  )
{
  return
    TAO::Any_Dual_Impl_T<EventPayload>::extract (
        _tao_any,
        EventPayload::_tao_any_destructor,
        _tc_EventPayload,
        _tao_elem
      );
}

// TAO_IDL - Generated from 
// be/be_visitor_structure/any_op_cs.cpp:54

// Copying insertion.
void operator<<= (
    CORBA::Any &_tao_any,
    const RtecEventData &_tao_elem
  )
{
  TAO::Any_Dual_Impl_T<RtecEventData>::insert_copy (
      _tao_any,
      RtecEventData::_tao_any_destructor,
      _tc_RtecEventData,
      _tao_elem
    );
}

// Non-copying insertion.
void operator<<= (
    CORBA::Any &_tao_any,
    RtecEventData *_tao_elem
  )
{
  TAO::Any_Dual_Impl_T<RtecEventData>::insert (
      _tao_any,
      RtecEventData::_tao_any_destructor,
      _tc_RtecEventData,
      _tao_elem
    );
}

// Extraction to non-const pointer (deprecated).
CORBA::Boolean operator>>= (
    const CORBA::Any &_tao_any,
    RtecEventData *&_tao_elem
  )
{
  return _tao_any >>= const_cast<
      const RtecEventData *&> (
      _tao_elem
    );
}

// Extraction to const pointer.
CORBA::Boolean operator>>= (
    const CORBA::Any &_tao_any,
    const RtecEventData *&_tao_elem
  )
{
  return
    TAO::Any_Dual_Impl_T<RtecEventData>::extract (
        _tao_any,
        RtecEventData::_tao_any_destructor,
        _tc_RtecEventData,
        _tao_elem
      );
}

// TAO_IDL - Generated from
// be/be_visitor_sequence/cdr_op_cs.cpp:96

#if !defined _TAO_CDR_OP_EventPayload_CPP_
#define _TAO_CDR_OP_EventPayload_CPP_

CORBA::Boolean operator<< (
    TAO_OutputCDR &strm,
    const EventPayload &_tao_sequence
  )
{
  const CORBA::ULong _tao_seq_len = _tao_sequence.length ();
  
  if (strm << _tao_seq_len)
    {
      // Encode all elements.
      
#if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
      {
        TAO_Unbounded_Sequence<CORBA::Octet> *oseq = 
          static_cast<TAO_Unbounded_Sequence<CORBA::Octet> *> ((EventPayload *)&_tao_sequence);
        if (oseq->mb ())
          return strm.write_octet_array_mb (oseq->mb ());
        else
          return strm.write_octet_array (_tao_sequence.get_buffer (), _tao_sequence.length ());
      }
      
#else /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */
      return strm.write_octet_array (_tao_sequence.get_buffer (), _tao_sequence.length ());
    
#endif /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */
    }
  
  return 0;
}

CORBA::Boolean operator>> (
    TAO_InputCDR &strm,
    EventPayload &_tao_sequence
  )
{
  CORBA::ULong _tao_seq_len;
  
  if (strm >> _tao_seq_len)
    {
      // Add a check to the length of the sequence
      // to make sure it does not exceed the length
      // of the stream. (See bug 58.)
      if (_tao_seq_len > strm.length ())
        {
          return 0;
        }
      
      // Set the length of the sequence.
      _tao_sequence.length (_tao_seq_len);
      
      // If length is 0 we return true.
      if (0 >= _tao_seq_len) 
        {
          return 1;
        }
      
      // Retrieve all the elements.
      
#if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
      if (ACE_BIT_DISABLED (strm.start ()->flags (),
      ACE_Message_Block::DONT_DELETE))
      {
        TAO_ORB_Core* orb_core = strm.orb_core ();
        if (orb_core != 0 &&
        strm.orb_core ()->resource_factory ()->
        input_cdr_allocator_type_locked () == 1)
        {
          TAO_Unbounded_Sequence<CORBA::Octet> *oseq = 
            static_cast<TAO_Unbounded_Sequence<CORBA::Octet> *> (&_tao_sequence);
          oseq->replace (_tao_seq_len, strm.start ());
          oseq->mb ()->wr_ptr (oseq->mb()->rd_ptr () + _tao_seq_len);
          strm.skip_bytes (_tao_seq_len);
          return 1;
        }
      }
      return strm.read_octet_array (_tao_sequence.get_buffer (), _tao_seq_len);
#else /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */
      return strm.read_octet_array (_tao_sequence.get_buffer (), _tao_sequence.length ());
    
#endif /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */
    
    }
  
  return 0;
}

#endif /* _TAO_CDR_OP_EventPayload_CPP_ */

// TAO_IDL - Generated from
// be/be_visitor_structure/cdr_op_cs.cpp:61

CORBA::Boolean operator<< (
    TAO_OutputCDR &strm,
    const RtecEventData &_tao_aggregate
  )
{
  return
    (strm << _tao_aggregate.pad1) &&
    (strm << _tao_aggregate.payload) &&
    (strm << _tao_aggregate.any_value);
}

CORBA::Boolean operator>> (
    TAO_InputCDR &strm,
    RtecEventData &_tao_aggregate
  )
{
  return
    (strm >> _tao_aggregate.pad1) &&
    (strm >> _tao_aggregate.payload) &&
    (strm >> _tao_aggregate.any_value);
}

