diff options
Diffstat (limited to 'TAO/examples/Simple/bank/Account_i.cpp')
-rw-r--r-- | TAO/examples/Simple/bank/Account_i.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/TAO/examples/Simple/bank/Account_i.cpp b/TAO/examples/Simple/bank/Account_i.cpp new file mode 100644 index 00000000000..2f150afc54a --- /dev/null +++ b/TAO/examples/Simple/bank/Account_i.cpp @@ -0,0 +1,79 @@ +// $Id$ + +#include "Account_i.h" + +ACE_RCSID(Bank, Account_i, "$Id$") + +// Constructor + +Account_i::Account_i (void) +{ + // no-op +} + +Account_i::Account_i (const char *name, + CORBA::Float balance) + + : balance_ (balance), + name_ (CORBA::string_dup (name)) +{ +} + +// Destructor + +Account_i::~Account_i (void) +{ + CORBA::string_free (name_); +} + +// Set the ORB pointer. + +void +Account_i::orb (CORBA::ORB_ptr o) +{ + this->orb_ = CORBA::ORB::_duplicate (o); +} + +// Return the current balance on the server. + +CORBA::Float +Account_i::balance (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return balance_; +} + +void +Account_i::deposit (CORBA::Float deposit + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + balance_ += deposit; +} + +void +Account_i::withdraw (CORBA::Float withdrawl + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Bank::Account::Overdraft)) +{ + if (balance_ >= withdrawl) + balance_ -= withdrawl; + else + ACE_THROW (Bank::Account::Overdraft ("Exception::Overdraft\n")); +} + +char * +Account_i::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return CORBA::string_dup (this->name_.in ()); +} + +void +Account_i::name (const char *name + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->name_ = CORBA::string_dup (name); +} |