2 * Simulator of microcontrollers (pobjcl.h)
4 * Copyright (C) 1997 Drotos Daniel
6 * To contact author send email to dr.dkdb@gmail.com
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
40 ==========================================================================#
42 ==========================================================================#
53 class cl_base
: public cl_abs_base
56 /*const char * */chars name
;
57 class cl_base
*parent
;
58 class cl_list
*children
;
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
);
92 class cl_event
: public cl_base
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; }
108 ==========================================================================#
110 ==========================================================================#
114 class cl_list
: public cl_base
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
)
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
);
139 virtual void *pop(void);
140 virtual void *top(void);
143 virtual void set_limit(t_index alimit
);
145 void free_at(t_index index
);
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
);
163 virtual void free_item(void *item
);
168 ==========================================================================#
170 ==========================================================================#
174 class cl_sorted_list
: public cl_list
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;
187 virtual int compare(const void *key1
, const void *key2
)= 0;
192 ==========================================================================#
194 ==========================================================================#
198 class cl_strings
: public cl_sorted_list
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
); }
206 virtual int compare(const void *key1
, const void *key2
);
207 virtual void free_item(void *item
);
212 ==========================================================================#
214 ==========================================================================#
218 class cl_ustrings
: public cl_strings
221 cl_ustrings(t_index alimit
, t_index adelta
, const char *aname
);
222 virtual ~cl_ustrings(void);
225 virtual int compare(const void *key1
, const void *key2
);
226 virtual bool search(const void *key
, t_index
&index
);
232 /* End of utils.src/pobj.h */