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 class_and_metaclass_base_classes_h
26 #define class_and_metaclass_base_classes_h
28 #include <AD/objc/objc.h> // object base class
30 //////////////////////////////////////////////////////////////////////////////
31 // Forward and opaque definitions
32 //////////////////////////////////////////////////////////////////////////////
33 class O_Class
; // class object base class
34 class O_MetaClass
; // metaclass object base class
35 class O_Protocol
; // protcol base class
36 class O_SelectorCache
; // cache for a selector
37 class O_MethodTable
; // method table
39 //////////////////////////////////////////////////////////////////////////////
40 // Definition of class O_Class
41 //////////////////////////////////////////////////////////////////////////////
42 class O_Class
: public O_Object
{
43 O_Class(const O_Class
&); // no copy constructor
44 void operator = (const O_Class
&); // no assignment
46 ///////////////////////////////////////////////////////////////////////////
47 // Description for a class
48 ///////////////////////////////////////////////////////////////////////////
49 O_Class
* super_class
; // super class in the hierarchy
50 O_MethodTable
* method_table
; // table of selectors -> method
51 O_SelectorCache
* selector_cache
; // method cache
53 ///////////////////////////////////////////////////////////////////////////
54 // Some imported types
55 ///////////////////////////////////////////////////////////////////////////
56 typedef O_Object Super
;
57 typedef Super::ObjectMethod ObjectMethod
;
58 typedef Super::O_SEL O_SEL
;
62 ///////////////////////////////////////////////////////////////////////////
63 // Constructor and destructor
64 ///////////////////////////////////////////////////////////////////////////
65 O_Class(O_Class
* my_super_class
, O_MetaClass
* my_meta_class
);
68 ///////////////////////////////////////////////////////////////////////////
70 ///////////////////////////////////////////////////////////////////////////
71 inline const O_Class
* my_super() const { return super_class
; }
72 inline O_Class
* my_super() { return super_class
; }
74 ///////////////////////////////////////////////////////////////////////////
75 // Methods for manipulating the method table and cache
76 ///////////////////////////////////////////////////////////////////////////
77 virtual ObjectMethod
lookup_method (O_SEL
);
78 virtual void add_method (O_SEL
, ObjectMethod
);
79 virtual void delete_method (O_SEL
);
80 virtual Bool
is_defined (O_SEL
) const;
81 virtual Bool
can_understand (O_SEL
);
84 //////////////////////////////////////////////////////////////////////////////
85 // Definition of class MetaClass
86 //////////////////////////////////////////////////////////////////////////////
87 class O_MetaClass
: public O_Class
{
88 O_MetaClass(const O_MetaClass
&); // no copy constructor
89 void operator = (const O_MetaClass
&); // no assignment
91 ///////////////////////////////////////////////////////////////////////////
92 // Some imported types
93 ///////////////////////////////////////////////////////////////////////////
94 typedef O_Class Super
;
95 typedef Super::ObjectMethod ObjectMethod
;
96 typedef Super::O_SEL O_SEL
;
100 ///////////////////////////////////////////////////////////////////////////
101 // Constructor and destructor
102 ///////////////////////////////////////////////////////////////////////////
103 O_MetaClass(O_Class
* my_super_class
, O_MetaClass
* my_meta_class
);
104 virtual ~O_MetaClass();