| User's Guide: Small Ada 95 Object Database; Version 0.1.0; Document Revision $Revision: 1.9 $ | ||
|---|---|---|
| Prev | Chapter 4. Development Guide | Next |
The tool odlprep is a preprocessor for Ada 95 units supporting extensions which are used to add persistency related information to the Ada 95 language.
Odlprep implements an extension of Ada 95 by simply inserting the source code to implement in extension into the output files. The language extensionis called odl and focuses on the type definitions of Ada 95. The syntaxof this extension is show below:
Example 4-2. odl syntax
type <name> is { persistent | isa <parent> } record
<field> : [ attribute ] <typename> [ := <initializer> ]
end record;
The keyword persistent indicates, that the type is to be handled as an persistent type. The keyword isa indicates the this declaration is the extension of the given parent, which in turn is expected to be an persistent data type.
The odlprep takes as input a GNAT compilation unit which means the specification file with the extension .ods and the body file with the extension .odb and creates out of this the .adb and .ads files which can be compiled by GNAT. A typical usage example is shown below:
Example 4-3. Using odlprep with a make file
include ../../make.conf
targets=sdbclient
preptargets=$(subst .ods,.ads,$(wildcard *.ods)) $(subst .odb,.adb,$(wildcard *.odb))
all :: $(targets)
person.adb: person.odb person.ods
$(ODLPREP) $*
sdbclient: sdbclient.adb person.adb person.ads
$(ADACC) -g -I$(PREFIX) sdbclient.adb $(APP_CFLAGS) $(APP_BARGS) $(CLI_LARGS)
A typical example of a persistent object definition is shown below:
Example 4-4. persistent data type
type Object is persistent recordFirst_Name : attribute Unbounded_String;
Family_Name : attribute Unbounded_String; State : Natural := 0;
end record ;


