MICO

account.cc

/*
 *  MICO --- an Open Source CORBA implementation
 *  Copyright (c) 1997-2001 by The Mico Team
 *
 *  This file was automatically generated. DO NOT EDIT!
 */

#include "account.h"

//--------------------------------------------------------
//  Implementation of stubs
//--------------------------------------------------------

/*
 * Base interface for class Account
 */

Account::~Account()
{
}

void *
Account::_narrow_helper( const char *_repoid )
{
  if( strcmp( _repoid, "IDL:Account:1.0" ) == 0 )
    return (void *)this;
  return NULL;
}

Account_ptr
Account::_narrow( CORBA::Object_ptr _obj )
{
  Account_ptr _o;
  if( !CORBA::is_nil( _obj ) ) {
    void *_p;
    if( (_p = _obj->_narrow_helper( "IDL:Account:1.0" )))
      return _duplicate( (Account_ptr) _p );
    if (!strcmp (_obj->_repoid(), "IDL:Account:1.0") || _obj->_is_a_remote ("IDL:Account:1.0")) {
      _o = new Account_stub;
      _o->MICO_SCOPE(CORBA,Object::operator=)( *_obj );
      return _o;
    }
  }
  return _nil();
}

Account_ptr
Account::_narrow( CORBA::AbstractBase_ptr _obj )
{
  return _narrow (_obj->_to_object());
}

class _Marshaller_Account : public CORBA::StaticTypeInfo {
    typedef Account_ptr _MICO_T;
  public:
    StaticValueType create () const;
    void assign (StaticValueType dst, const StaticValueType src) const;
    void free (StaticValueType) const;
    void release (StaticValueType) const;
    CORBA::Boolean demarshal (CORBA::DataDecoder&, StaticValueType) const;
    void marshal (CORBA::DataEncoder &, StaticValueType) const;
};


CORBA::StaticValueType _Marshaller_Account::create() const
{
  return (StaticValueType) new _MICO_T( 0 );
}

void _Marshaller_Account::assign( StaticValueType d, const StaticValueType s ) const
{
  *(_MICO_T*) d = ::Account::_duplicate( *(_MICO_T*) s );
}

void _Marshaller_Account::free( StaticValueType v ) const
{
  CORBA::release( *(_MICO_T *) v );
  delete (_MICO_T*) v;
}

void _Marshaller_Account::release( StaticValueType v ) const
{
  CORBA::release( *(_MICO_T *) v );
}

CORBA::Boolean _Marshaller_Account::demarshal( CORBA::DataDecoder &dc, StaticValueType v ) const
{
  CORBA::Object_ptr obj;
  if (!CORBA::_stc_Object->demarshal(dc, &obj))
    return FALSE;
  *(_MICO_T *) v = ::Account::_narrow( obj );
  CORBA::Boolean ret = CORBA::is_nil (obj) || !CORBA::is_nil (*(_MICO_T *)v);
  CORBA::release (obj);
  return ret;
}

void _Marshaller_Account::marshal( CORBA::DataEncoder &ec, StaticValueType v ) const
{
  CORBA::Object_ptr obj = *(_MICO_T *) v;
  CORBA::_stc_Object->marshal( ec, &obj );
}

CORBA::StaticTypeInfo *_marshaller_Account;


/*
 * Stub interface for class Account
 */

Account_stub::~Account_stub()
{
}

void Account_stub::deposit( CORBA::ULong amount )
{
  CORBA::StaticAny _amount( CORBA::_stc_ulong, &amount );
  CORBA::StaticRequest __req( this, "deposit" );
  __req.add_in_arg( &_amount );

  __req.invoke();

  mico_sii_throw( &__req, 
    0);
}


void Account_stub::withdraw( CORBA::ULong amount )
{
  CORBA::StaticAny _amount( CORBA::_stc_ulong, &amount );
  CORBA::StaticRequest __req( this, "withdraw" );
  __req.add_in_arg( &_amount );

  __req.invoke();

  mico_sii_throw( &__req, 
    0);
}


CORBA::Long Account_stub::balance()
{
  CORBA::Long _res;
  CORBA::StaticAny __res( CORBA::_stc_long, &_res );

  CORBA::StaticRequest __req( this, "balance" );
  __req.set_result( &__res );

  __req.invoke();

  mico_sii_throw( &__req, 
    0);
  return _res;
}


struct __tc_init_ACCOUNT {
  __tc_init_ACCOUNT()
  {
    _marshaller_Account = new _Marshaller_Account;
  }
};

static __tc_init_ACCOUNT __init_ACCOUNT;

//--------------------------------------------------------
//  Implementation of skeletons
//--------------------------------------------------------

Account_skel::Account_skel( const CORBA::BOA::ReferenceData &_id )
{
  CORBA::ImplementationDef_var _impl =
    _find_impl( "IDL:Account:1.0", "Account" );
  _create_ref( _id,
    0,
    _impl,
    "IDL:Account:1.0" );
  register_dispatcher( new StaticInterfaceDispatcherWrapper<Account_skel>( this ) );
}

Account_skel::Account_skel( CORBA::Object_ptr _obj )
{
  CORBA::ImplementationDef_var _impl =
    _find_impl( "IDL:Account:1.0", "Account" );
  assert( !CORBA::is_nil( _impl ) );
  _restore_ref( _obj,
    CORBA::BOA::ReferenceData(),
    0,
    _impl );
  register_dispatcher( new StaticInterfaceDispatcherWrapper<Account_skel>( this ) );
}

Account_skel::~Account_skel()
{
}

bool Account_skel::dispatch( CORBA::StaticServerRequest_ptr __req, CORBA::Environment & /*_env*/ )
{
  #ifdef HAVE_EXCEPTIONS
  try {
  #endif
    if( strcmp( __req->op_name(), "deposit" ) == 0 ) {
      CORBA::ULong amount;
      CORBA::StaticAny _amount( CORBA::_stc_ulong, &amount );

      __req->add_in_arg( &_amount );

      if( !__req->read_args() )
        return true;

      deposit( amount );
      __req->write_results();
      return true;
    }
    if( strcmp( __req->op_name(), "withdraw" ) == 0 ) {
      CORBA::ULong amount;
      CORBA::StaticAny _amount( CORBA::_stc_ulong, &amount );

      __req->add_in_arg( &_amount );

      if( !__req->read_args() )
        return true;

      withdraw( amount );
      __req->write_results();
      return true;
    }
    if( strcmp( __req->op_name(), "balance" ) == 0 ) {
      CORBA::Long _res;
      CORBA::StaticAny __res( CORBA::_stc_long, &_res );
      __req->set_result( &__res );

      if( !__req->read_args() )
        return true;

      _res = balance();
      __req->write_results();
      return true;
    }
  #ifdef HAVE_EXCEPTIONS
  } catch( CORBA::SystemException_catch &_ex ) {
    __req->set_exception( _ex->_clone() );
    __req->write_results();
    return true;
  } catch( ... ) {
    assert( 0 );
    return true;
  }
  #endif
  return false;
}

Account_ptr Account_skel::_this()
{
  return Account::_duplicate( this );
}


José M. Vidal .

4 of 8