Mercurial > ecos
comparison host/libcdl/wizard.cxx @ 76:435cced73e2f ecos-v1_3_1-release
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
| author | jlarmour |
|---|---|
| date | Tue, 28 Mar 2000 14:10:45 +0000 |
| parents | |
| children | 6736c52df507 |
comparison
equal
deleted
inserted
replaced
| 75:41bf073c0c32 | 76:435cced73e2f |
|---|---|
| 1 //{{{ Banner | |
| 2 | |
| 3 //============================================================================ | |
| 4 // | |
| 5 // wizard.cxx | |
| 6 // | |
| 7 // Implementation of the CdlWizard class | |
| 8 // | |
| 9 //============================================================================ | |
| 10 //####COPYRIGHTBEGIN#### | |
| 11 // | |
| 12 // ---------------------------------------------------------------------------- | |
| 13 // Copyright (C) 1999, 2000 Red Hat, Inc. | |
| 14 // | |
| 15 // This file is part of the eCos host tools. | |
| 16 // | |
| 17 // This program is free software; you can redistribute it and/or modify it | |
| 18 // under the terms of the GNU General Public License as published by the Free | |
| 19 // Software Foundation; either version 2 of the License, or (at your option) | |
| 20 // any later version. | |
| 21 // | |
| 22 // This program is distributed in the hope that it will be useful, but WITHOUT | |
| 23 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 24 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
| 25 // more details. | |
| 26 // | |
| 27 // You should have received a copy of the GNU General Public License along with | |
| 28 // this program; if not, write to the Free Software Foundation, Inc., | |
| 29 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 30 // | |
| 31 // ---------------------------------------------------------------------------- | |
| 32 // | |
| 33 //####COPYRIGHTEND#### | |
| 34 //============================================================================ | |
| 35 //#####DESCRIPTIONBEGIN#### | |
| 36 // | |
| 37 // Author(s): bartv | |
| 38 // Contact(s): bartv | |
| 39 // Date: 1999/03/01 | |
| 40 // Version: 0.01 | |
| 41 // | |
| 42 //####DESCRIPTIONEND#### | |
| 43 //============================================================================ | |
| 44 | |
| 45 //}}} | |
| 46 //{{{ #include's | |
| 47 | |
| 48 // ---------------------------------------------------------------------------- | |
| 49 #include "cdlconfig.h" | |
| 50 | |
| 51 // Get the infrastructure types, assertions, tracing and similar | |
| 52 // facilities. | |
| 53 #include <cyg/infra/cyg_ass.h> | |
| 54 #include <cyg/infra/cyg_trac.h> | |
| 55 | |
| 56 // <cdlcore.hxx> defines everything implemented in this module. | |
| 57 // It implicitly supplies <string>, <vector> and <map> because | |
| 58 // the class definitions rely on these headers. | |
| 59 #include <cdlcore.hxx> | |
| 60 | |
| 61 //}}} | |
| 62 | |
| 63 //{{{ Statics | |
| 64 | |
| 65 // ---------------------------------------------------------------------------- | |
| 66 CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlWizardBody); | |
| 67 | |
| 68 //}}} | |
| 69 //{{{ Constructor | |
| 70 | |
| 71 // ---------------------------------------------------------------------------- | |
| 72 // Constructor. The real work is actually done in the parse routine. | |
| 73 CdlWizardBody::CdlWizardBody(std::string name_arg) | |
| 74 : CdlNodeBody(name_arg), | |
| 75 CdlParentableBody(), | |
| 76 CdlUserVisibleBody() | |
| 77 { | |
| 78 CYG_REPORT_FUNCNAME("CdlWizardBody:: constructor"); | |
| 79 CYG_REPORT_FUNCARG1XV(this); | |
| 80 | |
| 81 cdlwizardbody_cookie = CdlWizardBody_Magic; | |
| 82 CYGDBG_MEMLEAK_CONSTRUCTOR(); | |
| 83 | |
| 84 CYG_POSTCONDITION_THISC(); | |
| 85 CYG_REPORT_RETURN(); | |
| 86 } | |
| 87 | |
| 88 //}}} | |
| 89 //{{{ Destructor | |
| 90 | |
| 91 // ---------------------------------------------------------------------------- | |
| 92 // The real work is done in the base classes. | |
| 93 CdlWizardBody::~CdlWizardBody() | |
| 94 { | |
| 95 CYG_REPORT_FUNCNAME("CdlWizardBody:: destructor"); | |
| 96 CYG_REPORT_FUNCARG1XV(this); | |
| 97 CYG_PRECONDITION_THISC(); | |
| 98 | |
| 99 cdlwizardbody_cookie = CdlWizardBody_Invalid; | |
| 100 CYGDBG_MEMLEAK_DESTRUCTOR(); | |
| 101 | |
| 102 CYG_REPORT_RETURN(); | |
| 103 } | |
| 104 | |
| 105 //}}} | |
| 106 //{{{ parse_wizard() | |
| 107 | |
| 108 // ---------------------------------------------------------------------------- | |
| 109 // Parsing a wizard definition. | |
| 110 | |
| 111 int | |
| 112 CdlWizardBody::parse_wizard(CdlInterpreter interp, int argc, char** argv) | |
| 113 { | |
| 114 CYG_REPORT_FUNCNAMETYPE("CdlWizard::parse_wizard", "result %d"); | |
| 115 CYG_REPORT_FUNCARG1("argc %d", argc); | |
| 116 CYG_PRECONDITION_CLASSC(interp); | |
| 117 | |
| 118 int result = TCL_OK; | |
| 119 const char* diag_argv0 = CdlParse::get_tcl_cmd_name(argv[0]); | |
| 120 | |
| 121 CdlLoadable loadable = interp->get_loadable(); | |
| 122 CdlContainer parent = interp->get_container(); | |
| 123 CdlToplevel toplevel = interp->get_toplevel(); | |
| 124 std::string filename = interp->get_filename(); | |
| 125 CYG_ASSERT_CLASSC(loadable); // There should always be a loadable during parsing | |
| 126 CYG_ASSERT_CLASSC(parent); | |
| 127 CYG_ASSERT_CLASSC(toplevel); | |
| 128 CYG_ASSERTC("" != filename); | |
| 129 | |
| 130 // The new wizard should be created and added to the loadable | |
| 131 // early on. If there is a parsing error it will get cleaned up | |
| 132 // automatically as a consequence of the loadable destructor. | |
| 133 // However it is necessary to validate the name first. Errors | |
| 134 // should be reported via CdlParse::report_error(), which | |
| 135 // may result in an exception. | |
| 136 CdlWizard new_wizard = 0; | |
| 137 try { | |
| 138 | |
| 139 // Currently there are no command-line options. This may change in future. | |
| 140 if (3 != argc) { | |
| 141 CdlParse::report_error(interp, std::string("Incorrect number of arguments to ") + diag_argv0 + | |
| 142 "\n Expecting name and properties list."); | |
| 143 } else if (!Tcl_CommandComplete(argv[2])) { | |
| 144 CdlParse::report_error(interp, std::string("Invalid property list for cdl_wizard ") + argv[1]); | |
| 145 } else if (0 != toplevel->lookup(argv[1])) { | |
| 146 CdlParse::report_error(interp, std::string("Wizard ") + argv[1] + " cannot be loaded.\n" + | |
| 147 " The name is already in use."); | |
| 148 } else { | |
| 149 new_wizard = new CdlWizardBody(argv[1]); | |
| 150 toplevel->add_node(loadable, parent, new_wizard); | |
| 151 | |
| 152 // At this stage new_wizard has been created and added to the hierarchy. | |
| 153 // The main work now is to add the properties. | |
| 154 | |
| 155 // Push the wizard as the current base object early on. | |
| 156 // This aids diagnostics. | |
| 157 CdlNode old_node = 0; | |
| 158 | |
| 159 std::string tcl_result; | |
| 160 std::vector<CdlInterpreterCommandEntry> new_commands; | |
| 161 std::vector<CdlInterpreterCommandEntry>* old_commands = 0; | |
| 162 static CdlInterpreterCommandEntry commands[] = | |
| 163 { | |
| 164 CdlInterpreterCommandEntry("init_proc", &parse_init_proc ), | |
| 165 CdlInterpreterCommandEntry("decoration_proc", &parse_decoration_proc ), | |
| 166 CdlInterpreterCommandEntry("screen", &parse_screen ), | |
| 167 CdlInterpreterCommandEntry("confirm_proc", &parse_confirm_proc ), | |
| 168 CdlInterpreterCommandEntry("cancel_proc", &parse_cancel_proc ), | |
| 169 CdlInterpreterCommandEntry("", 0 ), | |
| 170 }; | |
| 171 int i; | |
| 172 for (i = 0; 0 != commands[i].command; i++) { | |
| 173 new_commands.push_back(commands[i]); | |
| 174 } | |
| 175 CdlParentableBody::add_property_parsers(new_commands); | |
| 176 CdlUserVisibleBody::add_property_parsers(new_commands); | |
| 177 CdlNodeBody::add_property_parsers(new_commands); | |
| 178 | |
| 179 // Now evaluate the body. If an error occurs then typically | |
| 180 // this will be reported via CdlParse::report_error(), | |
| 181 // but any exceptions will have been intercepted and | |
| 182 // turned into a Tcl error. | |
| 183 old_node = interp->push_node(new_wizard); | |
| 184 old_commands = interp->push_commands(new_commands); | |
| 185 result = interp->eval(argv[2], tcl_result); | |
| 186 interp->pop_node(old_node); | |
| 187 interp->pop_commands(old_commands); | |
| 188 | |
| 189 if (TCL_OK == result) { | |
| 190 // Even if there were errors, they were not fatal. There may | |
| 191 // now be a number of properties for this option, and some | |
| 192 // validation should take place. Start with the base classes. | |
| 193 new_wizard->CdlNodeBody::check_properties(interp); | |
| 194 new_wizard->CdlUserVisibleBody::check_properties(interp); | |
| 195 new_wizard->CdlParentableBody::check_properties(interp); | |
| 196 | |
| 197 // The init_proc and decoration_proc properties are | |
| 198 // optional. The confirm_proc and cancel_proc properties | |
| 199 // are compulsory, and there should be at least one screen | |
| 200 // definition. | |
| 201 if (new_wizard->count_properties(CdlPropertyId_InitProc) > 1) { | |
| 202 CdlParse::report_error(interp, "A wizard should have only one `init_proc' property."); | |
| 203 } | |
| 204 if (new_wizard->count_properties(CdlPropertyId_DecorationProc) > 1) { | |
| 205 CdlParse::report_error(interp, "A wizard should have only one `decoration_proc' property."); | |
| 206 } | |
| 207 if (new_wizard->count_properties(CdlPropertyId_ConfirmProc) != 1) { | |
| 208 CdlParse::report_error(interp, "A wizard should have one `confirm_proc' property."); | |
| 209 } | |
| 210 if (new_wizard->count_properties(CdlPropertyId_CancelProc) != 1) { | |
| 211 CdlParse::report_error(interp, "A wizard should have one `cancel_proc' property."); | |
| 212 } | |
| 213 if (new_wizard->count_properties(CdlPropertyId_Screen) < 1) { | |
| 214 CdlParse::report_error(interp, "A wizard should have at least one `screen' property."); | |
| 215 } | |
| 216 | |
| 217 // It is necessary to check that all the screen properties have unique numbers | |
| 218 const std::vector<CdlProperty>& properties = new_wizard->get_properties(); | |
| 219 std::vector<CdlProperty>::const_iterator prop_i, prop_j; | |
| 220 for (prop_i = properties.begin(); prop_i != properties.end(); prop_i++) { | |
| 221 if (CdlPropertyId_Screen != (*prop_i)->get_property_name()) { | |
| 222 continue; | |
| 223 } | |
| 224 CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(*prop_i); | |
| 225 CYG_ASSERT_CLASSC(tclprop); | |
| 226 cdl_int num1 = tclprop->get_number(); | |
| 227 | |
| 228 for (prop_j = ++prop_i; prop_j != properties.end(); prop_j++) { | |
| 229 if (CdlPropertyId_Screen != (*prop_j)->get_property_name()) { | |
| 230 continue; | |
| 231 } | |
| 232 CdlProperty_TclCode tclprop2 = dynamic_cast<CdlProperty_TclCode>(*prop_j); | |
| 233 CYG_ASSERT_CLASSC(tclprop2); | |
| 234 cdl_int num2 = tclprop2->get_number(); | |
| 235 | |
| 236 if (num1 == num2) { | |
| 237 std::string tmp = ""; | |
| 238 Cdl::integer_to_string(num1, tmp); | |
| 239 CdlParse::report_error(interp, "Duplicate definition of screen " + tmp); | |
| 240 break; | |
| 241 } | |
| 242 } | |
| 243 } | |
| 244 | |
| 245 // There is no restriction on what screen numbers can be | |
| 246 // defined (screens may appear and disappear during | |
| 247 // development). It would be nice to validate that the | |
| 248 // Tcl fragments never switch to an invalid screen, but | |
| 249 // there is no easy way to do that. | |
| 250 } | |
| 251 } | |
| 252 | |
| 253 } catch(...) { | |
| 254 if (0 != new_wizard) { | |
| 255 delete new_wizard; | |
| 256 } | |
| 257 throw; | |
| 258 } | |
| 259 | |
| 260 CYG_REPORT_RETVAL(result); | |
| 261 return result; | |
| 262 } | |
| 263 | |
| 264 // ---------------------------------------------------------------------------- | |
| 265 // Syntax: cancel_proc <tclcode> | |
| 266 | |
| 267 int | |
| 268 CdlWizardBody::parse_cancel_proc(CdlInterpreter interp, int argc, char** argv) | |
| 269 { | |
| 270 CYG_REPORT_FUNCNAMETYPE("parse_cancel_proc", "result %d"); | |
| 271 | |
| 272 int result = CdlParse::parse_tclcode_property(interp, argc, argv, CdlPropertyId_CancelProc, 0, 0); | |
| 273 | |
| 274 CYG_REPORT_RETVAL(result); | |
| 275 return result; | |
| 276 } | |
| 277 | |
| 278 // ---------------------------------------------------------------------------- | |
| 279 // Syntax: confirm_proc <tclcode> | |
| 280 | |
| 281 int | |
| 282 CdlWizardBody::parse_confirm_proc(CdlInterpreter interp, int argc, char** argv) | |
| 283 { | |
| 284 CYG_REPORT_FUNCNAMETYPE("parse_confirm_proc", "result %d"); | |
| 285 | |
| 286 int result = CdlParse::parse_tclcode_property(interp, argc, argv, CdlPropertyId_ConfirmProc, 0, 0); | |
| 287 | |
| 288 CYG_REPORT_RETVAL(result); | |
| 289 return result; | |
| 290 } | |
| 291 | |
| 292 // ---------------------------------------------------------------------------- | |
| 293 // syntax: decoration_proc <tclcode> | |
| 294 | |
| 295 int | |
| 296 CdlWizardBody::parse_decoration_proc(CdlInterpreter interp, int argc, char** argv) | |
| 297 { | |
| 298 CYG_REPORT_FUNCNAMETYPE("parse_decoration_proc", "result %d"); | |
| 299 | |
| 300 int result = CdlParse::parse_tclcode_property(interp, argc, argv, CdlPropertyId_DecorationProc, 0, 0); | |
| 301 | |
| 302 CYG_REPORT_RETVAL(result); | |
| 303 return result; | |
| 304 } | |
| 305 | |
| 306 // ---------------------------------------------------------------------------- | |
| 307 // Syntax: init_proc <tclcode> | |
| 308 | |
| 309 int | |
| 310 CdlWizardBody::parse_init_proc(CdlInterpreter interp, int argc, char** argv) | |
| 311 { | |
| 312 CYG_REPORT_FUNCNAMETYPE("parse_init_proc", "result %d"); | |
| 313 | |
| 314 int result = CdlParse::parse_tclcode_property(interp, argc, argv, CdlPropertyId_InitProc, 0, 0); | |
| 315 | |
| 316 CYG_REPORT_RETVAL(result); | |
| 317 return result; | |
| 318 } | |
| 319 | |
| 320 // ---------------------------------------------------------------------------- | |
| 321 // The screen property is a little bit special and cannot be handled by the | |
| 322 // generic parsers. There are two arguments, a number and some Tcl code. | |
| 323 | |
| 324 int | |
| 325 CdlWizardBody::parse_screen(CdlInterpreter interp, int argc, char** argv) | |
| 326 { | |
| 327 CYG_REPORT_FUNCNAME("CdlParse::parse_screen"); | |
| 328 CYG_REPORT_FUNCARG1("argc %d", argc); | |
| 329 CYG_PRECONDITION_CLASSC(interp); | |
| 330 | |
| 331 CdlProperty_TclCode new_property = 0; | |
| 332 cdl_int number = 0; | |
| 333 | |
| 334 try { | |
| 335 std::vector<std::pair<std::string,std::string> > options; | |
| 336 int data_index = CdlParse::parse_options(interp, std::string("property ") + argv[0], 0, argc, argv, 1, options); | |
| 337 if ((data_index + 2) != argc) { | |
| 338 CdlParse::report_property_parse_error(interp, argv[0], std::string("Invalid number of arguments.\n") + | |
| 339 " Expecting two arguments, a number and some Tcl code."); | |
| 340 } else if (!Cdl::string_to_integer(argv[data_index], number)) { | |
| 341 CdlParse::report_property_parse_error(interp, argv[0], std::string(argv[data_index]) + " is not a valid number."); | |
| 342 } else if (!Tcl_CommandComplete(argv[data_index + 1])) { | |
| 343 CdlParse::report_property_parse_error(interp, argv[0], "incomplete Tcl code fragment."); | |
| 344 } else { | |
| 345 | |
| 346 CdlNode current_node = interp->get_node(); | |
| 347 CYG_ASSERTC(0 != current_node); | |
| 348 new_property = CdlProperty_TclCodeBody::make(current_node, CdlPropertyId_Screen, number, argv[data_index + 1], | |
| 349 argc, argv, options); | |
| 350 } | |
| 351 } catch(...) { | |
| 352 if (0 != new_property) { | |
| 353 delete new_property; | |
| 354 } | |
| 355 throw; | |
| 356 } | |
| 357 | |
| 358 return TCL_OK; | |
| 359 } | |
| 360 | |
| 361 //}}} | |
| 362 //{{{ Persistence | |
| 363 | |
| 364 // ---------------------------------------------------------------------------- | |
| 365 // For now there is no information in a wizard that should end up in a | |
| 366 // save file, but it is still desirable to override the base class | |
| 367 // member function. | |
| 368 | |
| 369 void | |
| 370 CdlWizardBody::save(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) | |
| 371 throw(CdlInputOutputException, std::bad_alloc) | |
| 372 { | |
| 373 CYG_REPORT_FUNCNAME("CdlWizard::save"); | |
| 374 CYG_REPORT_FUNCARG5XV(this, interp, chan, indentation, minimal); | |
| 375 CYG_PRECONDITION_THISC(); | |
| 376 | |
| 377 CYG_UNUSED_PARAM(CdlInterpreter, interp); | |
| 378 CYG_UNUSED_PARAM(Tcl_Channel, chan); | |
| 379 CYG_UNUSED_PARAM(int, indentation); | |
| 380 CYG_UNUSED_PARAM(bool, minimal); | |
| 381 | |
| 382 CYG_REPORT_RETURN(); | |
| 383 } | |
| 384 | |
| 385 //}}} | |
| 386 //{{{ Data access | |
| 387 | |
| 388 // ---------------------------------------------------------------------------- | |
| 389 bool | |
| 390 CdlWizardBody::has_init_proc() const | |
| 391 { | |
| 392 CYG_REPORT_FUNCNAMETYPE("CdlWizard::has_init_proc", "result %d"); | |
| 393 CYG_REPORT_FUNCARG1XV(this); | |
| 394 CYG_PRECONDITION_THISC(); | |
| 395 | |
| 396 bool result = has_property(CdlPropertyId_InitProc); | |
| 397 CYG_REPORT_RETVAL(result); | |
| 398 return result; | |
| 399 } | |
| 400 | |
| 401 bool | |
| 402 CdlWizardBody::has_decoration_proc() const | |
| 403 { | |
| 404 CYG_REPORT_FUNCNAMETYPE("CdlWizard::has_decoration_proc", "result %d"); | |
| 405 CYG_REPORT_FUNCARG1XV(this); | |
| 406 CYG_PRECONDITION_THISC(); | |
| 407 | |
| 408 bool result = has_property(CdlPropertyId_DecorationProc); | |
| 409 CYG_REPORT_RETVAL(result); | |
| 410 return result; | |
| 411 } | |
| 412 | |
| 413 bool | |
| 414 CdlWizardBody::has_screen(cdl_int screen) const | |
| 415 { | |
| 416 CYG_REPORT_FUNCNAMETYPE("CdlWizard::has_screen", "result %d"); | |
| 417 CYG_REPORT_FUNCARG2XV(this, (int) screen); | |
| 418 CYG_PRECONDITION_THISC(); | |
| 419 | |
| 420 bool result = false; | |
| 421 const std::vector<CdlProperty>& properties = get_properties(); | |
| 422 std::vector<CdlProperty>::const_iterator prop_i; | |
| 423 for (prop_i = properties.begin(); prop_i != properties.end(); prop_i++) { | |
| 424 if (CdlPropertyId_Screen != (*prop_i)->get_property_name()) { | |
| 425 continue; | |
| 426 } | |
| 427 CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(*prop_i); | |
| 428 CYG_ASSERT_CLASSC(tclprop); | |
| 429 if (screen == tclprop->get_number()) { | |
| 430 result = true; | |
| 431 break; | |
| 432 } | |
| 433 } | |
| 434 CYG_REPORT_RETVAL(result); | |
| 435 return result; | |
| 436 } | |
| 437 | |
| 438 const cdl_tcl_code& | |
| 439 CdlWizardBody::get_init_proc() const | |
| 440 { | |
| 441 CYG_REPORT_FUNCNAME("CdlWizard::get_init_proc"); | |
| 442 CYG_REPORT_FUNCARG1XV(this); | |
| 443 CYG_PRECONDITION_THISC(); | |
| 444 | |
| 445 static cdl_tcl_code null_result = ""; | |
| 446 cdl_tcl_code& result = null_result; | |
| 447 CdlProperty prop = get_property(CdlPropertyId_InitProc); | |
| 448 if (0 != prop) { | |
| 449 CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(prop); | |
| 450 CYG_ASSERT_CLASSC(tclprop); | |
| 451 result = tclprop->get_code(); | |
| 452 } | |
| 453 | |
| 454 CYG_REPORT_RETURN(); | |
| 455 return result; | |
| 456 } | |
| 457 | |
| 458 const cdl_tcl_code& | |
| 459 CdlWizardBody::get_decoration_proc() const | |
| 460 { | |
| 461 CYG_REPORT_FUNCNAME("CdlWizard::get_decoration_proc"); | |
| 462 CYG_REPORT_FUNCARG1XV(this); | |
| 463 CYG_PRECONDITION_THISC(); | |
| 464 | |
| 465 static cdl_tcl_code null_result = ""; | |
| 466 cdl_tcl_code& result = null_result; | |
| 467 CdlProperty prop = get_property(CdlPropertyId_DecorationProc); | |
| 468 if (0 != prop) { | |
| 469 CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(prop); | |
| 470 CYG_ASSERT_CLASSC(tclprop); | |
| 471 result = tclprop->get_code(); | |
| 472 } | |
| 473 | |
| 474 CYG_REPORT_RETURN(); | |
| 475 return result; | |
| 476 } | |
| 477 | |
| 478 const cdl_tcl_code& | |
| 479 CdlWizardBody::get_confirm_proc() const | |
| 480 { | |
| 481 CYG_REPORT_FUNCNAME("CdlWizard::get_display_proc"); | |
| 482 CYG_REPORT_FUNCARG1XV(this); | |
| 483 CYG_PRECONDITION_THISC(); | |
| 484 | |
| 485 CdlProperty prop = get_property(CdlPropertyId_ConfirmProc); | |
| 486 CYG_ASSERT_CLASSC(prop); | |
| 487 CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(prop); | |
| 488 CYG_ASSERT_CLASSC(tclprop); | |
| 489 | |
| 490 const cdl_tcl_code& result = tclprop->get_code(); | |
| 491 | |
| 492 CYG_REPORT_RETURN(); | |
| 493 return result; | |
| 494 } | |
| 495 | |
| 496 const cdl_tcl_code& | |
| 497 CdlWizardBody::get_cancel_proc() const | |
| 498 { | |
| 499 CYG_REPORT_FUNCNAME("CdlWizard::get_display_proc"); | |
| 500 CYG_REPORT_FUNCARG1XV(this); | |
| 501 CYG_PRECONDITION_THISC(); | |
| 502 | |
| 503 CdlProperty prop = get_property(CdlPropertyId_CancelProc); | |
| 504 CYG_ASSERT_CLASSC(prop); | |
| 505 CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(prop); | |
| 506 CYG_ASSERT_CLASSC(tclprop); | |
| 507 | |
| 508 const cdl_tcl_code& result = tclprop->get_code(); | |
| 509 | |
| 510 CYG_REPORT_RETURN(); | |
| 511 return result; | |
| 512 } | |
| 513 | |
| 514 cdl_int | |
| 515 CdlWizardBody::get_first_screen_number() const | |
| 516 { | |
| 517 CYG_REPORT_FUNCNAMETYPE("CdlWizard::get_first_screen_number", "result %d"); | |
| 518 CYG_REPORT_FUNCARG1XV(this); | |
| 519 CYG_PRECONDITION_THISC(); | |
| 520 | |
| 521 // The result should really be initialized to MININT, but that is | |
| 522 // slightly tricky given that we are dealing with cdl_int's rather | |
| 523 // than plain int's. Instead a separate flag gives the same | |
| 524 // effect. | |
| 525 bool result_set = false; | |
| 526 cdl_int result = -1; | |
| 527 | |
| 528 const std::vector<CdlProperty>& properties = get_properties(); | |
| 529 std::vector<CdlProperty>::const_iterator prop_i; | |
| 530 for (prop_i = properties.begin(); prop_i != properties.end(); prop_i++) { | |
| 531 if (CdlPropertyId_Screen != (*prop_i)->get_property_name()) { | |
| 532 continue; | |
| 533 } | |
| 534 CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(*prop_i); | |
| 535 cdl_int its_num = tclprop->get_number(); | |
| 536 if (!result_set || (its_num < result)) { | |
| 537 result = its_num; | |
| 538 result_set = true; | |
| 539 } | |
| 540 } | |
| 541 | |
| 542 CYG_REPORT_RETVAL((int) result); | |
| 543 return result; | |
| 544 } | |
| 545 | |
| 546 const cdl_tcl_code& | |
| 547 CdlWizardBody::get_first_screen() const | |
| 548 { | |
| 549 CYG_REPORT_FUNCNAME("CdlWizard::get_first_screen"); | |
| 550 CYG_REPORT_FUNCARG1XV(this); | |
| 551 CYG_PRECONDITION_THISC(); | |
| 552 | |
| 553 // The result should really be initialized to MININT, but that is | |
| 554 // slightly tricky given that we are dealing with cdl_int's rather | |
| 555 // than plain int's. Instead a separate flag gives the same | |
| 556 // effect. | |
| 557 static cdl_tcl_code null_result = ""; | |
| 558 bool result_set = false; | |
| 559 cdl_tcl_code& result = null_result; | |
| 560 cdl_int result_num = -1; | |
| 561 | |
| 562 const std::vector<CdlProperty>& properties = get_properties(); | |
| 563 std::vector<CdlProperty>::const_iterator prop_i; | |
| 564 for (prop_i = properties.begin(); prop_i != properties.end(); prop_i++) { | |
| 565 if (CdlPropertyId_Screen != (*prop_i)->get_property_name()) { | |
| 566 continue; | |
| 567 } | |
| 568 CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(*prop_i); | |
| 569 cdl_int its_num = tclprop->get_number(); | |
| 570 if (!result_set || (its_num < result_num)) { | |
| 571 result = tclprop->get_code(); | |
| 572 result_num = its_num; | |
| 573 result_set = true; | |
| 574 } | |
| 575 } | |
| 576 | |
| 577 CYG_REPORT_RETURN(); | |
| 578 return result; | |
| 579 } | |
| 580 | |
| 581 const cdl_tcl_code& | |
| 582 CdlWizardBody::get_screen(cdl_int screen) const | |
| 583 { | |
| 584 CYG_REPORT_FUNCNAME("CdlWizard::get_screen"); | |
| 585 CYG_REPORT_FUNCARG2XV(this, (int)screen); | |
| 586 CYG_PRECONDITION_THISC(); | |
| 587 | |
| 588 static cdl_tcl_code null_result = ""; | |
| 589 cdl_tcl_code& result = null_result; | |
| 590 | |
| 591 const std::vector<CdlProperty>& properties = get_properties(); | |
| 592 std::vector<CdlProperty>::const_iterator prop_i; | |
| 593 for (prop_i = properties.begin(); prop_i != properties.end(); prop_i++) { | |
| 594 if (CdlPropertyId_Screen != (*prop_i)->get_property_name()) { | |
| 595 continue; | |
| 596 } | |
| 597 CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(*prop_i); | |
| 598 if (tclprop->get_number() == screen) { | |
| 599 result = tclprop->get_code(); | |
| 600 break; | |
| 601 } | |
| 602 } | |
| 603 | |
| 604 CYG_REPORT_RETURN(); | |
| 605 return result; | |
| 606 } | |
| 607 | |
| 608 //}}} | |
| 609 //{{{ check_this() | |
| 610 | |
| 611 // ---------------------------------------------------------------------------- | |
| 612 // check_this(). There is very little data associated with a wizard, | |
| 613 // most of the checks happen in the base classes. | |
| 614 bool | |
| 615 CdlWizardBody::check_this(cyg_assert_class_zeal zeal) const | |
| 616 { | |
| 617 if (CdlWizardBody_Magic != cdlwizardbody_cookie) { | |
| 618 return false; | |
| 619 } | |
| 620 CYGDBG_MEMLEAK_CHECKTHIS(); | |
| 621 return CdlUserVisibleBody::check_this(zeal); | |
| 622 } | |
| 623 | |
| 624 //}}} | |
| 625 //{{{ misc | |
| 626 | |
| 627 // ---------------------------------------------------------------------------- | |
| 628 | |
| 629 std::string | |
| 630 CdlWizardBody::get_class_name() const | |
| 631 { | |
| 632 CYG_REPORT_FUNCNAME("CdlWizard::get_class_name"); | |
| 633 CYG_PRECONDITION_THISC(); | |
| 634 CYG_REPORT_RETURN(); | |
| 635 return "wizard"; | |
| 636 } | |
| 637 | |
| 638 //}}} |
