[ucsim] Update email and file info, fix stm8 flash controller
[sdcc.git] / sdcc / sim / ucsim / src / core / utils.src / optioncl.h
blobbe58b204882ce257e03595f232cc2e80f439d4ad
1 /*
2 * Simulator of microcontrollers (optioncl.h)
4 * Copyright (C) 1997 Drotos Daniel
5 *
6 * To contact author send email to dr.dkdb@gmail.com
8 */
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
25 02111-1307, USA. */
26 /*@1@*/
28 #ifndef SIM_OPTIONCL_HEADER
29 #define SIM_OPTIONCL_HEADER
31 #include "ddconfig.h"
33 #include <stdio.h>
35 #include "pobjcl.h"
36 #include "stypes.h"
39 enum option_type {
40 non_opt,
41 integer_opt,
42 float_opt,
43 bool_opt,
44 string_opt,
45 pointer_opt
48 // forward
49 class cl_optref;
51 union option_value {
52 long ival;
53 double fval;
54 bool bval;
55 char *sval;
56 void *pval;
59 class cl_option: public cl_base
61 protected:
62 //enum opt_type type;
63 void *option;
64 union option_value value;
65 class cl_base *creator;
66 public:
67 class cl_list *users; // cl_optref
68 //char *name;
69 char *help;
70 bool hidden;
72 public:
73 cl_option(class cl_base *the_creator, const char *aname, const char *Ihelp);
74 virtual class cl_option &operator=(class cl_option &o);
75 virtual ~cl_option(void);
76 virtual void pre_remove(void);
78 virtual class cl_base *get_creator(void) { return(creator); }
79 virtual void hide(void) { hidden= true; }
80 virtual void show(void) { hidden= false; }
82 virtual void print(class cl_console_base */*con*/) {}
83 virtual const char *get_type_name(void) { return("none"); }
85 virtual union option_value *get_value(void) { return(&value); }
86 virtual void get_value(bool *val);
87 virtual void get_value(char **val);
88 virtual void get_value(void **val);
89 virtual void get_value(long *val);
90 virtual void get_value(double *val);
91 virtual void set_value(bool opt);
92 virtual void set_value(const char *opt);
93 virtual void set_value(void *opt);
94 virtual void set_value(long opt);
95 virtual void set_value(double opt);
97 virtual void new_reference(class cl_optref *ref);
98 virtual void del_reference(class cl_optref *ref);
99 virtual void inform_users(void);
103 class cl_options: public cl_sorted_list
105 public:
106 cl_options(void): cl_sorted_list(2, 2, "options")
107 { Duplicates= true; }
108 virtual const void *key_of(const void *item) const;
109 virtual int compare(const void *key1, const void *key2);
110 virtual void new_option(class cl_option *opt);
111 virtual void del_option(class cl_option *opt);
112 virtual class cl_option *get_option(const char *the_name);
113 virtual class cl_option *get_option(const char *the_name, class cl_base *creator);
114 virtual class cl_option *get_option(const char *the_name, const char *creator);
115 virtual class cl_option *get_option(int idx);
116 virtual int nuof_options(char *the_name);
117 virtual int nuof_options(char *the_name, const char *creator);
119 virtual class cl_option *set_value(const char *the_name, cl_base *creator,
120 bool value);
121 virtual class cl_option *set_value(const char *the_name, cl_base *creator,
122 const char *value);
123 virtual class cl_option *set_value(const char *the_name, cl_base *creator,
124 void *value);
125 virtual class cl_option *set_value(const char *the_name, cl_base *creator,
126 long value);
127 virtual class cl_option *set_value(const char *the_name, cl_base *creator,
128 double value);
132 class cl_optref: public cl_base
134 public:
135 class cl_option *option;
136 protected:
137 class cl_base *owner;
138 public:
139 cl_optref(class cl_base *the_owner);
140 cl_optref(class cl_base *the_owner, class cl_option *new_option);
141 cl_optref(class cl_base *the_owner, const char *to_use);
142 virtual ~cl_optref(void);
144 virtual class cl_option *create(class cl_base *creator,
145 enum option_type type,
146 const char *the_name, const char *help);
147 virtual void default_option(const char *the_name);
148 virtual class cl_option *use(void);
149 virtual class cl_option *use(const char *the_name);
150 virtual void option_changed(void) {}
151 virtual void option_removing(void);
152 virtual class cl_base *get_owner(void) { return(owner); }
154 virtual bool get_value(bool);
155 virtual bool get_value(bool *val);
156 virtual char *get_value(const char *);
157 virtual void *get_value(void *);
158 virtual long get_value(long);
159 virtual bool get_value(long *val);
160 virtual double get_value(double);
164 class cl_bool_option: public cl_option
166 public:
167 cl_bool_option(class cl_base *the_creator, const char *aname, const char *Ihelp);
168 virtual void print(class cl_console_base *con);
169 virtual const char *get_type_name(void) { return("boolean"); }
170 virtual void set_value(const char *s);
174 class cl_string_option: public cl_option
176 public:
177 cl_string_option(class cl_base *the_creator, const char *aname, const char *Ihelp);
178 virtual class cl_option &operator=(class cl_option &o);
179 virtual void print(class cl_console_base *con);
180 virtual const char *get_type_name(void) { return("string"); }
184 class cl_pointer_option: public cl_option
186 public:
187 cl_pointer_option(class cl_base *the_creator, const char *aname, const char *Ihelp);
188 virtual class cl_option &operator=(class cl_option &o);
189 virtual void print(class cl_console_base *con);
190 virtual const char *get_type_name(void) { return("pointer"); }
194 class cl_number_option: public cl_option
196 public:
197 cl_number_option(class cl_base *the_creator, const char *aname, const char *Ihelp);
198 virtual void print(class cl_console_base *con);
199 virtual const char *get_type_name(void) { return("integer"); }
200 virtual void set_value(const char *s);
204 class cl_float_option: public cl_option
206 public:
207 cl_float_option(class cl_base *the_creator, const char *aname, const char *Ihelp);
208 virtual void print(class cl_console_base *con);
209 virtual const char *get_type_name(void) { return("float"); }
210 virtual void set_value(const char *s);
214 /*class cl_cons_debug_opt: public cl_option
216 public:
217 class cl_app *app;
218 public:
219 cl_cons_debug_opt(class cl_app *the_app, char *Iid, const char *Ihelp);
221 virtual void print(class cl_console_base *con);
223 virtual void get_value(bool *val);
225 virtual void set_value(bool);
226 virtual void set_value(const char *s);
227 };*/
230 #endif
232 /* End of utils.src/optioncl.h */