Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

livingstone_debug.h

Go to the documentation of this file.
00001 //
00002 // A nonflight class that contains debugging functions
00003 // $Id: livingstone_debug.h,v 1.19 2000/09/13 20:44:29 kurien Exp $
00004 //
00005 
00006 #ifndef LIVINGSTONE_DEBUG_H
00007 #define LIVINGSTONE_DEBUG_H
00008 
00009 #include <opsat/cbfs_tracker_debug.h>
00010 #include <cover/cover_tracker_debug.h>
00011 #include <livingstone/livingstone.h>
00012 #include <livdll/livdll.h>
00013 
00014 #include <iostream.h>
00015 
00016 
00020 
00021 template <class Search_tracker_debug_type, class Search_tracker_type>
00022 class LIVDLL_API Livingstone_debug {
00023 
00024 
00025 public:
00026 Livingstone_debug(Livingstone<Search_tracker_type>* liv, ostream& outstream)
00027   :  stream(outstream),engine(liv),
00028   tracker_debugger(new Search_tracker_debug_type(liv->tracker,outstream))  {};
00029 
00030   void listener();
00031 
00036   bool parse_cmd(char* cmd, char* args) {
00037         // Skip comment character
00038         if (!strncmp("//",cmd,2)) {
00039                 return true;
00040                 }
00041 
00042         if (!strcmp("help",cmd)) {
00043                 listener_usage();
00044                 return true;
00045                 }
00046 
00047 
00048         return tracker_debugger->parse_cmd(cmd,args);
00049 
00050   }
00051 
00052 
00053   void listener_usage() {
00054         stream << endl;
00055         tracker_debugger->listener_usage();
00056         stream << "  exit" << endl << endl;
00057   }
00058 
00059   Livingstone<Search_tracker_type>* get_engine() { return engine; };
00060         
00061 
00062 private:
00063   Search_tracker_debug_type *tracker_debugger;
00064   Livingstone<Search_tracker_type>* engine;
00065 
00066     ostream &stream;
00067 };
00068 
00069 template <class Search_tracker_debug_type,class Search_tracker_type>
00070 void 
00071 Livingstone_debug<Search_tracker_debug_type,Search_tracker_type>::listener()    {
00072 
00073  char cmd[MBA_MAX_LINE_SIZE];
00074  char rest_of_line[MBA_MAX_LINE_SIZE];
00075 
00076  stream << "Type  help    for a list and description of commands"<< endl << endl;
00077 
00078  for (;;) {
00079           stream << "L2> " ;
00080           stream.flush();
00081           cin >> cmd;
00082 
00083 
00084           if (!strcmp("exit",cmd))
00085                   return;
00086 
00087           cin.getline(rest_of_line,MBA_MAX_LINE_SIZE);
00088 
00089 
00090           // Echo means copy the output verbatim into the output stream.
00091           if (!strcmp("echo",cmd)) {
00092                   cout << rest_of_line << endl;
00093                   continue;
00094                   }
00095           
00096           // Pass the cmd and args to parser
00097 
00098           // First take off any leading spaces.  The line
00099           // is null terminated, so we know this loop will
00100           // stop at the end of the character array.
00101           char* args;
00102           for(args=rest_of_line;' '==*args;++args);
00103 
00104           // Check to see if any lower-level debuggers understood
00105           // the command.
00106           if (parse_cmd(cmd,args))
00107                   continue;
00108 
00109           // If the command is unknown, print some instructions
00110           cerr << "Didn't understand cmd " << cmd << endl;
00111           listener_usage();
00112           
00113   }
00114 }
00115 
00116 // Instantiate classes Livingstone_debug<CBFS_tracker_debug,CBFS_tracker> and 
00117 // Livingstone_debug<Cover_tracker_debug,Cover_tracker>.
00118 // This does not create an object. It only forces the generation of all
00119 // of the members of classes Livingstone<CBFS_tracker> and Livingstone<Cover_tracker>. 
00120 // It exports them from the DLL and imports them into the .exe file.
00121 #ifdef WIN32
00122 EXPIMP_TEMPLATE template class LIVDLL_API Livingstone_debug<CBFS_tracker_debug,CBFS_tracker>;
00123 EXPIMP_TEMPLATE template class LIVDLL_API Livingstone_debug<Cover_tracker_debug,Cover_tracker>;
00124 
00125 #endif
00126 
00127 #endif // LIVINGSTONE_DEBUG_H

Generated at Wed Sep 20 10:10:25 2000 for livingstone by doxygen 1.1.3 written by Dimitri van Heesch, © 1997-2000