Merge branch ucsim-034-pre3 to main trunk; new version 0.4
[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 public:
46   cl_base(void);
47   virtual ~cl_base(void);
48
49   virtual int init(void);
50 };
51
52
53 /*                                                                          #
54   ==========================================================================#
55                                                                     cl_list #
56   ==========================================================================#
57                                                                             #
58 */
59
60 class cl_list: public cl_base
61 {
62 public:
63   t_index          count;
64 protected:
65   void             **Items;
66   t_index          Limit;
67   t_index          Delta;
68
69 public:
70   cl_list(t_index alimit, t_index adelta);
71   virtual ~cl_list(void);
72
73           void     *at(t_index index);
74   virtual t_index  index_of(void *item);
75   virtual bool     index_of(void *item, t_index *idx);
76           int      get_count(void);
77   virtual void     *pop(void);
78   virtual void     *top(void);
79
80   //void           pack(void);
81   virtual void     set_limit(t_index alimit);
82
83           void     free_at(t_index index);
84           void     free_all(void);
85           void     disconn_at(t_index index);
86           void     disconn(void *item);
87           void     disconn_all(void);
88
89           void     add_at(t_index index, void *item);
90           void     put_at(t_index index, void *item);
91   virtual t_index  add(void *item);
92   virtual void     push(void *item);
93
94           void     *first_that(match_func test, void *arg);
95           void     *last_that(match_func test, void *arg);
96           void     for_each(iterator_func action, void *arg);
97
98           void     error(t_index code, t_index info);
99 private:
100   virtual void     free_item(void *item);
101 };
102
103
104 /*                                                                          #
105   ==========================================================================#
106                                                              cl_sorted_list #
107   ==========================================================================#
108                                                                             #
109 */
110
111 class cl_sorted_list: public cl_list
112 {
113 public:
114   bool             Duplicates;
115
116   cl_sorted_list(t_index alimit, t_index adelta);
117   virtual ~cl_sorted_list(void);
118   
119   virtual bool     search(void *key, t_index& index);
120   virtual t_index  index_of(void *item);
121   virtual t_index  add(void *item);
122   virtual void     *key_of(void *item);
123 private:
124   virtual int      compare(void *key1, void *key2)= 0;
125 };
126
127
128 /*                                                                          #
129   ==========================================================================#
130                                                                  cl_strings #
131   ==========================================================================#
132                                                                             #
133 */
134
135 class cl_strings: public cl_sorted_list
136 {
137 public:
138   cl_strings(t_index alimit, t_index adelta);
139   virtual ~cl_strings(void);
140   
141 private:
142   virtual int      compare(void *key1, void *key2);
143   virtual void     free_item(void *item);
144 };
145
146
147 /*                                                                          #
148   ==========================================================================#
149                                                                 cl_ustrings #
150   ==========================================================================#
151                                                                             #
152 */
153
154 class cl_ustrings: public cl_strings
155 {
156 public:
157   cl_ustrings(t_index alimit, t_index adelta);
158   virtual ~cl_ustrings(void);
159   
160 private:
161   virtual int      compare(void *key1, void *key2);
162   virtual bool     search(void *key, t_index &index);
163 };
164
165
166 #endif
167
168 /* End of pobj.h */