#include "account.h"
#include <omniORB2/proxyCall.h>

static const char* _0RL_library_version = omniORB_2_7;


// Proxy call descriptor class. Mangled signature:
//  void_i_cunsigned_plong
class _0RL_pc_0a01bdf5e4f42031_00000000
  : public OmniProxyCallDesc
{
public:
  inline _0RL_pc_0a01bdf5e4f42031_00000000(const char* _op, size_t _op_len, CORBA::ULong _a_amount) :
    OmniProxyCallDesc(_op, _op_len),
    arg_amount(_a_amount)  {}

  virtual CORBA::ULong alignedSize(CORBA::ULong size_in);
  virtual void marshalArguments(GIOP_C&);

private:
  CORBA::ULong arg_amount;
};

CORBA::ULong _0RL_pc_0a01bdf5e4f42031_00000000::alignedSize(CORBA::ULong msgsize)
{
  msgsize = omni::align_to(msgsize,omni::ALIGN_4);
  msgsize += 4;
  return msgsize;
}

void _0RL_pc_0a01bdf5e4f42031_00000000::marshalArguments(GIOP_C& giop_client)
{
  arg_amount >>= giop_client;
}

void _proxy_Account::deposit(CORBA::ULong  amount)
{
  _0RL_pc_0a01bdf5e4f42031_00000000 _call_desc("deposit", 8, amount);

  OmniProxyCallWrapper::invoke(this, _call_desc);
}



void _proxy_Account::withdraw(CORBA::ULong  amount)
{
  _0RL_pc_0a01bdf5e4f42031_00000000 _call_desc("withdraw", 9, amount);

  OmniProxyCallWrapper::invoke(this, _call_desc);
}



// Proxy call descriptor class. Mangled signature:
//  _clong
class _0RL_pc_0a01bdf5e4f42031_10000000
  : public OmniProxyCallDesc
{
public:
  inline _0RL_pc_0a01bdf5e4f42031_10000000(const char* _op, size_t _op_len) :
    OmniProxyCallDesc(_op, _op_len)  {}

  virtual void unmarshalReturnedValues(GIOP_C&);
  inline CORBA::Long result() { return pd_result; }

private:
  CORBA::Long pd_result;
};

void _0RL_pc_0a01bdf5e4f42031_10000000::unmarshalReturnedValues(GIOP_C& giop_client)
{
  pd_result <<= giop_client;
}

CORBA::Long  _proxy_Account::balance()
{
  _0RL_pc_0a01bdf5e4f42031_10000000 _call_desc("balance", 8);

  OmniProxyCallWrapper::invoke(this, _call_desc);
  return _call_desc.result();
}




CORBA::Boolean
_sk_Account::dispatch(GIOP_S &_0RL_s,const char *_0RL_op,CORBA::Boolean _0RL_response_expected)
{
  if (strcmp(_0RL_op,"deposit") == 0)
  {
    CORBA::ULong amount;
    amount <<= _0RL_s;
    _0RL_s.RequestReceived();
        deposit(amount);
    size_t _0RL_msgsize = (size_t) GIOP_S::ReplyHeaderSize();
    _0RL_s.InitialiseReply(GIOP::NO_EXCEPTION,(CORBA::ULong)_0RL_msgsize);
    _0RL_s.ReplyCompleted();
    return 1;
  }
  else if (strcmp(_0RL_op,"withdraw") == 0)
  {
    CORBA::ULong amount;
    amount <<= _0RL_s;
    _0RL_s.RequestReceived();
        withdraw(amount);
    size_t _0RL_msgsize = (size_t) GIOP_S::ReplyHeaderSize();
    _0RL_s.InitialiseReply(GIOP::NO_EXCEPTION,(CORBA::ULong)_0RL_msgsize);
    _0RL_s.ReplyCompleted();
    return 1;
  }
  else if (strcmp(_0RL_op,"balance") == 0)
  {
    _0RL_s.RequestReceived();
    CORBA::Long _0RL_result;
    _0RL_result = balance();
    size_t _0RL_msgsize = (size_t) GIOP_S::ReplyHeaderSize();
    _0RL_msgsize = omni::align_to(_0RL_msgsize,omni::ALIGN_4);
    _0RL_msgsize += 4;
    _0RL_s.InitialiseReply(GIOP::NO_EXCEPTION,(CORBA::ULong)_0RL_msgsize);
    _0RL_result >>= _0RL_s;
    _0RL_s.ReplyCompleted();
    return 1;
  }
  else {
    return 0;
  }
}

_sk_Account::_sk_Account (const omniORB::objectKey& k)
{
  omniRopeAndKey l(0,(CORBA::Octet*)&k,(CORBA::ULong)sizeof(k));
  setRopeAndKey(l,0);
}

omniORB::objectKey
_sk_Account::_key()
{
  omniRopeAndKey l;
  getRopeAndKey(l);
  return (*((omniORB::objectKey*)l.key()));
}

Account_ptr
Account::_duplicate(Account_ptr obj)
{
  if (CORBA::is_nil(obj))
    return Account::_nil();
  CORBA::Object::_duplicate(obj);
  return obj;
}

Account_ptr
Account::_narrow(CORBA::Object_ptr obj)
{
  if (CORBA::is_nil(obj))
    return Account::_nil();
  Account_ptr e = (Account_ptr) (obj->PR_getobj()->_realNarrow(Account_IntfRepoID));
  if (e)
    return e;
  else
    return Account::_nil();
}

void *
Account::_widenFromTheMostDerivedIntf(const char *repoId,CORBA::Boolean is_cxx_type_id)
{
  if (is_cxx_type_id) return 0;
  if (!repoId)
    return (void *)((CORBA::Object_ptr)this);
  if (strcmp(Account_IntfRepoID,repoId) == 0)
    return (void *)this;
  else {
    return 0;
  }
}

CORBA::Boolean
Account::_0RL_is_a(const char *base_repoId) {
  if (strcmp(base_repoId,(const char *)Account_IntfRepoID)==0)
    return 1;
  else
    return 0;
}

Account_ptr
Account_Helper::_nil() {
  return Account::_nil();
}

CORBA::Boolean
Account_Helper::is_nil(Account_ptr p) {
  return CORBA::is_nil(p);
}

void
Account_Helper::release(Account_ptr p) {
  CORBA::release(p);
}

void
Account_Helper::duplicate(Account_ptr p) {
  CORBA::Object::_duplicate(p);
}

size_t
Account_Helper::NP_alignedSize(Account_ptr obj,size_t initialoffset) {
  return Account::NP_alignedSize(obj,initialoffset);
}

void
Account_Helper::marshalObjRef(Account_ptr obj,NetBufferedStream &s) {
  Account::marshalObjRef(obj,s);
}

Account_ptr Account_Helper::unmarshalObjRef(NetBufferedStream &s) {
  return Account::unmarshalObjRef(s);
}

void
Account_Helper::marshalObjRef(Account_ptr obj,MemBufferedStream &s) {
  Account::marshalObjRef(obj,s);
}

Account_ptr Account_Helper::unmarshalObjRef(MemBufferedStream &s) {
  return Account::unmarshalObjRef(s);
}

const char *
Account_proxyObjectFactory::irRepoId() const
{
  return (const char *)Account_IntfRepoID;
}

CORBA::Object_ptr
Account_proxyObjectFactory::newProxyObject(Rope *r,CORBA::Octet *key,size_t keysize,IOP::TaggedProfileList *profiles,CORBA::Boolean release)
{
  _proxy_Account *p = new _proxy_Account(r,key,keysize,profiles,release);
  if (!p) {
    throw CORBA::NO_MEMORY(0,CORBA::COMPLETED_NO);
  }
  return (CORBA::Object_ptr) p;
}

CORBA::Boolean
Account_proxyObjectFactory::is_a(const char *base_repoId) const
{
  return Account::_0RL_is_a(base_repoId);

}

Account_ptr
Account::_nil() {
  return Account_proxyObjectFactory::_nil();
}

static const Account_proxyObjectFactory Account_proxyObjectFactory;
Account_ptr Account_proxyObjectFactory::__nil_Account = 0;

void _proxy_SavingsAccount::creditInterest()
{
  OmniProxyCallWrapper::void_call _call_desc("creditInterest", 15);

  OmniProxyCallWrapper::invoke(this, _call_desc);
}




CORBA::Boolean
_sk_SavingsAccount::dispatch(GIOP_S &_0RL_s,const char *_0RL_op,CORBA::Boolean _0RL_response_expected)
{
  if (strcmp(_0RL_op,"creditInterest") == 0)
  {
    _0RL_s.RequestReceived();
        creditInterest();
    size_t _0RL_msgsize = (size_t) GIOP_S::ReplyHeaderSize();
    _0RL_s.InitialiseReply(GIOP::NO_EXCEPTION,(CORBA::ULong)_0RL_msgsize);
    _0RL_s.ReplyCompleted();
    return 1;
  }
  else if (_sk_Account::dispatch(_0RL_s,_0RL_op,_0RL_response_expected)) {
    return 1;
  }
  else {
    return 0;
  }
}

_sk_SavingsAccount::_sk_SavingsAccount (const omniORB::objectKey& k)
{
  omniRopeAndKey l(0,(CORBA::Octet*)&k,(CORBA::ULong)sizeof(k));
  setRopeAndKey(l,0);
}

omniORB::objectKey
_sk_SavingsAccount::_key()
{
  omniRopeAndKey l;
  getRopeAndKey(l);
  return (*((omniORB::objectKey*)l.key()));
}

SavingsAccount_ptr
SavingsAccount::_duplicate(SavingsAccount_ptr obj)
{
  if (CORBA::is_nil(obj))
    return SavingsAccount::_nil();
  CORBA::Object::_duplicate(obj);
  return obj;
}

SavingsAccount_ptr
SavingsAccount::_narrow(CORBA::Object_ptr obj)
{
  if (CORBA::is_nil(obj))
    return SavingsAccount::_nil();
  SavingsAccount_ptr e = (SavingsAccount_ptr) (obj->PR_getobj()->_realNarrow(SavingsAccount_IntfRepoID));
  if (e)
    return e;
  else
    return SavingsAccount::_nil();
}

void *
SavingsAccount::_widenFromTheMostDerivedIntf(const char *repoId,CORBA::Boolean is_cxx_type_id)
{
  if (is_cxx_type_id) return 0;
  if (!repoId)
    return (void *)((CORBA::Object_ptr)this);
  if (strcmp(SavingsAccount_IntfRepoID,repoId) == 0)
    return (void *)this;
  else {
    void *_p;
    if ((_p = Account::_widenFromTheMostDerivedIntf(repoId))) {
      return _p;
    }
    else
      return 0;
  }
}

CORBA::Boolean
SavingsAccount::_0RL_is_a(const char *base_repoId) {
  if (strcmp(base_repoId,(const char *)SavingsAccount_IntfRepoID)==0)
    return 1;
  else if (Account::_0RL_is_a(base_repoId))
    return 1;
  else
    return 0;
}

SavingsAccount_ptr
SavingsAccount_Helper::_nil() {
  return SavingsAccount::_nil();
}

CORBA::Boolean
SavingsAccount_Helper::is_nil(SavingsAccount_ptr p) {
  return CORBA::is_nil(p);
}

void
SavingsAccount_Helper::release(SavingsAccount_ptr p) {
  CORBA::release(p);
}

void
SavingsAccount_Helper::duplicate(SavingsAccount_ptr p) {
  CORBA::Object::_duplicate(p);
}

size_t
SavingsAccount_Helper::NP_alignedSize(SavingsAccount_ptr obj,size_t initialoffset) {
  return SavingsAccount::NP_alignedSize(obj,initialoffset);
}

void
SavingsAccount_Helper::marshalObjRef(SavingsAccount_ptr obj,NetBufferedStream &s) {
  SavingsAccount::marshalObjRef(obj,s);
}

SavingsAccount_ptr SavingsAccount_Helper::unmarshalObjRef(NetBufferedStream &s) {
  return SavingsAccount::unmarshalObjRef(s);
}

void
SavingsAccount_Helper::marshalObjRef(SavingsAccount_ptr obj,MemBufferedStream &s) {
  SavingsAccount::marshalObjRef(obj,s);
}

SavingsAccount_ptr SavingsAccount_Helper::unmarshalObjRef(MemBufferedStream &s) {
  return SavingsAccount::unmarshalObjRef(s);
}

const char *
SavingsAccount_proxyObjectFactory::irRepoId() const
{
  return (const char *)SavingsAccount_IntfRepoID;
}

CORBA::Object_ptr
SavingsAccount_proxyObjectFactory::newProxyObject(Rope *r,CORBA::Octet *key,size_t keysize,IOP::TaggedProfileList *profiles,CORBA::Boolean release)
{
  _proxy_SavingsAccount *p = new _proxy_SavingsAccount(r,key,keysize,profiles,release);
  if (!p) {
    throw CORBA::NO_MEMORY(0,CORBA::COMPLETED_NO);
  }
  return (CORBA::Object_ptr) p;
}

CORBA::Boolean
SavingsAccount_proxyObjectFactory::is_a(const char *base_repoId) const
{
  return SavingsAccount::_0RL_is_a(base_repoId);

}

SavingsAccount_ptr
SavingsAccount::_nil() {
  return SavingsAccount_proxyObjectFactory::_nil();
}

static const SavingsAccount_proxyObjectFactory SavingsAccount_proxyObjectFactory;
SavingsAccount_ptr SavingsAccount_proxyObjectFactory::__nil_SavingsAccount = 0;

