COBRA - whoops CORBA

By Ira Pohl   copyright 1999

Appears in the C++ Bookshelf:Distilled -published as an eBook by

Originally published as a Fatbrain column



CORBA is not a misspelling of a deadly viper. Common Object Request Broker Architecture (CORBA) provides an industry standard architecture for heterogeneous systems to share computing resources transparently. Michi Henning and Steve Vinoski have written the definitive book on CORBA programming in C++, Advanced CORBA Programming with C++.

Around 1,100 pages long, it is a long read. It's also deep; you should already know C++ thoroughly, and be familiar with the Interface Definition Language (IDL) and the way it maps into C++. This comprehensive guide is divided into six major parts, 22 chapters, and two appendices. Thankfully, it has a good index, some 40 pages long with approximately 90 entries per page.

To use CORBA you need to learn IDL. IDL is a specification language that looks like C++. It is used to specify, in a machine and programming language independent way, objects. Here are some simple examples taken from pp. 18-19:

IDL Program


interface Employee {

  long number ();



interface EmployeeRegistry {

  Employee lookup(in long emp_number);



interface Printer {

  void print();



interface ColorPrinter : Printer {

  enum ColorMode { BlackAndWhite, FullColor};

  void set_color(in ColorMode mode);



The idea of interface is found in Java. It is akin to a C++ abstract base class that only has pure virtual functions. On seeing the interface definition of Employee, a CORBA object is expected to implement its prescribed number operation. The lookup function in EmployeeRegistry has specified an argument as "in." This designation tells us that CORBA implementation expects this variable to be used for input, and most likely will be implemented as call by value. Other parameter possibilities are "out" and "inout."

CORBA descriptions also allow inheritance and use the colon notation of C++. Chapter 4, "The OMG Interface Definition Language" and Chapter 6, "Basic IDL-to-C++ Mapping" give a detailed description of much of IDL notation and C++ coding. These two chapters constitute 150 pages, so we are talking about learning a considerable amount of notation. As onerous as this is, seeing the many logical consistencies between IDL and C++ ameliorates the difficulty of learning the notation.

CORBA is a client-server methodology. You design the application's objects and define them in IDL. You can then use an IDL compiler that compiles IDL into client stubs and server skeletons. Next, you must declare and implement for each of your COBRA objects, a servant class. These perform the services that each object provides to its clients. You must write a server main(), which provides the flow of control for a C++ CORBA program. You compile and link the server code with the stubs and skeletons to make the server executable. Finally, you write, compile and link the client code with its generated stubs. These six major steps are outlined in detail in Advanced CORBA Programming with C++.

Chapter 3 is a complete, simple example of such a client-server application. The object is one that provides Greenwich Mean Time. The server uses an ORB to provide a service like this to any client needing current time. The IDL is


interface Time {  //see page 38 Henning and Vinoski

   TimeOfDay get_gmt();



The server code, including a main(), is two pages long and easy to follow for the experienced C++ programmer. What is nice about this example is that it is then clearly and thoroughly described in 11 pages.

The main example the book uses is a climate control system. This acts as a detailed case study of the use of a CORBA. It is detailed enough to be an exemplar of most critical code practices needed by a CORBA programmer. This example figures in the next 500 pages. The climate control system is a realistic distributed application. It is a set of thermostatic controls that handles temperatures and devices throughout a large building. The system has hundreds of thermometers monitoring temperature and a like number of thermostats maintaining desired temperatures. The system is centrally monitored by an operator, which can select desired temperatures throughout the facility. IDL is displayed for each of these critical elements. C++ code is developed, which fleshes out the important parts of the example.

This book is a major contribution to large-scale industrial code development. The bad news is that it is 1,100 pages of very serious, non-trivial reading. The good news is that it is the only book you should need on this important topic. The writing is clear and intelligent. The examples are serious and illuminating. This book is a necessary precondition for starting a serious CORBA project in C++.


CORBA is a capstone technology. That it works is a testament to the resources and growing maturity of the software industry. Its ideas are coherent and easy to state in a very simple fashion. Have one machine request a service from another machine. Have that service executed and have its result used by the first machine.  In practice the computer world is too diverse to make this an easy task. Manufacturers have different architectures, programming languages are suited to different domains. So an overarching concern is that it CORBA compliant system adhere to some standard. This is an organizational miracle.