|User's Guide: A Framework for Object Persistency for GNAT; Version 0.6.1; Document Revision $Revision: 1.17 $|
Building an application using persistent objects requires to defined the objects to be handled as persistent objects and to add some basic glue code to your application as shown below:
Example 5-1. A minimal Application
with MyObject; with ODB.Persistent; with ODB.Storage.File; ...... use ODB; procedure Main is O : ODB.Reference ; File_Store : File.Object; begin File.Load(File_Store); O := Lookup_Object( "First_Object" ); if O = null then O := new MyObject.Object; Object_Name( O, "First_Object" ); O.A := 1; end if; ........... do some thing ...... File.Save(File_Store); exception when Others => ,....... end Main;
Upon start of the application, it will be checked if the object is already known in the persistency store with the name "First_Object". If not, the object will be allocated by means of the new method.