501c53d50e1915c2e30fe904b34090069ab220b5
[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           int      get_count(void);
76   virtual void     *pop(void);
77   virtual void     *top(void);
78
79   //void           pack(void);
80   virtual void     set_limit(t_index alimit);
81
82           void     free_at(t_index index);
83           void     disconn_at(t_index index);
84           void     disconn(void *item);
85           void     disconn_all(void);
86
87           void     add_at(t_index index, void *item);
88           void     put_at(t_index index, void *item);
89   virtual t_index  add(void *item);
90   virtual void     push(void *item);
91
92           void     *first_that(match_func test, void *arg);
93           void     *last_that(match_func test, void *arg);
94           void     for_each(iterator_func action, void *arg);
95
96           void     error(t_index code, t_index info);
97 private:
98   virtual void     free_item(void *item);
99 };
100
101
102 /*                                                                          #
103   ==========================================================================#
104                                                              cl_sorted_list #
105   ==========================================================================#
106                                                                             #
107 */
108
109 class cl_sorted_list: public cl_list
110 {
111 public:
112   bool             Duplicates;
113
114   cl_sorted_list(t_index alimit, t_index adelta);
115   virtual ~cl_sorted_list(void);
116   
117   virtual bool     search(void *key, t_index& index);
118   virtual t_index  index_of(void *item);
119   virtual t_index  add(void *item);
120   virtual void     *key_of(void *item);
121 private:
122   virtual int      compare(void *key1, void *key2)= 0;
123 };
124
125
126 /*                                                                          #
127   ==========================================================================#
128                                                                  cl_strings #
129   ==========================================================================#
130                                                                             #
131 */
132
133 class cl_strings: public cl_sorted_list
134 {
135 public:
136   cl_strings(t_index alimit, t_index adelta);
137   virtual ~cl_strings(void);
138   
139 private:
140   virtual int      compare(void *key1, void *key2);
141   virtual void     free_item(void *item);
142 };
143
144
145 /*                                                                          #
146   ==========================================================================#
147                                                                 cl_ustrings #
148   ==========================================================================#
149                                                                             #
150 */
151
152 class cl_ustrings: public cl_strings
153 {
154 public:
155   cl_ustrings(t_index alimit, t_index adelta);
156   virtual ~cl_ustrings(void);
157   
158 private:
159   virtual int      compare(void *key1, void *key2);
160   virtual bool     search(void *key, t_index &index);
161 };
162
163
164 #endif
165
166 /* End of pobj.h */