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_