lotus

previous page: 9.3) Odapter/OpenODB: Odapter and Smalltalk
  
page up: Object-Oriented Technology FAQ
  
next page: 9.3) Odapter/OpenODB: Features and Benefits

9.3) Odapter/OpenODB: Odapter and C++




Description

This article is from the Object-Oriented Technology FAQ, by Bob Hathaway rjh@geodesic.com with numerous contributions by others.

9.3) Odapter/OpenODB: Odapter and C++

For C++ developers, once the corresponding C++
model is created, Odapter provides the abilility to
manage C++ objects stored in the underlying
relational database, as shown in Figure 4.

void printFlight() 
{ 
   int i; 
   ODBType Flight ("Flight"); 
   ODBBag allFlights=Flight.allObjects(); 
   ODBFunc flightno("flighno"); 
  
   for(i=0;i<allFlights.size();i++){ 
      cout<<flightno(allFlights[i]); 
   } 
} 
Figure 4 

Figure 4 shows a C++ version of the Smalltalk
example in Figure 3. That is, Figure 4 shows how to
access all the flight objects shown in Figure 2 and
prints the flight number associated with each
flight object.

The Odapter C++ library includes a set of classes
(e.g. ODBType, ODBClass, ODBFunc, ODBBag) and
corresponding member functions (e.g. allObjects).
User-defined classes (Flight) and member functions
(flightno) are also shown. In Figure 4, all Odapter
calls are in italics.

Odapter and C-linkable Languages

For traditional developers using C, or any
languages linkable with C, the object-oriented
features are provided by Odapter. Odapter objects
are manipulated by embedding OSQL statements in the
C program, similar to the db.execosql call shown in
Figure 4. In addition, the C interface requires the
conversion of data types from Odapter to C.

By embedding Odapter calls in a C program, the C
language becomes object-oriented.

 

Continue to:













TOP
previous page: 9.3) Odapter/OpenODB: Odapter and Smalltalk
  
page up: Object-Oriented Technology FAQ
  
next page: 9.3) Odapter/OpenODB: Features and Benefits