2 * Simulator of microcontrollers (error.cc)
4 * Copyright (C) 1997 Drotos Daniel
6 * To contact author send email to dr.dkdb@gmail.com
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
39 struct id_element error_on_off_names
[]= {
40 { ERROR_PARENT
, "unset" },
42 { ERROR_OFF
, "off" },
46 static class cl_error_registry error_registry
;
48 class cl_list
*cl_error_registry::registered_errors
= 0;
53 cl_error_class::cl_error_class(enum error_type typ
, const char *aname
,
54 enum error_on_off be_on
/* = ERROR_PARENT*/):
59 set_name(aname
, "not-known");
62 cl_error_class::cl_error_class(enum error_type typ
, const char *aname
,
63 class cl_error_class
*parent
,
64 enum error_on_off be_on
/* = ERROR_PARENT*/):
69 set_name(aname
, "not-known");
71 parent
->add_child(this);
75 cl_error_class::set_on(enum error_on_off val
)
84 cl_error_class::is_on(void)
86 if (on
== ERROR_PARENT
)
90 class cl_error_class
*p
=
91 (class cl_error_class
*)(get_parent());
95 return(on
== ERROR_ON
);
99 cl_error_class::get_type(void)
105 cl_error_class::get_name(void)
111 cl_error_class::get_type_name(void)
113 return(get_id_string(error_type_names
, type
, "untyped"));
116 case err_unknown: return("unclassified"); break;
117 case err_error: return("error"); break;
118 case err_warning: return("warning"); break;
127 cl_error::cl_error(void):
130 classification
= error_registry
.find("non-classified");
134 cl_error::~cl_error(void)
145 cl_error::get_type(void)
148 return(classification
->get_type());
153 cl_error::get_on(void)
157 return(classification
->get_on());
161 cl_error::is_on(void)
165 return(classification
->is_on());
169 cl_error::print(class cl_commander_base
*c
)
171 c
->dd_cprintf("error", "%s\n", (char *)get_type_name());
175 cl_error::get_type_name(void)
177 enum error_type type
= get_type();
178 return(get_id_string(error_type_names
, type
, "untyped"));
181 cl_error_registry::cl_error_registry(void)
183 if (NULL
== error_registry
.find("non-classified"))
184 register_error(new cl_error_class(err_error
, "non-classified", ERROR_ON
));
187 /* End of sim.src/error.cc */