File: pobjcl.h

package info (click to toggle)
sdcc 3.8.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 99,212 kB
  • sloc: ansic: 918,594; cpp: 69,526; makefile: 56,790; sh: 29,616; asm: 12,364; perl: 12,136; yacc: 7,179; lisp: 1,672; python: 812; lex: 773; awk: 495; sed: 89
file content (234 lines) | stat: -rw-r--r-- 6,175 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*
 * Simulator of microcontrollers (pobjcl.h)
 *
 * Copyright (C) 1997,16 Drotos Daniel, Talker Bt.
 * 
 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
 *
 */

/* This file is part of microcontroller simulator: ucsim.

UCSIM is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

UCSIM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with UCSIM; see the file COPYING.  If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
/*@1@*/

#ifndef POBJ_HEADER
#define POBJ_HEADER

#include "ddconfig.h"

#include "pobjt.h"

#include "eventcl.h"
#include "charscl.h"


/*									    #
  ==========================================================================#
								    cl_base #
  ==========================================================================#
									    #
*/

class cl_abs_base
{
};

class cl_list;
class cl_event;

class cl_base: public cl_abs_base
{
private:
  /*const char * */chars name;
  class cl_base *parent;
  class cl_list *children;
public:
  cl_base(void);
  virtual ~cl_base(void);

  virtual int init(void);
  virtual const char *get_name(void) { return(name); }
  virtual const char *get_name(const char *def);
  virtual bool have_name(void) { return/*(name != 0)*/ !name.is_null(); }
  virtual bool have_real_name(void) { return/*(name != 0 && *name != '\0')*/ !name.empty(); }
  const char *set_name(const char *new_name);
  const char *set_name(const char *new_name, const char *def_name);
  bool is_named(const char *the_name);
  bool is_inamed(const char *the_name);

  class cl_base *get_parent(void) { return(parent); }
  int nuof_children(void);

  virtual void add_child(class cl_base *child);
  virtual void remove_child(class cl_base *child);
  virtual void remove_from_chain(void);
  virtual void unlink(void);
  virtual class cl_base *first_child(void);
  virtual class cl_base *next_child(class cl_base *child);

  virtual bool handle_event(class cl_event &event);
  virtual bool pass_event_down(class cl_event &event);
};


/*
 * Event
 */

class cl_event: public cl_base
{
protected:
  bool handled;
public:
  enum event what;
public:
  cl_event(enum event what_event);
  virtual ~cl_event(void);

  bool is_handled(void) { return(handled); }
  virtual void handle(void) { handled= true; }
};


/*									    #
  ==========================================================================#
								    cl_list #
  ==========================================================================#
									    #
*/

class cl_list: public cl_base
{
public:
  t_index	   count;
protected:
  void		   **Items;
  t_index	   Limit;
  t_index	   Delta;

public:
  cl_list(t_index alimit, t_index adelta, char *aname);
  cl_list(t_index alimit, t_index adelta, const char *aname);
  virtual ~cl_list(void);

  inline  void	   *at(t_index index)
  {
    if (index < 0 || index >= count)
      error(1, index);
    return (Items[index]);
  }
  class cl_base *object_at(t_index index);
  virtual t_index  index_of(void *item);
  virtual bool     index_of(void *item, t_index *idx);
  virtual void     *next(void *item);
  	  int	   get_count(void);
  virtual void     *pop(void);
  virtual void     *top(void);

  //void	   pack(void);
  virtual void	   set_limit(t_index alimit);

	  void	   free_at(t_index index);
          void     free_all(void);
	  void	   disconn_at(t_index index);
	  void	   disconn(void *item);
	  void	   disconn_all(void);

	  void	   add_at(t_index index, void *item);
	  void	   put_at(t_index index, void *item);
  virtual t_index  add(void *item);
  virtual t_index  add(class cl_base *item, class cl_base *parent);
  virtual void     push(void *item);

	  void	   *first_that(match_func test, void *arg);
	  void	   *last_that(match_func test, void *arg);
	  void	   for_each(iterator_func action, void *arg);

	  void	   error(t_index code, t_index info);
private:
  virtual void	   free_item(void *item);
};


/*									    #
  ==========================================================================#
							     cl_sorted_list #
  ==========================================================================#
									    #
*/

class cl_sorted_list: public cl_list
{
public:
  bool		   Duplicates;
public:
  cl_sorted_list(t_index alimit, t_index adelta, char *aname);
  cl_sorted_list(t_index alimit, t_index adelta, const char *aname);
  virtual ~cl_sorted_list(void);
  
  virtual bool	   search(void *key, t_index& index);
  virtual t_index  index_of(void *item);
  virtual t_index  add(void *item);
  virtual void	   *key_of(void *item);
private:
  virtual int	   compare(void *key1, void *key2)= 0;
};


/*									    #
  ==========================================================================#
							         cl_strings #
  ==========================================================================#
									    #
*/

class cl_strings: public cl_sorted_list
{
public:
  cl_strings(t_index alimit, t_index adelta, char *aname);
  cl_strings(t_index alimit, t_index adelta, const char *aname);
  virtual ~cl_strings(void);
  
private:
  virtual int	   compare(void *key1, void *key2);
  virtual void	   free_item(void *item);
};


/*									    #
  ==========================================================================#
							        cl_ustrings #
  ==========================================================================#
									    #
*/

class cl_ustrings: public cl_strings
{
public:
  cl_ustrings(t_index alimit, t_index adelta, char *aname);
  cl_ustrings(t_index alimit, t_index adelta, const char *aname);
  virtual ~cl_ustrings(void);
  
private:
  virtual int	   compare(void *key1, void *key2);
  virtual bool	   search(void *key, t_index &index);
};


#endif

/* End of pobj.h */