The Bank Example

CORBA has a traditional example that is the equivalent of "Hello, world" in C. It's known as the Bank Example and consists of a simple method call that returns a bank balance. We're going to add some additional capabilities such as a deposit and withdraw method. It would also be a good idea to prohibit overdrafts on the account, so an exception will be used to block drawing out more than the account contents. The IDL for this example is in Listing 19.1.

Listing 19.1. Bank.idl
module Bank {
   exception WithdrawError {
      float current_balance;
   };

   interface Account {
      void deposit(in float amount);
      void withdraw(in float amount) raises (WithdrawError);
      float balance();
   };
};
					

The exception is declared with one data member. If the client ...

Get Borland® Delphi™ 6 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.