[80] | 1 | /********************************************************************** <BR>
|
---|
| 2 | This file is part of Crack dot Com's free source code release of
|
---|
| 3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
| 4 | information about compiling & licensing issues visit this URL</a>
|
---|
| 5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
| 6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
| 7 | ***********************************************************************/
|
---|
| 8 |
|
---|
| 9 | #ifndef LI_OBJREF_HH
|
---|
| 10 | #define LI_OBJREF_HH
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | #include "lisp/li_types.hh"
|
---|
| 14 | #include "global_id.hh"
|
---|
| 15 | #include "lisp/li_class.hh"
|
---|
| 16 |
|
---|
| 17 | class g1_object_class;
|
---|
| 18 | class g1_draw_context_class;
|
---|
| 19 |
|
---|
| 20 | extern li_type_number li_g1_ref_type_number;
|
---|
| 21 | class li_g1_ref : public li_object
|
---|
| 22 | {
|
---|
| 23 | friend class li_g1_ref_function;
|
---|
| 24 | w32 _global_id;
|
---|
| 25 | public:
|
---|
| 26 | li_g1_ref(w32 global_id)
|
---|
| 27 | : li_object(li_g1_ref_type_number)
|
---|
| 28 | {
|
---|
| 29 | _global_id=global_id;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | li_g1_ref(g1_object_class *o);
|
---|
| 33 |
|
---|
| 34 | w32 id() { return _global_id; }
|
---|
| 35 | g1_object_class *value()
|
---|
| 36 | {
|
---|
| 37 | if (g1_global_id.check_id(_global_id))
|
---|
| 38 | return g1_global_id.get(_global_id);
|
---|
| 39 | else
|
---|
| 40 | return 0;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | static li_g1_ref *get(li_object *o, li_environment *env)
|
---|
| 44 | {
|
---|
| 45 | check_type(o, li_g1_ref_type_number, env);
|
---|
| 46 | return ((li_g1_ref *)o);
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | void draw(g1_object_class *start, w32 color, g1_draw_context_class *context);
|
---|
| 50 | } ;
|
---|
| 51 |
|
---|
| 52 | li_g1_ref *li_g1_null_ref();
|
---|
| 53 |
|
---|
| 54 | // this li_object stores a list of references to g1_object
|
---|
| 55 | // the storage is an array of w32, the first being how many are in list
|
---|
| 56 | // the rest are actual references
|
---|
| 57 |
|
---|
| 58 | extern li_type_number li_g1_ref_list_type_number;
|
---|
| 59 | class li_g1_ref_list : public li_object
|
---|
| 60 | {
|
---|
| 61 | friend class li_g1_ref_list_function;
|
---|
| 62 | w32 *list;
|
---|
| 63 | void free();
|
---|
| 64 | public:
|
---|
| 65 | li_g1_ref_list *clone();
|
---|
| 66 | li_g1_ref_list()
|
---|
| 67 | : li_object(li_g1_ref_list_type_number)
|
---|
| 68 | {
|
---|
| 69 | list=0;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | int size() { if (!list) return 0; else return list[0]; }
|
---|
| 74 |
|
---|
| 75 | w32 get_id(int list_num);
|
---|
| 76 | g1_object_class *value(int list_num);
|
---|
| 77 |
|
---|
| 78 | void add(w32 id);
|
---|
| 79 | void add(g1_object_class *obj);
|
---|
| 80 |
|
---|
| 81 | void remove(w32 id);
|
---|
| 82 | void remove(g1_object_class *o);
|
---|
| 83 |
|
---|
| 84 | // gets rid of invalid object id's that might be in the list
|
---|
| 85 | void compact();
|
---|
| 86 |
|
---|
| 87 | int find(w32 id); // return -1 if not found in list, else returns position
|
---|
| 88 | int find(g1_object_class *o); // return -1 if not found in list, else returns position
|
---|
| 89 |
|
---|
| 90 | static li_g1_ref_list *get(li_object *o, li_environment *env)
|
---|
| 91 | {
|
---|
| 92 | check_type(o, li_g1_ref_list_type_number, env);
|
---|
| 93 | return ((li_g1_ref_list *)o);
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | void draw(g1_object_class *start, w32 color, g1_draw_context_class *context);
|
---|
| 97 | } ;
|
---|
| 98 |
|
---|
| 99 | struct li_g1_ref_class_member : public li_class_member
|
---|
| 100 | {
|
---|
| 101 | li_g1_ref_class_member(char *name) : li_class_member(name) {}
|
---|
| 102 | li_g1_ref *operator()() { return li_g1_ref::get(li_this->get(*this),0); }
|
---|
| 103 | };
|
---|
| 104 |
|
---|
| 105 | struct li_g1_ref_list_class_member : public li_class_member
|
---|
| 106 | {
|
---|
| 107 | li_g1_ref_list_class_member(char *name) : li_class_member(name) {}
|
---|
| 108 | li_g1_ref_list *operator()() { return li_g1_ref_list::get(li_this->get(*this),0); }
|
---|
| 109 | };
|
---|
| 110 |
|
---|
| 111 |
|
---|
| 112 | #endif
|
---|