[ucsim] Update email and file info, fix stm8 flash controller
[sdcc.git] / sdcc / sim / ucsim / src / core / utils.src / pobjcl.h
blob7bf5cdad9e5bdc28d494483332371b8109539b34
1 /*
2 * Simulator of microcontrollers (pobjcl.h)
4 * Copyright (C) 1997 Drotos Daniel
5 *
6 * To contact author send email to dr.dkdb@gmail.com
8 */
10 /* This file is part of microcontroller simulator: ucsim.
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING. If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 02111-1307, USA. */
26 /*@1@*/
28 #ifndef POBJ_HEADER
29 #define POBJ_HEADER
31 #include "ddconfig.h"
33 #include "pobjt.h"
35 #include "eventcl.h"
36 #include "charscl.h"
39 /* #
40 ==========================================================================#
41 cl_base #
42 ==========================================================================#
46 class cl_abs_base
50 class cl_list;
51 class cl_event;
53 class cl_base: public cl_abs_base
55 private:
56 /*const char * */chars name;
57 class cl_base *parent;
58 class cl_list *children;
59 public:
60 cl_base(void);
61 virtual ~cl_base(void);
63 virtual int init(void);
64 virtual const char *get_name(void) const { return(name); }
65 virtual const char *get_name(const char *def) const;
66 virtual bool have_name(void) { return/*(name != 0)*/ !name.is_null(); }
67 virtual bool have_real_name(void) { return/*(name != 0 && *name != '\0')*/ !name.empty(); }
68 const char *set_name(const char *new_name);
69 const char *set_name(const char *new_name, const char *def_name);
70 virtual bool is_named(const char *the_name) const;
71 virtual bool is_inamed(const char *the_name) const;
73 class cl_base *get_parent(void) { return(parent); }
74 int nuof_children(void);
76 virtual void add_child(class cl_base *child);
77 virtual void remove_child(class cl_base *child);
78 virtual void remove_from_chain(void);
79 virtual void unlink(void);
80 virtual class cl_base *first_child(void);
81 virtual class cl_base *next_child(class cl_base *child);
83 virtual bool handle_event(class cl_event &event);
84 virtual bool pass_event_down(class cl_event &event);
89 * Event
92 class cl_event: public cl_base
94 protected:
95 bool handled;
96 public:
97 enum event what;
98 public:
99 cl_event(enum event what_event);
100 virtual ~cl_event(void);
102 bool is_handled(void) { return(handled); }
103 virtual void handle(void) { handled= true; }
107 /* #
108 ==========================================================================#
109 cl_list #
110 ==========================================================================#
114 class cl_list: public cl_base
116 public:
117 t_index count;
118 protected:
119 void **Items;
120 t_index Limit;
121 t_index Delta;
123 public:
124 cl_list(void);
125 cl_list(t_index alimit, t_index adelta, const char *aname);
126 virtual ~cl_list(void);
128 inline void *at(t_index index)
130 if (index < 0 || index >= count)
131 error(1, index);
132 return (Items[index]);
134 class cl_base *object_at(t_index index);
135 virtual t_index index_of(const void *item);
136 virtual bool index_of(const void *item, t_index *idx);
137 virtual void *next(void *item);
138 int get_count(void);
139 virtual void *pop(void);
140 virtual void *top(void);
142 //void pack(void);
143 virtual void set_limit(t_index alimit);
145 void free_at(t_index index);
146 void free_all(void);
147 void disconn_at(t_index index);
148 void disconn(const void *item);
149 void disconn_all(void);
151 void add_at(t_index index, void *item);
152 void put_at(t_index index, void *item);
153 virtual t_index add(void *item);
154 virtual t_index add(class cl_base *item, class cl_base *parent);
155 virtual void push(void *item);
157 void *first_that(match_func test, const void *arg);
158 void *last_that(match_func test, const void *arg);
159 void for_each(iterator_func action, void *arg);
161 void error(t_index code, t_index info);
162 private:
163 virtual void free_item(void *item);
167 /* #
168 ==========================================================================#
169 cl_sorted_list #
170 ==========================================================================#
174 class cl_sorted_list: public cl_list
176 public:
177 bool Duplicates;
178 public:
179 cl_sorted_list(t_index alimit, t_index adelta, const char *aname);
180 virtual ~cl_sorted_list(void);
182 virtual bool search(const void *key, t_index& index);
183 virtual t_index index_of(const void *item);
184 virtual t_index add(void *item);
185 virtual const void *key_of(const void *item) const;
186 private:
187 virtual int compare(const void *key1, const void *key2)= 0;
191 /* #
192 ==========================================================================#
193 cl_strings #
194 ==========================================================================#
198 class cl_strings: public cl_sorted_list
200 public:
201 cl_strings(t_index alimit, t_index adelta, const char *aname);
202 virtual ~cl_strings(void);
203 inline const char *at(t_index index) { return (char *)cl_sorted_list::at(index); }
205 private:
206 virtual int compare(const void *key1, const void *key2);
207 virtual void free_item(void *item);
211 /* #
212 ==========================================================================#
213 cl_ustrings #
214 ==========================================================================#
218 class cl_ustrings: public cl_strings
220 public:
221 cl_ustrings(t_index alimit, t_index adelta, const char *aname);
222 virtual ~cl_ustrings(void);
224 private:
225 virtual int compare(const void *key1, const void *key2);
226 virtual bool search(const void *key, t_index &index);
230 #endif
232 /* End of utils.src/pobj.h */