1 //////////////////////////////////////////////////////////////////////////////
4 // ADLib, Prop and their related set of tools and documentation are in the
5 // public domain. The author(s) of this software reserve no copyrights on
6 // the source code and any code generated using the tools. You are encouraged
7 // to use ADLib and Prop to develop software, in both academic and commercial
8 // settings, and are welcomed to incorporate any part of ADLib and Prop into
11 // Although you are under no obligation to do so, we strongly recommend that
12 // you give away all software developed using our tools.
14 // We also ask that credit be given to us when ADLib and/or Prop are used in
15 // your programs, and that this notice be preserved intact in all the source
18 // This software is still under development and we welcome(read crave for)
19 // any suggestions and help from the users.
23 //////////////////////////////////////////////////////////////////////////////
25 #ifndef persistent_objects_type_h
26 #define persistent_objects_type_h
28 //////////////////////////////////////////////////////////////////////////////
29 // This file describes the class PObjectType, which describes the type
30 // of a persistent object.
31 //////////////////////////////////////////////////////////////////////////////
33 #include <AD/generic/generic.h>
34 #include <AD/persist/pconfig.h>
37 //////////////////////////////////////////////////////////////////////////////
41 //////////////////////////////////////////////////////////////////////////////
46 //////////////////////////////////////////////////////////////////////////////
48 // Persistent objects types.
50 //////////////////////////////////////////////////////////////////////////////
52 PObjectType (const PObjectType
&);
53 void operator = (const PObjectType
&);
57 { P_OBJECT_TYPEID unique_id
; // unique id for each type
58 const char * type_name
; // name of object type
59 int type_name_len
; // length of type name
60 PBaseFactory
* factory
; // object factory
64 // index into a table of unique id during execution
65 friend class PBaseFactory
;
68 static Entry
* lookup_entry (const char *);
71 //////////////////////////////////////////////////////////////////////////
72 // Constructor and destructor
73 //////////////////////////////////////////////////////////////////////////
74 inline PObjectType (Entry
* e
= 0) : entry(e
) {}
75 PObjectType (const char * name
);
76 virtual ~PObjectType ();
78 friend std::ostream
& operator << ( std::ostream
&, const PObjectType
& );
79 inline Bool
operator == (const PObjectType
& id
) const
80 { return entry
== id
.entry
; }
81 inline Bool
operator != (const PObjectType
& id
) const
82 { return entry
!= id
.entry
; }
83 const char * name () const;
84 static int number_of_types ();
86 //////////////////////////////////////////////////////////////////////////
88 // Interface to the persistent object classes
90 //////////////////////////////////////////////////////////////////////////
92 //////////////////////////////////////////////////////////////////////////
94 // Read and write methods. We can't read and write PObjectType
95 // arbitrarily from and to the persistent streams.
97 //////////////////////////////////////////////////////////////////////////
98 void write ( Postream
& ) const;
99 void read ( Pistream
& );