- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Configs/DCCGI/DCCGITest.cpp

    00001 //=============================================================================
    00002 //
    00003 // Copyright (c) 2001           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems (MERS) group
    00007 // does not assume any responsibility.
    00008 //
    00009 // AUTHOR:                      Seung H. Chung
    00010 //
    00011 // ORGANIZATION:        Model-based Embedded and Robotic Systems Group
    00012 //                                      Massachusetts Institute of Technology
    00013 //
    00014 // FILE:                        Titan_test.cpp
    00015 //
    00016 // DESCRIPTION:
    00017 //
    00018 //
    00019 //
    00020 //# CHECKED PHE 08/07/2002
    00021 //=============================================================================
    00022
    00023 #ifdef _MSC_VER
    00024 #pragma warning( disable : 4786 )
    00025 #include "win32/unistd.h"
    00026 #else
    00027 #include <unistd.h>
    00028 #endif
    00029
    00030 #include <cstdio>
    00031 #include <cassert>
    00032 #include <iostream>
    00033 #include <string>
    00034 #include <Mers/Utils/Containers/intList.h>
    00035 #include <Mers/Models/CCA/CCAVariable.h>
    00036 #include <Mers/Models/CCA/CCAVariables.h>
    00037 #include <Mers/Models/CCA/CCAModel.h>
    00038 #include <Mers/Models/CCA/Io/Mof/MOFReader.h>
    00039
    00040 #ifdef USE_CME
    00041 #include <Mers/Estimation/Discrete/CompiledME/CCMEReader/CCMEReader.h>
    00042 #include "../Estimation/CompiledME/ModeEstimator.h"
    00043 #else
    00044 #include <Mers/Estimation/Discrete/ModeEstimation/ModeEstimator.h>
    00045 #endif
    00046 #include <Mers/Estimation/Discrete/MEInterface.h>
    00047
    00048 #ifdef USE_CGI
    00049 #include <Mers/Solvers/Entailment/CompiledGI/CompiledGoalInterpreter.h>
    00050 #include <Mers/Models/Base/BaseModel.h>
    00051 #else
    00052 #include <Mers/Solvers/Entailment/GI/GoalInterpreter.h>
    00053 #endif
    00054
    00055 #include <Mers/Reconfiguration/Discrete/modeReconfiguration.h>
    00056 #include <Mers/Reconfiguration/Discrete/mrInterface.h>
    00057 #include "TitanInterface.h"
    00058 #include "TitanCallbackStub.h"
    00059 using namespace std;
    00060
    00061 CCAModel *      load_MOF(char const * MOF_file_name);
    00062 void    run_Titan_shell(TitanInterface *Titan_interface_p, CCAModel const *model_p, ModeEstimator * me);
    00063 void    print_Titan_shell_help(char ch);
    00064 void    print_variables(CCAVariables const * variable_p, char ch, ModeEstimator const * me);
    00065 void    eat_space_or_tab(istream &stream);
    00066 void    clear_stream(istream &stream);
    00067 bool    read_pair_of_int(istream &stream, int &int_1, int &int_2);
    00068
    00069 int
    00070 main(int argc, char** argv)
    00071 {
    00072         argc--;
    00073         argv++;
    00074
    00075         CCAModel *model_p;
    00076         char const * MOF_file_name;
    00077 #ifdef USE_CGI
    00078         // until model is a BaseModel...
    00079         // BaseModel * baseModel;
    00080         GITable * giTable;
    00081         char const * CCGIT_file_name;
    00082 #endif
    00083 #ifdef USE_CME
    00084         CCMEReader ccmeReader;
    00085 #endif
    00086
    00087 #ifdef USE_CGI
    00088         if(argc != 2){
    00089                 if(argc == -1)
    00090                         printf("Use: DCCGI <CCA file> <CCGIT file>\n");
    00091                 else
    00092                         printf("Use: %s <CCA file> <CCGIT file>\n", argv[-1]);
    00093                 return 1;
    00094         }else{
    00095                 MOF_file_name = argv[0];
    00096                 CCGIT_file_name = argv[1];
    00097                 model_p = load_MOF(argv[0]);
    00098                 /*
    00099                 {
    00100                         // until model is a BaseModel...
    00101                         baseModel = new BaseModel(MOF_file_name);
    00102                         domains const * doms = model_p->get_domains_p();
    00103                         domains::const_iterator cid;
    00104                         for(cid = doms->begin(); cid != doms->end(); cid++){
    00105                                 BaseModelDomain * bmDomain =
    00106                                         new BaseModelDomain((*cid).name().c_str(), true);
    00107                                 values const * vals = (*cid).values_p();
    00108                                 values::const_iterator civ;
    00109                                 for(civ = vals->begin(); civ != vals->end(); civ++){
    00110                                         BaseModelValue * bmValue =
    00111                                                 new BaseModelValue((*civ).name().c_str());
    00112                                         bmDomain->pushBack(bmValue);
    00113                                 }
    00114                                 baseModel->addDomain(bmDomain);
    00115                         }
    00116
    00117                         variables const * vars = model_p->get_variables_p();
    00118                         variables::const_iterator civ;
    00119                         for(civ = vars->begin(); civ != vars->end(); civ++){
    00120                                 BaseModelDomain * bmDomain =
    00121                                         baseModel->getDomain((*civ).domain_p()->name().c_str());
    00122                                 BaseModelVariable::VariableType varType;
    00123                                 switch((*civ).type()){
    00124                                 case variable::CONTROL:
    00125                                         varType = BaseModelVariable::Control;
    00126                                         break;
    00127                                 case variable::DEPENDENT:
    00128                                         varType = BaseModelVariable::Dependent;
    00129                                         break;
    00130                                 case variable::OBSERVABLE:
    00131                                         varType = BaseModelVariable::Observable;
    00132                                         break;
    00133                                 case variable::STATE:
    00134                                         varType = BaseModelVariable::State;
    00135                                         break;
    00136                                 default:
    00137                                         varType = BaseModelVariable::Unknown;
    00138                                         break;
    00139                                 }
    00140                                 baseModel->addVariable((*civ).name().c_str(), varType, bmDomain);
    00141                         }
    00142                 }
    00143                 giTable = new GITable(baseModel);
    00144                 */
    00145                 giTable = new GITable(model_p);
    00146                 if(FAILED(giTable->loadGITable(CCGIT_file_name)))
    00147                 {
    00148                         printf("Error loading file: %s\n", CCGIT_file_name);
    00149                         return 1;
    00150                 }
    00151         }
    00152 #else
    00153 #ifdef USE_CME
    00154         if (argc == 2)  // mof test file given...
    00155         {
    00156                 model_p = load_MOF(argv[0]);
    00157                 MOF_file_name = argv[0];
    00158                 if(ccmeReader.loadCCMEFile(argv[1], *model_p))
    00159                 {
    00160                         cout << "ERROR: Couldn't load dissents and compiled transitions." << endl;
    00161                         exit(-1);
    00162                 }
    00163         }else{
    00164                 if(argc == -1)
    00165                         printf("Use: Titan_test <CCA file> <CCME File>\n");
    00166                 else
    00167                         printf("Use: %s <CCA file> <CCME File>\n", argv[-1]);
    00168                 return 1;
    00169         }
    00170 #else
    00171         if (argc == 1)  // mof test file given...
    00172         {
    00173                 model_p = load_MOF(argv[0]);
    00174                 MOF_file_name = argv[0];
    00175         }else{
    00176                 if(argc == -1)
    00177                         printf("Use: Titan_test <CCA file>\n");
    00178                 else
    00179                         printf("Use: %s <CCA file>\n", argv[-1]);
    00180                 return 1;
    00181         }
    00182 #endif
    00183 #endif
    00184         cout << "Using " << MOF_file_name << " model..." << endl << endl;
    00185
    00186 // Mode Estimator instantiation
    00187 #ifdef USE_CME
    00188         ModeEstimator           mode_estimator(*model_p, ccmeReader.getDissents(), ccmeReader.getTransitions());
    00189 #else
    00190         ModeEstimator           mode_estimator(*model_p);
    00191         //ModeEstimator         mode_estimator(model_p, true);
    00192 #endif
    00193
    00194 /*#
    00195         // Hack
    00196 //      mode_estimator.update_current_state(0, 4);
    00197 //      mode_estimator.update_current_state(4, 2);
    00198 //      mode_estimator.update_current_state(6, 2);
    00199 //      mode_estimator.update_current_state(10, 2);
    00200 //      mode_estimator.update_current_state(18, 4);
    00201 */
    00202
    00203 #ifdef USE_CGI
    00204         //CompiledGoalInterpreter * gi =
    00205         //      new CompiledGoalInterpreter(giTable, baseModel);
    00206         CompiledGoalInterpreter * gi =
    00207                 new CompiledGoalInterpreter(giTable, model_p);
    00208 #else
    00209         GoalInterpreter * gi = new GoalInterpreter(model_p);
    00210 #endif
    00211
    00212         modeReconfiguration mode_reconfiguration(*model_p, gi);
    00213         MEInterface *           me_interface_p = new MEInterface(&mode_estimator);
    00214         mrInterface *           mr_interface_p = new mrInterface(mode_reconfiguration);
    00215         //mr_interface_p->setDebug(true);
    00216         TitanCallbackStub *     Titan_callback_p = new TitanCallbackStub();
    00217         TitanInterface *        Titan_interface_p =
    00218                 new TitanInterface(Titan_callback_p, me_interface_p, mr_interface_p);
    00219
    00220         cout << endl << "Running demo..." << endl << endl;
    00221         run_Titan_shell(Titan_interface_p, model_p, &mode_estimator);
    00222         cout << endl << MOF_file_name << "... demo done." << endl;
    00223
    00224         sleep(1); // Give dispatchers time to finish all threads.
    00225         delete Titan_interface_p;
    00226
    00227         delete Titan_callback_p;
    00228
    00229         assert(model_p != NULL);
    00230         delete model_p;
    00231
    00232 #ifdef USE_CGI
    00233         //delete baseModel;
    00234 #endif
    00235
    00236         return 0;
    00237 }
    00238
    00239 CCAModel *
    00240 load_MOF(char const * MOF_file_name)
    00241 {
    00242         if (MOF_file_name == "")
    00243         {
    00244                 cerr << endl << "No MOF file specified." << endl;
    00245                 exit(-1);
    00246         }
    00247
    00248         CCAModel *model_p = new CCAModel();
    00249
    00250         if(MOFReader::loadMOF(MOF_file_name, *model_p))
    00251         {
    00252                 delete model_p;
    00253                 cerr << endl << "Could not load " << MOF_file_name << "." << endl;
    00254                 exit(-1);
    00255         }
    00256         return model_p;
    00257 }
    00258
    00259 void
    00260 run_Titan_shell(TitanInterface *Titan_interface_p, CCAModel const *model_p, ModeEstimator * me)
    00261 {
    00262         int             var_index, val_index;
    00263         char    char_p[300];
    00264         bool    quit_shell = false;
    00265
    00266         cout << endl << "TITAN Shell: Enter 'h' for help.";
    00267         cout << endl << endl;
    00268
    00269         while (!quit_shell)
    00270         {
    00271                 cout << "> " << flush;
    00272                 eat_space_or_tab(cin);
    00273                 cin.get(char_p, 2);
    00274
    00275                 // 'c' or 'C' corresponds to queue command.
    00276                 if (char_p[0] == 'c' || char_p[0] == 'C')
    00277                 {
    00278                         if (read_pair_of_int(cin, var_index, val_index) == false)
    00279                         {
    00280                                 cout << "Error: 'c' must be followed by pair of integers." << endl;
    00281                         }
    00282                         else
    00283                         {
    00284                                 Titan_interface_p->queue_command(var_index, val_index);
    00285                                 cout << endl;
    00286                         }
    00287                 }
    00288                 // 'e' or 'E' corresponds to queue find mode estimate.
    00289                 else if (char_p[0] == 'e' || char_p[0] == 'E')
    00290                 {
    00291                         eat_space_or_tab(cin);
    00292                         if (cin.peek() == '\n')
    00293                         {
    00294                                 Titan_interface_p->queue_find_mode_estimate();
    00295                                 sleep(1);
    00296                                 cout << endl;
    00297                         }
    00298                         else
    00299                         {
    00300                                 cin >> char_p;
    00301                                 if (char_p[0] == '-' && char_p[1] == 'f')
    00302                                 {
    00303                                         Titan_interface_p->queue_report_full_state();
    00304                                         sleep(1);
    00305                                         cout << endl;
    00306                                 }
    00307                                 else
    00308                                 {
    00309                                         Titan_interface_p->queue_find_mode_estimate();
    00310                                         sleep(1);
    00311                                         cout << endl;
    00312                                 }
    00313                         }
    00314                 }
    00315                 // 'g' or 'G' corresponds to queue goal.
    00316                 else if (char_p[0] == 'g' || char_p[0] == 'G')
    00317                 {
    00318                         if (read_pair_of_int(cin, var_index, val_index) == false)
    00319                         {
    00320                                 cout << "Error: 'g' must be followed by pair of integers." << endl;
    00321                         }
    00322                         else
    00323                         {
    00324                                 do{
    00325                                         Titan_interface_p->queue_goal(var_index, val_index);
    00326                                 }while(read_pair_of_int(cin, var_index, val_index));
    00327                                 cout << endl;
    00328                         }
    00329                 }
    00330                 // 'h' or 'H' or '?' corresponds to display help.
    00331                 else if (char_p[0] == 'h' || char_p[0] == 'H' || char_p[0] == '?')
    00332                 {
    00333                         eat_space_or_tab(cin);
    00334                         if (cin.peek() == '\n')
    00335                         {
    00336                                 print_Titan_shell_help('h');
    00337                                 cout << endl;
    00338                         }
    00339                         else
    00340                         {
    00341                                 cin >> char_p;
    00342                                 if (char_p[0] != '\0')
    00343                                 {
    00344                                         print_Titan_shell_help(char_p[0]);
    00345                                         cout << endl;
    00346                                 }
    00347                                 else
    00348                                 {
    00349                                         print_Titan_shell_help('h');
    00350                                         cout << endl;
    00351                                 }
    00352                         }
    00353                 }
    00354                 // 's' or 'S' corresponds to queue observation.
    00355                 else if (char_p[0] == 's' || char_p[0] == 'S')
    00356                 {
    00357                         if (read_pair_of_int(cin, var_index, val_index) == false)
    00358                         {
    00359                                 cout << "Error: 's' must be followed by pair of integers." << endl;
    00360                         }
    00361                         else
    00362                         {
    00363                                 do{
    00364                                         Titan_interface_p->queue_initial_state(var_index, val_index);
    00365                                 }while(read_pair_of_int(cin, var_index, val_index));
    00366                                 cout << endl;
    00367                         }
    00368                 }
    00369                 // 'o' or 'O' corresponds to queue observation.
    00370                 else if (char_p[0] == 'o' || char_p[0] == 'O')
    00371                 {
    00372                         if (read_pair_of_int(cin, var_index, val_index) == false)
    00373                         {
    00374                                 cout << "Error: 'o' must be followed by pair of integers." << endl;
    00375                         }
    00376                         else
    00377                         {
    00378                                 do{
    00379                                         Titan_interface_p->queue_observation(var_index, val_index);
    00380                                 }while(read_pair_of_int(cin, var_index, val_index));
    00381                                 cout << endl;
    00382                         }
    00383                 }
    00384                 // 'q' or 'Q' corresponds to display quit.
    00385                 else if (char_p[0] == 'q' || char_p[0] == 'Q') // quit
    00386                 {
    00387                         quit_shell = true;
    00388                 }
    00389                 // 'r' or 'R' corresponds to queue observation.
    00390                 else if (char_p[0] == 'r' || char_p[0] == 'R')
    00391                 {
    00392                         Titan_interface_p->queue_request_MR();
    00393                         sleep(1);
    00394                         cout << endl;
    00395                 }
    00396                 // 'v' or 'V' corresponds to display all variables.
    00397                 else if (char_p[0] == 'v' || char_p[0] == 'V')
    00398                 {
    00399                         eat_space_or_tab(cin);
    00400                         if (cin.peek() == '\n')
    00401                         {
    00402                                 print_variables(model_p->variables_p(), 'a', me);
    00403                                 cout << endl;
    00404                         }
    00405                         else
    00406                         {
    00407                                 cin >> char_p;
    00408                                 if (char_p[0] == '-' && char_p[1] != '\0')
    00409                                 {
    00410                                         print_variables(model_p->variables_p(), char_p[1], me);
    00411                                         cout << endl;
    00412                                 }
    00413                                 else
    00414                                 {
    00415                                         print_variables(model_p->variables_p(), 'a', me);
    00416                                         cout << endl;
    00417                                 }
    00418                         }
    00419                 }
    00420                 clear_stream(cin);
    00421         }
    00422 }
    00423
    00424 void
    00425 print_Titan_shell_help(char ch)
    00426 {
    00427         if (ch == 'c')
    00428         {
    00429                 cout << "NAME" << endl;
    00430                 cout << "\tc - queues a command to Mode Estimation" << endl << endl;
    00431                 cout << "SYNOPSIS" << endl;
    00432                 cout << "\tc (VARIABLE_INDEX = VALUE_INDEX)" << endl << endl;
    00433                 cout << "DESCRIPTION" << endl;
    00434                 cout << "\tQueues the command VARIABLE_INDEX = VALUE_INDEX to Mode Estimation."
    00435                          << endl;
    00436         }
    00437         else if (ch == 'e')
    00438         {
    00439                 cout << "NAME" << endl;
    00440                 cout << "\te - queues find_mode_estimate to Mode Estimation" << endl << endl;
    00441                 cout << "SYNOPSIS" << endl;
    00442                 cout << "\te [OPTION]" << endl << endl;
    00443                 cout << "DESCRIPTION" << endl;
    00444                 cout << "\tQueues find_mode_estimate() to Mode Estimation." << endl << endl;
    00445                 cout << "\t-f\tQueues reprot_full_mode_estimate() to Mode Estimation." << endl;
    00446         }
    00447         else if (ch == 'g')
    00448         {
    00449                 cout << "NAME" << endl;
    00450                 cout << "\tg - queues goals to Mode Reconfiguration" << endl << endl;
    00451                 cout << "SYNOPSIS" << endl;
    00452                 cout << "\tg (VARIABLE_INDEX = VALUE_INDEX)" << endl << endl;
    00453                 cout << "DESCRIPTION" << endl;
    00454                 cout << "\tQueues the goal VARIABLE_INDEX = VALUE_INDEX to Mode Reconfiguration."
    00455                          << endl;
    00456         }
    00457         else if (ch == 'h')
    00458         {
    00459                 cout << "  s : sets a mode variable in the leading trajectory in ME" << endl;
    00460                 cout << "  c : queues a command to ME" << endl;
    00461                 cout << "  o : queues an observation to ME" << endl;
    00462                 cout << "  e : queues find_mode_estimate to ME" << endl;
    00463                 cout << "  g : queues a goal to MR" << endl;
    00464                 cout << "  h : displays this help" << endl;
    00465                 cout << "  q : quit" << endl;
    00466                 cout << "  r : queues a reconfiguration request to MR" << endl;
    00467                 cout << "  v : displays variables" << endl;
    00468                 cout << endl;
    00469         }
    00470         else if (ch == 's')
    00471         {
    00472                 cout << "NAME" << endl;
    00473                 cout << "\ts - sets a mode variable in the leading trajectory in Mode Estimation" << endl << endl;
    00474                 cout << "SYNOPSIS" << endl;
    00475                 cout << "\ts (VARIABLE_INDEX = VALUE_INDEX)" << endl << endl;
    00476                 cout << "DESCRIPTION" << endl;
    00477                 cout << "\tSets the mode VARIABLE_INDEX = VALUE_INDEX of the leading trajectory in Mode Estimation."
    00478                          << endl;
    00479                 cout << "\t The trajectory probability is set to 1 and all other trajectories are eliminated." << endl;
    00480         }
    00481         else if (ch == 'o')
    00482         {
    00483                 cout << "NAME" << endl;
    00484                 cout << "\to - queues an observation to Mode Estimation" << endl << endl;
    00485                 cout << "SYNOPSIS" << endl;
    00486                 cout << "\to (VARIABLE_INDEX = VALUE_INDEX)" << endl << endl;
    00487                 cout << "DESCRIPTION" << endl;
    00488                 cout << "\tQueues the observation VARIABLE_INDEX = VALUE_INDEX to Mode Estimation."
    00489                          << endl;
    00490         }
    00491         else if (ch == 'q')
    00492         {
    00493                 cout << "NAME" << endl;
    00494                 cout << "\tq - quit Titan Interface test" << endl << endl;
    00495                 cout << "SYNOPSIS" << endl;
    00496                 cout << "\tq" << endl << endl;
    00497                 cout << "DESCRIPTION" << endl;
    00498                 cout << "\tQuits out of Titan Interface test."
    00499                          << endl;
    00500         }
    00501         else if (ch == 'r')
    00502         {
    00503                 cout << "NAME" << endl;
    00504                 cout << "\tr - queues a reconfiguration request to Mode Reconfiguration" << endl << endl;
    00505                 cout << "SYNOPSIS" << endl;
    00506                 cout << "\tr" << endl << endl;
    00507                 cout << "DESCRIPTION" << endl;
    00508                 cout << "\tQueues a reconfiguration request to Mode Reconfiguration."
    00509                          << endl;
    00510         }
    00511         else if (ch == 'v')
    00512         {
    00513                 cout << "NAME" << endl;
    00514                 cout << "\tv - displays the model variables and the corresponding indicies"
    00515                          << endl << endl;
    00516                 cout << "SYNOPSIS" << endl;
    00517                 cout << "\tv [OPTION]" << endl << endl;
    00518                 cout << "DESCRIPTION" << endl;
    00519                 cout << "\tDisplays the model variables and the corresponding indicies" << endl;
    00520                 cout << "\tand domain." << endl << endl;
    00521                 cout << "\t-c\tdisplays only control variables." << endl;
    00522                 cout << "\t-d\tdisplays only dependent variables." << endl;
    00523                 cout << "\t-o\tdisplays only observable variables." << endl;
    00524                 cout << "\t-s\tdisplays only state variables." << endl;
    00525         }
    00526 }
    00527
    00528 void print_variable(CCAVariable const * var)
    00529 {
    00530         cout << var->getName() << '[' << var->getUID() << "]: {";
    00531         CCADomain const &dom = *(var->getDomain());
    00532         for(unsigned int x = 0; x < dom.getLength(); x++){
    00533                 if(x != 0)
    00534                         cout << ", ";
    00535                 cout << dom[x]->getName() << '[' << dom[x]->getUID() << ']';
    00536         }
    00537         cout << "}" << endl;
    00538 }
    00539
    00540 void
    00541 print_variables(CCAVariables const *variables_p, char ch, ModeEstimator const * me)
    00542 {
    00543         CCAVariables::const_iterator const_it;
    00544
    00545         if (ch == 'c')
    00546         {
    00547 /*              for (const_it = variables_p->begin(); const_it != variables_p->end(); const_it++)
    00548                 {
    00549                         if (const_it->getVariableType() == CCAVariable::CONTROL)
    00550                         {
    00551                                 print_variable(&(*const_it));
    00552                         }
    00553                 }
    00554 */
    00555                 me->showCommandVars(cout);
    00556         }
    00557         else if (ch == 'd')
    00558         {
    00559                 for (const_it = variables_p->begin(); const_it != variables_p->end(); const_it++)
    00560                 {
    00561                         if (const_it->getVariableType() == CCAVariable::DEPENDENT)
    00562                         {
    00563                                 print_variable(&(*const_it));
    00564                         }
    00565                 }
    00566         }
    00567         else if (ch == 'o')
    00568         {
    00569 /*              for (const_it = variables_p->begin(); const_it != variables_p->end(); const_it++)
    00570                 {
    00571                         if (const_it->getVariableType() == CCAVariable::OBSERVABLE)
    00572                         {
    00573                                 print_variable(&(*const_it));
    00574                         }
    00575                 }
    00576 */
    00577                 me->showObservationVars(cout);
    00578         }
    00579         else if (ch == 's')
    00580         {
    00581 /*              for (const_it = variables_p->begin(); const_it != variables_p->end(); const_it++)
    00582                 {
    00583                         if (const_it->getVariableType() == CCAVariable::STATE)
    00584                         {
    00585                                 print_variable(&(*const_it));
    00586                         }
    00587                 }
    00588 */
    00589                 me->showStateVars(cout);
    00590         }
    00591         else
    00592         {
    00593 /*              for (const_it = variables_p->begin(); const_it != variables_p->end(); const_it++)
    00594                 {
    00595                         print_variable(&(*const_it));
    00596                 }
    00597 */
    00598                 me->showAllVars(cout);
    00599         }
    00600 }
    00601
    00602 void
    00603 eat_space_or_tab(istream &stream)
    00604 {
    00605         while(stream.peek() == ' ' || stream.peek() == '\t')
    00606         {
    00607                 stream.ignore(1);
    00608         }
    00609 }
    00610
    00611 void
    00612 clear_stream(istream &stream)
    00613 {
    00614         while(stream.peek() != '\n')
    00615         {
    00616                 stream.ignore(1);
    00617         }
    00618         stream.ignore(1);
    00619 }
    00620
    00621 bool
    00622 read_pair_of_int(istream &stream, int &int_1, int &int_2)
    00623 {
    00624         while((stream.peek() < '0' || stream.peek() > '9') && stream.peek() != '\n')
    00625         {
    00626                 stream.ignore(1);
    00627         }
    00628         if (stream.peek() == '\n')
    00629         {
    00630                 return false;
    00631         }
    00632         stream >> int_1;
    00633         while((stream.peek() < '0' || stream.peek() > '9') && stream.peek() != '\n')
    00634         {
    00635                 stream.ignore(1);
    00636         }
    00637         if (stream.peek() == '\n')
    00638         {
    00639                 return false;
    00640         }
    00641         stream >> int_2;
    00642         return true;
    00643 }