b7ccb87cc4690ab37dd4c823cb1e380e1fe985a1
[fw/sdcc] / sim / ucsim / pobjcl.h
1 /*
2  * Simulator of microcontrollers (pobjcl.h)
3  *
4  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
5  * 
6  * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
7  *
8  */
9
10 /* This file is part of microcontroller simulator: ucsim.
11
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.
16
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.
21
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@*/
27
28 #ifndef POBJ_HEADER
29 #define POBJ_HEADER
30
31 #include "ddconfig.h"
32
33 #include "pobjt.h"
34
35
36 /*                                                                          #
37   ==========================================================================#
38                                                                     cl_base #
39   ==========================================================================#
40                                                                             #
41 */
42
43 class cl_base
44 {
45 private:
46   char *name;
47 public:
48   cl_base(void);
49   virtual ~cl_base(void);
50
51   virtual int init(void);
52   virtual char *get_name(void) { return(name); }
53   virtual char *get_name(char *def);
54   virtual bool have_name(void) { return(name != 0); }
55   virtual bool have_real_name(void) { return(name != 0 && *name != '\0'); }
56   char *set_name(char *new_name);
57 };
58
59
60 /*                                                                          #
61   ==========================================================================#
62                                                                     cl_list #
63   ==========================================================================#
64                                                                             #
65 */
66
67 class cl_list: public cl_base
68 {
69 public:
70   t_index          count;
71 protected:
72   void             **Items;
73   t_index          Limit;
74   t_index          Delta;
75
76 public:
77   cl_list(t_index alimit, t_index adelta);
78   virtual ~cl_list(void);
79
80           void     *at(t_index index);
81   virtual t_index  index_of(void *item);
82   virtual bool     index_of(void *item, t_index *idx);
83           int      get_count(void);
84   virtual void     *pop(void);
85   virtual void     *top(void);
86
87   //void           pack(void);
88   virtual void     set_limit(t_index alimit);
89
90           void     free_at(t_index index);
91           void     free_all(void);
92           void     disconn_at(t_index index);
93           void     disconn(void *item);
94           void     disconn_all(void);
95
96           void     add_at(t_index index, void *item);
97           void     put_at(t_index index, void *item);
98   virtual t_index  add(void *item);
99   virtual void     push(void *item);
100
101           void     *first_that(match_func test, void *arg);
102           void     *last_that(match_func test, void *arg);
103           void     for_each(iterator_func action, void *arg);
104
105           void     error(t_index code, t_index info);
106 private:
107   virtual void     free_item(void *item);
108 };
109
110
111 /*                                                                          #
112   ==========================================================================#
113                                                              cl_sorted_list #
114   ==========================================================================#
115                                                                             #
116 */
117
118 class cl_sorted_list: public cl_list
119 {
120 public:
121   bool             Duplicates;
122
123   cl_sorted_list(t_index alimit, t_index adelta);
124   virtual ~cl_sorted_list(void);
125   
126   virtual bool     search(void *key, t_index& index);
127   virtual t_index  index_of(void *item);
128   virtual t_index  add(void *item);
129   virtual void     *key_of(void *item);
130 private:
131   virtual int      compare(void *key1, void *key2)= 0;
132 };
133
134
135 /*                                                                          #
136   ==========================================================================#
137                                                                  cl_strings #
138   ==========================================================================#
139                                                                             #
140 */
141
142 class cl_strings: public cl_sorted_list
143 {
144 public:
145   cl_strings(t_index alimit, t_index adelta);
146   virtual ~cl_strings(void);
147   
148 private:
149   virtual int      compare(void *key1, void *key2);
150   virtual void     free_item(void *item);
151 };
152
153
154 /*                                                                          #
155   ==========================================================================#
156                                                                 cl_ustrings #
157   ==========================================================================#
158                                                                             #
159 */
160
161 class cl_ustrings: public cl_strings
162 {
163 public:
164   cl_ustrings(t_index alimit, t_index adelta);
165   virtual ~cl_ustrings(void);
166   
167 private:
168   virtual int      compare(void *key1, void *key2);
169   virtual bool     search(void *key, t_index &index);
170 };
171
172
173 #endif
174
175 /* End of pobj.h */