Guide to odlprep

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 record                        (1)
          First_Name  : attribute Unbounded_String;        (2)
          Family_Name : attribute Unbounded_String;
          State       : Natural  := 0;                     (3)
       end record ;
         
(1)
The keyword persistent denotes a type which will be derived from the OOS.Persisten.Object.
(2)
The keyword attribute denotes a component of the type as an attribute to be stored. The attribute will be stored with the component name (e.g. First_Name).
(3)
All type components which are not marked as an attribute are available during run time, but they are not persistent!