Robot Simulator of the Robotics Group for Self-Organization of Control: plotoptionengine.h Source File

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

- Search for |

- File List
- File Members

# plotoptionengine.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  *   Copyright (C) 2005 by Robot Group Leipzig                             *
    00003  *    martius@informatik.uni-leipzig.de                                    *
    00004  *    fhesse@informatik.uni-leipzig.de                                     *
    00005  *    der@informatik.uni-leipzig.de                                        *
    00006  *    guettler@informatik.uni-leipzig.de                                   *
    00007  *    joergweide84@aol.com (robot12)                                       *
    00008  *                                                                         *
    00009  *   This program is free software; you can redistribute it and/or modify  *
    00010  *   it under the terms of the GNU General Public License as published by  *
    00011  *   the Free Software Foundation; either version 2 of the License, or     *
    00012  *   (at your option) any later version.                                   *
    00013  *                                                                         *
    00014  *   This program is distributed in the hope that it will be useful,       *
    00015  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00016  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
    00017  *   GNU General Public License for more details.                          *
    00018  *                                                                         *
    00019  *   You should have received a copy of the GNU General Public License     *
    00020  *   along with this program; if not, write to the                         *
    00021  *   Free Software Foundation, Inc.,                                       *
    00022  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
    00023  ***************************************************************************
    00024  *                                                                         *
    00025  *  DESCRIPTION                                                            *
    00026  *                                                                         *
    00027  *                                                                         *
    00028  *                                                                         *
    00029  *  $Log: plotoptionengine.h,v $
    00030  *  Revision 1.6  2009/08/10 15:36:19  der
    00031  *  plotoptions can again be added and initialized later
    00032  *  ctrl-g and -f are working again
    00033  *  ctrl-n added for neuronviz
    00034  *
    00035  *  Revision 1.5  2009/08/10 07:37:48  guettler
    00036  *  -Inspectable interface now supports to add infoLines itself.
    00037  *   These lines are then outprinted line by line to the PlotOption once,
    00038  *   preceded by a #I.
    00039  *  -Restart functionality of PlotOptionEngine added (e.g. closePipes(), reInit()).
    00040  *
    00041  *  Revision 1.4  2009/08/05 22:53:02  martius
    00042  *  redesigned
    00043  *   works as a stand alone object now
    00044  *   added init function
    00045  *   configurables are now in engine and not in plotoptions
    00046  *   works with wiredcontroller
    00047  *
    00048  *  Revision 1.3  2009/07/21 08:50:16  robot12
    00049  *  finish of the split
    00050  *  to do: add some comments....
    00051  *
    00052  *  Revision 1.2  2009/06/30 14:20:49  robot12
    00053  *  finishing the gen API and add some comments
    00054  *
    00055  *  Revision 1.1  2009/06/02 09:55:24  robot12
    00056  *  Splitting of WiredController and PlotOption into WiredController : public PlotOptionEngine and
    00057  *  PlotOption (used by ga_tools). Further refactorings needed.
    00058  *                                                                                 *
    00059  *                                                                         *
    00060  **************************************************************************/
    00061
    00062 #ifndef PLOTOPTIONENGINE_H_
    00063 #define PLOTOPTIONENGINE_H_
    00064
    00065 #include <list>
    00066
    00067 #include "plotoption.h"
    00068 #include <selforg/abstractcontroller.h>
    00069
    00070 class Inspectable;
    00071
    00072 /*
    00073  *
    00074  */
    00075 class PlotOptionEngine
    00076 {
    00077 public:
    00078   PlotOptionEngine(const PlotOption& plotOption);
    00079   PlotOptionEngine(const std::list<PlotOption>& plotOptions);
    00080
    00081   virtual ~PlotOptionEngine();
    00082
    00083   /** initializes PlotOptionEngine and opens all pipes and stuff.
    00084       The optional controller is used to print structure information
    00085    */
    00086   virtual bool init(AbstractController* maybe_controller =0);
    00087
    00088   /**
    00089    * Reinitialises the PlotOptionEngine.
    00090    * This means it closes all open pipes by calling closePipes()
    00091    * and restarts them by calling init().
    00092    * @return true if succeeded, otherwise false.
    00093    */
    00094   virtual bool reInit();
    00095
    00096   /**
    00097    * Closes all open pipes of the current used PlotOptions.
    00098    */
    00099   virtual void closePipes();
    00100
    00101   /**
    00102      sets the name of all plotoptions (call before init, but after options are added)
    00103    */
    00104   virtual void setName(const std::string& name);
    00105
    00106   /** adds the PlotOptions to the list of plotoptions
    00107       If a plotoption with the same Mode exists, then the old one is deleted first
    00108    */
    00109   virtual PlotOption& addPlotOption(PlotOption& plotoption);
    00110
    00111   /** adds the PlotOptions to the list of plotoptions
    00112       If a plotoption with the same Mode exists, then the old one is deleted first
    00113       The plotting is also initialized
    00114    */
    00115   virtual bool addAndInitPlotOption(PlotOption& plotoption);
    00116
    00117   /** removes the PlotOptions with the given type
    00118       @return true if sucessful, false otherwise
    00119    */
    00120   virtual bool removePlotOption(PlotMode mode);
    00121
    00122
    00123   /** adds an inspectable object for logging. Must be called before init!
    00124    */
    00125   virtual void addInspectable(const Inspectable* inspectable);
    00126
    00127   /** adds an configureable object for logging. Must be called before init!
    00128    */
    00129   virtual void addConfigurable(const Configurable* c);
    00130
    00131   /**
    00132      write comment to output streams (PlotOptions). For instance changes in parameters.
    00133   */
    00134   virtual void writePlotComment(const char* cmt);
    00135
    00136   virtual void plot(double time);
    00137
    00138 protected:
    00139
    00140   bool initPlotOption(PlotOption& po);
    00141
    00142   std::list<PlotOption> plotOptions;
    00143   std::list<const Inspectable* > inspectables;
    00144   std::list< const Configurable* > configureables;
    00145   long int t;
    00146
    00147   bool initialised;
    00148
    00149   // old artefact, should be removed in future releases
    00150   AbstractController* maybe_controller;
    00151 };
    00152
    00153 #endif /* PLOTOPTIONENGINE_H_ */