blob: e889fea0c2cca76acc9c4e70af56f8f55d082b07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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 (CORBA::Environment &)
ACE_THROW_SPEC ((CORBA::SystemException))
{
return balance_;
}
void
Account_i::deposit (CORBA::Float deposit,
CORBA::Environment &)
ACE_THROW_SPEC ((CORBA::SystemException))
{
balance_ += deposit;
}
void
Account_i::withdraw (CORBA::Float withdrawl,
CORBA::Environment &ACE_TRY_ENV)
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 (CORBA::Environment &)
ACE_THROW_SPEC ((CORBA::SystemException))
{
return CORBA::string_dup (this->name_.in ());
}
void
Account_i::name (const char *name,
CORBA::Environment &)
ACE_THROW_SPEC ((CORBA::SystemException))
{
this->name_ = CORBA::string_dup (name);
}
|