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

# Tools/Debugging/View.h

Go to the documentation of this file.

    00001 /**
    00002  * @file Tools/Debugging/View.h
    00003  *
    00004  * This file declares the view classes and macros.
    00005  *
    00006  * @author <A href=mailto:roefer@tzi.de>Thomas Röfer</A>
    00007  */
    00008 #ifndef __View_H__
    00009 #define __View_H__
    00010
    00011 #include "Tools/List.h"
    00012 #include "Tools/Debugging/DebugDrawings.h"
    00013 #include "Tools/Debugging/DebugImages.h"
    00014
    00015 /**
    00016  * The class is a base class for image views.
    00017  */
    00018 class ImageViewBase
    00019 {
    00020   public:
    00021     static List<ImageViewBase*> list; /**< The list of all views. */
    00022
    00023     /**
    00024      * The function returns information on the view to create.
    00025      * @param name Returns the name of the view.
    00026      * @param layers Returns a list of layer ids.
    00027      * @param numOfLayers Returns the length of the list.
    00028      */
    00029     virtual void getInfo(const char*& name,
    00030                          Drawings::ImageDrawing*& layers,
    00031                          int& numOfLayers,
    00032                          Images::ImageID& id) = 0;
    00033
    00034     /**
    00035      * Constructor.
    00036      */
    00037     ImageViewBase() {list.insert(this);}
    00038 };
    00039
    00040 /**
    00041  * The class is a base class for field views.
    00042  */
    00043 class FieldViewBase
    00044 {
    00045   public:
    00046     static List<FieldViewBase*> list; /**< The list of all views. */
    00047
    00048     /**
    00049      * The function returns information on the view to create.
    00050      * @param name Returns the name of the view.
    00051      * @param layers Returns a list of layer ids.
    00052      * @param numOfLayers Returns the length of the list.
    00053      */
    00054     virtual void getInfo(const char*& name,
    00055                          Drawings::FieldDrawing*& layers,
    00056                          int& numOfLayers) = 0;
    00057
    00058     /**
    00059      * Constructor.
    00060      */
    00061     FieldViewBase() {list.insert(this);}
    00062 };
    00063
    00064 /**
    00065  * The macro begins the definition of an image view.
    00066  * It must be followed by a list of Drawings::ImageDrawing constants.
    00067  * These constants define the layers that will be drawn in the view.
    00068  * The list must be finished by the END_VIEW macro.
    00069  * @param name The name of the view.
    00070  * @param name The background image of the view.
    00071  */
    00072 #define IMAGE_VIEW(name,background) \
    00073   class _View##name : public ImageViewBase\
    00074   { \
    00075     public: \
    00076       static const char* viewName; \
    00077       static Drawings::ImageDrawing layers[]; \
    00078       static int numOfLayers; \
    00079     public: \
    00080     virtual void getInfo(const char*& s,Drawings::ImageDrawing*& l,int& n,Images::ImageID& id) \
    00081         {s = viewName; l = layers + 1; n = numOfLayers; id = Images::background;} \
    00082   } _view##name; \
    00083   const char* _View##name::viewName = "image." #name; \
    00084   Drawings::ImageDrawing _View##name::layers[] = {Drawings::numberOfImageDrawings,
    00085
    00086 /**
    00087  * The macro begins the definition of a field view.
    00088  * It must be followed by a list of Drawings::FieldDrawing constants.
    00089  * These constants define the layers that will be drawn on the view.
    00090  * The list must be finished by the END_VIEW macro.
    00091  * @param name The name of the view.
    00092  */
    00093 #define FIELD_VIEW(name) \
    00094   class _View##name : public FieldViewBase\
    00095   { \
    00096     public: \
    00097       static const char* viewName; \
    00098       static Drawings::FieldDrawing layers[]; \
    00099       static int numOfLayers; \
    00100     public: \
    00101       virtual void getInfo(const char*& s,Drawings::FieldDrawing*& l,int& n) \
    00102         {s = viewName; l = layers + 1; n = numOfLayers;} \
    00103   } _view##name; \
    00104   const char* _View##name::viewName = "field." #name; \
    00105   Drawings::FieldDrawing _View##name::layers[] = {Drawings::numberOfFieldDrawings,
    00106
    00107 /**
    00108  * The macro finishes the definition of a view.
    00109  * @param name The name of the view. It must be the same as
    00110  *             used at the beginning of the list.
    00111  */
    00112 #define END_VIEW(name) \
    00113   }; \
    00114   int _View##name::numOfLayers = sizeof(_View##name::layers) / sizeof(_View##name::layers[0]) - 1;
    00115
    00116 #endif