Click here to Skip to main content
15,891,529 members
Articles / Programming Languages / C#

Mixing ACE/TAO and .NET Clients and Servers

Rate me:
Please Sign up or sign in to vote.
4.65/5 (28 votes)
13 Dec 2005CPOL18 min read 84K   1.9K   45  
Demonstrates mixing C++ ACE/TAO clients and servers with C# IIOP.NET clients and servers on Windows and Linux.
// -*- 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:291


#include "ExampleInterfacesC.h"
#include "tao/CDR.h"
#include "tao/Exception_Data.h"
#include "tao/Invocation_Adapter.h"
#include "tao/Object_T.h"
#include "tao/Null_RefCount_Policy.h"
#include "tao/TypeCode_Constants.h"
#include "tao/Alias_TypeCode_Static.h"
#include "tao/Objref_TypeCode_Static.h"
#include "tao/Any_Impl_T.h"
#include "tao/Basic_Arguments.h"
#include "ace/OS_NS_string.h"

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

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

// TAO_IDL - Generated from
// .\be\be_visitor_arg_traits.cpp:70

// Arg traits specializations.
namespace TAO
{
}


// TAO_IDL - Generated from
// c:\local\ace\tao\tao_idl\be\be_visitor_interface/interface_cs.cpp:60

// Traits specializations for ExampleInterfaces::IAdder.

ExampleInterfaces::IAdder_ptr
TAO::Objref_Traits<ExampleInterfaces::IAdder>::duplicate (
    ExampleInterfaces::IAdder_ptr p
  )
{
  return ExampleInterfaces::IAdder::_duplicate (p);
}

void
TAO::Objref_Traits<ExampleInterfaces::IAdder>::release (
    ExampleInterfaces::IAdder_ptr p
  )
{
  CORBA::release (p);
}

ExampleInterfaces::IAdder_ptr
TAO::Objref_Traits<ExampleInterfaces::IAdder>::nil (void)
{
  return ExampleInterfaces::IAdder::_nil ();
}

CORBA::Boolean
TAO::Objref_Traits<ExampleInterfaces::IAdder>::marshal (
    ExampleInterfaces::IAdder_ptr p,
    TAO_OutputCDR & cdr
  )
{
  return CORBA::Object::marshal (p, cdr);
}

// Function pointer for collocation factory initialization.
TAO::Collocation_Proxy_Broker * 
(*ExampleInterfaces__TAO_IAdder_Proxy_Broker_Factory_function_pointer) (
    CORBA::Object_ptr obj
  ) = 0;

// TAO_IDL - Generated from
// c:\local\ace\tao\tao_idl\be\be_visitor_operation/operation_cs.cpp:78

CORBA::Double ExampleInterfaces::IAdder::add (
    ::CORBA::Double arg1,
    ::CORBA::Double arg2
    ACE_ENV_ARG_DECL
  )
  ACE_THROW_SPEC ((
    CORBA::SystemException
  ))
{
  if (!this->is_evaluated ())
    {
      ACE_NESTED_CLASS (CORBA, Object)::tao_object_initialize (this);
    }
  
  if (this->the_TAO_IAdder_Proxy_Broker_ == 0)
    {
      ExampleInterfaces_IAdder_setup_collocation ();
    }
  
  TAO::Arg_Traits< ::CORBA::Double>::ret_val _tao_retval;
  TAO::Arg_Traits< ::CORBA::Double>::in_arg_val _tao_arg1 (arg1);
  TAO::Arg_Traits< ::CORBA::Double>::in_arg_val _tao_arg2 (arg2);
  
  TAO::Argument *_the_tao_operation_signature [] =
    {
      &_tao_retval,
      &_tao_arg1,
      &_tao_arg2
    };
  
  TAO::Invocation_Adapter _tao_call (
      this,
      _the_tao_operation_signature,
      3,
      "add",
      3,
      this->the_TAO_IAdder_Proxy_Broker_
    );
  
  _tao_call.invoke (0, 0 ACE_ENV_ARG_PARAMETER);
  ACE_CHECK_RETURN (_tao_retval.excp ());
  
  return _tao_retval.retn ();
}

ExampleInterfaces::IAdder::IAdder (void)
 : the_TAO_IAdder_Proxy_Broker_ (0)
{
  this->ExampleInterfaces_IAdder_setup_collocation ();
}

void
ExampleInterfaces::IAdder::ExampleInterfaces_IAdder_setup_collocation ()
{
  if (::ExampleInterfaces__TAO_IAdder_Proxy_Broker_Factory_function_pointer)
    {
      this->the_TAO_IAdder_Proxy_Broker_ =
        ::ExampleInterfaces__TAO_IAdder_Proxy_Broker_Factory_function_pointer (this);
    }
}

ExampleInterfaces::IAdder::~IAdder (void)
{}

void 
ExampleInterfaces::IAdder::_tao_any_destructor (void *_tao_void_pointer)
{
  IAdder *_tao_tmp_pointer =
    static_cast<IAdder *> (_tao_void_pointer);
  CORBA::release (_tao_tmp_pointer);
}

ExampleInterfaces::IAdder_ptr
ExampleInterfaces::IAdder::_narrow (
    CORBA::Object_ptr _tao_objref
    ACE_ENV_ARG_DECL
  )
{
  return
    TAO::Narrow_Utils<IAdder>::narrow (
        _tao_objref,
        "IDL:SLB/ExampleInterfaces/IAdder:1.0",
        ExampleInterfaces__TAO_IAdder_Proxy_Broker_Factory_function_pointer
        ACE_ENV_ARG_PARAMETER
      );
}

ExampleInterfaces::IAdder_ptr
ExampleInterfaces::IAdder::_unchecked_narrow (
    CORBA::Object_ptr _tao_objref
    ACE_ENV_ARG_DECL
  )
{
  return
    TAO::Narrow_Utils<IAdder>::unchecked_narrow (
        _tao_objref,
        "IDL:SLB/ExampleInterfaces/IAdder:1.0",
        ExampleInterfaces__TAO_IAdder_Proxy_Broker_Factory_function_pointer
        ACE_ENV_ARG_PARAMETER
      );
}

ExampleInterfaces::IAdder_ptr
ExampleInterfaces::IAdder::_duplicate (IAdder_ptr obj)
{
  if (! CORBA::is_nil (obj))
    {
      obj->_add_ref ();
    }
  
  return obj;
}

void
ExampleInterfaces::IAdder::_tao_release (IAdder_ptr obj)
{
  CORBA::release (obj);
}

CORBA::Boolean
ExampleInterfaces::IAdder::_is_a (
    const char *value
    ACE_ENV_ARG_DECL
  )
{
  if (
      !ACE_OS::strcmp (
          value,
          "IDL:SLB/ExampleInterfaces/IAdder:1.0"
        ) ||
      !ACE_OS::strcmp (
          value,
          "IDL:omg.org/CORBA/Object:1.0"
        )
    )
    {
      return true; // success using local knowledge
    }
  else
    {
      return this->ACE_NESTED_CLASS (CORBA, Object)::_is_a (
          value
          ACE_ENV_ARG_PARAMETER
        );
    }
}

const char* ExampleInterfaces::IAdder::_interface_repository_id (void) const
{
  return "IDL:SLB/ExampleInterfaces/IAdder:1.0";
}

CORBA::Boolean
ExampleInterfaces::IAdder::marshal (TAO_OutputCDR &cdr)
{
  return (cdr << this);
}

// TAO_IDL - Generated from
// c:\local\ace\tao\tao_idl\be\be_visitor_typecode/objref_typecode.cpp:76

static TAO::TypeCode::Objref<char const *,
                             TAO::Null_RefCount_Policy>
  _tao_tc_ExampleInterfaces_IAdder (
    CORBA::tk_objref,
    "IDL:SLB/ExampleInterfaces/IAdder:1.0",
    "IAdder");
  
namespace ExampleInterfaces
{
  ::CORBA::TypeCode_ptr const _tc_IAdder =
    &_tao_tc_ExampleInterfaces_IAdder;
}



// TAO_IDL - Generated from
// c:\local\ace\tao\tao_idl\be\be_visitor_interface/any_op_cs.cpp:50

namespace TAO
{
  template<>
  CORBA::Boolean
  Any_Impl_T<ExampleInterfaces::IAdder>::to_object (
      CORBA::Object_ptr &_tao_elem
    ) const
  {
    _tao_elem = CORBA::Object::_duplicate (this->value_);
    return true;
  }
}

#if defined (ACE_ANY_OPS_USE_NAMESPACE)

namespace ExampleInterfaces
{
  
  
  // Copying insertion.
  void
  operator<<= (
      CORBA::Any &_tao_any,
      IAdder_ptr _tao_elem
    )
  {
    IAdder_ptr _tao_objptr =
      IAdder::_duplicate (_tao_elem);
    _tao_any <<= &_tao_objptr;
  }
  
  // Non-copying insertion.
  void
  operator<<= (
      CORBA::Any &_tao_any,
      IAdder_ptr *_tao_elem
    )
  {
    TAO::Any_Impl_T<IAdder>::insert (
        _tao_any,
        IAdder::_tao_any_destructor,
        _tc_IAdder,
        *_tao_elem
      );
  }
  
  CORBA::Boolean
  operator>>= (
      const CORBA::Any &_tao_any,
      IAdder_ptr &_tao_elem
    )
  {
    return
      TAO::Any_Impl_T<IAdder>::extract (
          _tao_any,
          IAdder::_tao_any_destructor,
          _tc_IAdder,
          _tao_elem
        );
  }
}

#else


// Copying insertion.
void
operator<<= (
    CORBA::Any &_tao_any,
    ExampleInterfaces::IAdder_ptr _tao_elem
  )
{
  ExampleInterfaces::IAdder_ptr _tao_objptr =
    ExampleInterfaces::IAdder::_duplicate (_tao_elem);
  _tao_any <<= &_tao_objptr;
}

// Non-copying insertion.
void
operator<<= (
    CORBA::Any &_tao_any,
    ExampleInterfaces::IAdder_ptr *_tao_elem
  )
{
  TAO::Any_Impl_T<ExampleInterfaces::IAdder>::insert (
      _tao_any,
      ExampleInterfaces::IAdder::_tao_any_destructor,
      ExampleInterfaces::_tc_IAdder,
      *_tao_elem
    );
}

CORBA::Boolean
operator>>= (
    const CORBA::Any &_tao_any,
    ExampleInterfaces::IAdder_ptr &_tao_elem
  )
{
  return
    TAO::Any_Impl_T<ExampleInterfaces::IAdder>::extract (
        _tao_any,
        ExampleInterfaces::IAdder::_tao_any_destructor,
        ExampleInterfaces::_tc_IAdder,
        _tao_elem
      );
}

#endif

// TAO_IDL - Generated from
// c:\local\ace\tao\tao_idl\be\be_visitor_interface/cdr_op_cs.cpp:63

CORBA::Boolean operator<< (
    TAO_OutputCDR &strm,
    const ExampleInterfaces::IAdder_ptr _tao_objref
  )
{
  CORBA::Object_ptr _tao_corba_obj = _tao_objref;
  return (strm << _tao_corba_obj);
}

CORBA::Boolean operator>> (
    TAO_InputCDR &strm,
    ExampleInterfaces::IAdder_ptr &_tao_objref
  )
{
  CORBA::Object_var obj;
  
  if (!(strm >> obj.inout ()))
    {
      return false;
    }
  
  typedef ::ExampleInterfaces::IAdder RHS_SCOPED_NAME;
  
  // Narrow to the right type.
  _tao_objref =
    TAO::Narrow_Utils<RHS_SCOPED_NAME>::unchecked_narrow (
        obj.in (),
        ExampleInterfaces__TAO_IAdder_Proxy_Broker_Factory_function_pointer
      );
    
  return 1;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer Defence R&D Canada
Canada Canada
Stephen Bogner is a Senior Research Engineer with Defence R&D Canada. As the Head Autonomous Applications Group, Autonomous Intelligent Systems Section, he only programs when it can't be avoided, and then only in C#.

Comments and Discussions