| 1 | 
 | 
|---|
| 2 | /** \page class The Described Class Library
 | 
|---|
| 3 | 
 | 
|---|
| 4 | The class library provides the DescribedClass base class which provides
 | 
|---|
| 5 | mechanisms that allows programmers to retrieve information about a
 | 
|---|
| 6 | DescribedClass descendant's name; parents; and default, StateIn, and KeyVal
 | 
|---|
| 7 | constructors.
 | 
|---|
| 8 | 
 | 
|---|
| 9 | The special nature of described classes requires that the base class,
 | 
|---|
| 10 | DescribedClass, cannot provide everything needed.  To assist the user in
 | 
|---|
| 11 | setting up described classes a helper class, ClassDesc, is provided.
 | 
|---|
| 12 | Foreach descendent of DescribedClass an object of type ClassDesc must be
 | 
|---|
| 13 | created.  These objects should be static so they are initialized before
 | 
|---|
| 14 | main is entered.
 | 
|---|
| 15 | 
 | 
|---|
| 16 | The ClassDesc constructor takes the following arguments:
 | 
|---|
| 17 | 
 | 
|---|
| 18 | <dl>
 | 
|---|
| 19 | <dt><b>const std::type_info& typeinfo</b>
 | 
|---|
| 20 |     <dd>The type_info for this class, as returned by the C++ typeid operator.
 | 
|---|
| 21 | <dt><b>const char *name</b>
 | 
|---|
| 22 |     <dd>The name of this class.
 | 
|---|
| 23 | <dt><b>int version</b>
 | 
|---|
| 24 |     <dd>The version of this class.  This is used to enable restoration
 | 
|---|
| 25 |         of objects that were saved with older versions of a class.
 | 
|---|
| 26 |         Version numbers must be 1 or greater.
 | 
|---|
| 27 | <dt><b>const char *parents</b>
 | 
|---|
| 28 |     <dd>The parents of this class.  This must be given exactly
 | 
|---|
| 29 |         as it is given in the class declaration, including all
 | 
|---|
| 30 |         qualifiers.
 | 
|---|
| 31 | <dt><b>DescribedClass* (*ctor)()</b>
 | 
|---|
| 32 |     <dd>A function that creates an object of this type using the
 | 
|---|
| 33 |         default constructor.  The default is 0 (meaning that no
 | 
|---|
| 34 |         constructor is available.
 | 
|---|
| 35 | <dt><b>DescribedClass* (*keyval_ctor)(const Ref<KeyVal>&)</b>
 | 
|---|
| 36 |     <dd>A function that creates an object of this type using the
 | 
|---|
| 37 |         KeyVal constructor. The default is 0.
 | 
|---|
| 38 | <dt><b>DescribedClass* (*statein_ctor)(StateIn&)</b>
 | 
|---|
| 39 |     <dd>A function that creates an object of this type using the
 | 
|---|
| 40 |         StateIn constructor. The default is 0.
 | 
|---|
| 41 | </dl>
 | 
|---|
| 42 | 
 | 
|---|
| 43 | For example, consider the class, D:
 | 
|---|
| 44 | 
 | 
|---|
| 45 | <pre>
 | 
|---|
| 46 | class D: public B, public C {
 | 
|---|
| 47 |   public:
 | 
|---|
| 48 |     D();    
 | 
|---|
| 49 | };
 | 
|---|
| 50 | </pre>
 | 
|---|
| 51 | 
 | 
|---|
| 52 | The file implementing D would contain the following line:
 | 
|---|
| 53 | 
 | 
|---|
| 54 | <pre>
 | 
|---|
| 55 | static ClassDesc D_cd(typeid(D),"D",1,"public B, public C",create\<D\>);
 | 
|---|
| 56 | </pre>
 | 
|---|
| 57 | 
 | 
|---|
| 58 | */
 | 
|---|