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 free 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 any suggestions
19 // and help from the users.
23 //////////////////////////////////////////////////////////////////////////////
25 #ifndef ADLib_object_hierarchy_h
26 #define ADLib_object_hierarchy_h
29 #include <AD/object/obintern.h>
31 /////////////////////////////////////////////////////////////////////////////
32 // (Opaque) forward declarations
33 /////////////////////////////////////////////////////////////////////////////
35 /////////////////////////////////////////////////////////////////////////////
39 /////////////////////////////////////////////////////////////////////////////
40 class Object
: public ObjIntern
{
43 //////////////////////////////////////////////////////////////////////////
44 // Constructor and destructor
45 //////////////////////////////////////////////////////////////////////////
49 //////////////////////////////////////////////////////////////////////////
50 // Name of class; each class should have this redefined
51 //////////////////////////////////////////////////////////////////////////
52 virtual const char * className() const;
54 //////////////////////////////////////////////////////////////////////////
57 // changed(Object& obj) --- invoked if obj is changed and `this' is
59 // deleled(Object& obj) --- invoked if obj is about to die and `this'
60 // is dependent on obj.
61 //////////////////////////////////////////////////////////////////////////
62 virtual void changed(Object
&); // default is an nop
63 virtual void deleted(Object
&); // default is an nop
64 virtual void dependsOn(Object
&);
65 virtual Bool
isDependedOn(const Object
&);
66 virtual void removeDependencyOn(Object
&);
67 virtual void removeAllDependency();
69 //////////////////////////////////////////////////////////////////////////
70 // Miscellaneous operations
71 //////////////////////////////////////////////////////////////////////////
72 virtual unsigned int hash() const { return (unsigned int)this; }
73 Bool
eq(const Object
& o
) const { return this == &o
; }
74 virtual Bool
equal(const Object
& o
) const { return this == &o
; }
76 //////////////////////////////////////////////////////////////////////////
77 // Debugging and tracing
78 //////////////////////////////////////////////////////////////////////////
79 virtual ostream
& dump(ostream
&) const; // print contents
80 virtual Bool
ok() const { return true; } // invariants satisfied??