initial
[prop.git] / include / AD / object / object.h
blob1ebb83418a1e81e2cf60be5c1443f41c45d06367
1 //////////////////////////////////////////////////////////////////////////////
2 // NOTICE:
3 //
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
9 // your programs.
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
16 // code.
18 // This software is still under development and we welcome any suggestions
19 // and help from the users.
21 // Allen Leung
22 // 1994
23 //////////////////////////////////////////////////////////////////////////////
25 #ifndef ADLib_object_hierarchy_h
26 #define ADLib_object_hierarchy_h
28 #include <iostream.h>
29 #include <AD/object/obintern.h>
31 /////////////////////////////////////////////////////////////////////////////
32 // (Opaque) forward declarations
33 /////////////////////////////////////////////////////////////////////////////
35 /////////////////////////////////////////////////////////////////////////////
36 //
39 /////////////////////////////////////////////////////////////////////////////
40 class Object : public ObjIntern {
41 public:
43 //////////////////////////////////////////////////////////////////////////
44 // Constructor and destructor
45 //////////////////////////////////////////////////////////////////////////
46 Object() {}
47 virtual ~Object();
49 //////////////////////////////////////////////////////////////////////////
50 // Name of class; each class should have this redefined
51 //////////////////////////////////////////////////////////////////////////
52 virtual const char * className() const;
54 //////////////////////////////////////////////////////////////////////////
55 // Object dependency:
56 //
57 // changed(Object& obj) --- invoked if obj is changed and `this' is
58 // dependent on obj.
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??
83 #endif