Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Tools/Xabsl2/Xabsl2Engine/Xabsl2Tools.h

Go to the documentation of this file.
00001 /**
00002 * @file Xabsl2Tools.h
00003 *
00004 * Definition of several helper classes for the XabslEngine.
00005 *
00006 * @author Matthias Jüngel
00007 * @author Martin Lötzsch
00008 */
00009 
00010 #ifndef __Xabsl2Tools_h_
00011 #define __Xabsl2Tools_h_
00012 
00013 #include "Xabsl2Array.h"
00014 
00015 /**
00016 * A Xabsl2Engine helper class for reading input data from files or from memory.
00017 */
00018 class Xabsl2InputSource
00019 {
00020 public:
00021   /** opens the source that contains the intermediate code */
00022   virtual bool open() = 0;
00023   
00024   /** closes the source */
00025   virtual void close() = 0;
00026 
00027   /** reads a numeric value from the input source */
00028   virtual double readValue() = 0;
00029 
00030   /** 
00031   * reads a string from the input source
00032   * @param destination The position where to write the string
00033   * @param maxLength the maximum length of the string
00034   * @return if the read succeded
00035   */
00036   virtual bool readString(char* destination, int maxLength) = 0;
00037 };
00038 
00039 /**
00040 * A Xabsl2Engine helper class for handling errors and debug messages
00041 */
00042 class Xabsl2ErrorHandler
00043 {
00044 public:
00045   /** constructor */
00046   Xabsl2ErrorHandler() : errorsOccurred(false) {};
00047 
00048   /** 
00049   * Prints out an error
00050   * @param text The text to display
00051   */
00052   virtual void printError(const char* text) = 0;
00053 
00054   /**
00055   * Prints out a message
00056   * @param text The text to display
00057   */
00058   virtual void printMessage(const char* text) = 0;
00059 
00060   /** 
00061   * Formats a error message and calls the printError() function.
00062   * @param format Format string as used by printf defined in stdio.h.
00063   * @param ... See printf in stdio.h.
00064   */
00065   void error(const char* format, ...);
00066 
00067   /** 
00068   * Formats a message and calls the printMessage() function 
00069   * @param format Format string as used by printf defined in stdio.h.
00070   * @param ... See printf in stdio.h.
00071   */
00072   void message(const char* format, ...);
00073 
00074   /** if errors occurred */
00075   bool errorsOccurred;
00076 
00077 private:
00078   /** a buffer for errors and debug messages */
00079   char messageBuffer[300];
00080 };
00081 
00082 /**
00083 * @typedef TimeFunction
00084 * A pointer to a function that returns the current system time.
00085 */
00086 typedef unsigned long (*TimeFunction)();
00087 
00088 // If that variable is defined, the engine prints a lot of debug messages during initialization 
00089 // #define XABSL2_DO_DEBUG_INIT
00090 
00091 /** Expressions inside that macro are only executed if XABSL2_DEBUG_INIT is defined */
00092 #ifdef XABSL2_DO_DEBUG_INIT
00093 #define XABSL2_DEBUG_INIT(expression) expression
00094 #else
00095 #define XABSL2_DEBUG_INIT(expression) /**/
00096 #endif
00097 
00098 
00099 #endif //__Xabsl2Tools_h_
00100 
00101 /*
00102 * Change Log:
00103 *
00104 * $Log: Xabsl2Tools.h,v $
00105 * Revision 1.1.1.1  2004/05/22 17:37:58  cvsadm
00106 * created new repository GT2004_WM
00107 *
00108 * Revision 1.1  2003/10/07 10:13:25  cvsadm
00109 * Created GT2004 (M.J.)
00110 *
00111 * Revision 1.3  2003/09/30 10:51:11  dueffert
00112 * typos fixed
00113 *
00114 * Revision 1.2  2003/08/09 14:53:10  dueffert
00115 * files and docu beautified
00116 *
00117 * Revision 1.1.1.1  2003/07/02 09:40:29  cvsadm
00118 * created new repository for the competitions in Padova from the 
00119 * tamara CVS (Tuesday 2:00 pm)
00120 *
00121 * removed unused solutions
00122 *
00123 * Revision 1.4  2003/01/13 13:19:38  loetzsch
00124 * switched off the XABSL2_DEBUG_INIT macro
00125 *
00126 * Revision 1.3  2002/12/06 21:13:37  loetzsch
00127 * Decimal input symbols can now be registered at the engine
00128 *
00129 * Revision 1.2  2002/12/02 19:56:32  loetzsch
00130 * - Xabsl2Array now seems to work for more than 1 element
00131 * - Basic behaviors now can be registered at the engine
00132 * - Basic behaviors have access to their parameters
00133 *
00134 * Revision 1.1  2002/12/01 17:54:29  loetzsch
00135 * continued Xabsl2Engine: Xabsl2Array seems to work now
00136 *
00137 */

Generated on Thu Sep 23 19:57:42 2004 for GT2004 by doxygen 1.3.6