plotoptionengine.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
00003  *    Georg Martius  <georg dot martius at web dot de>                     *
00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  *                                                                         *
00023  ***************************************************************************/
00024 
00025 #ifndef PLOTOPTIONENGINE_H_
00026 #define PLOTOPTIONENGINE_H_
00027 
00028 #include <list>
00029 
00030 #include "plotoption.h"
00031 #include <selforg/abstractcontroller.h>
00032 
00033 class Inspectable;
00034 
00035 /*
00036  *
00037  */
00038 class PlotOptionEngine
00039 {
00040 public:
00041   PlotOptionEngine(const PlotOption& plotOption);
00042   PlotOptionEngine(const std::list<PlotOption>& plotOptions);
00043 
00044   virtual ~PlotOptionEngine();
00045 
00046   /** initializes PlotOptionEngine and opens all pipes and stuff.
00047       The optional controller is used to print structure information
00048    */
00049   virtual bool init(AbstractController* maybe_controller =0);
00050 
00051   /**
00052    * Reinitialises the PlotOptionEngine.
00053    * This means it closes all open pipes by calling closePipes()
00054    * and restarts them by calling init().
00055    * @return true if succeeded, otherwise false.
00056    */
00057   virtual bool reInit();
00058 
00059   /**
00060    * Closes all open pipes of the current used PlotOptions.
00061    */
00062   virtual void closePipes();
00063 
00064   /**
00065      sets the name of all plotoptions (call before init, but after options are added)
00066    */
00067   virtual void setName(const std::string& name);
00068 
00069   /** adds the PlotOptions to the list of plotoptions
00070       If a plotoption with the same Mode exists, then the old one is deleted first
00071    */
00072   virtual PlotOption& addPlotOption(PlotOption& plotoption);
00073 
00074   /**
00075    * Adds the PlotOptions to the list of plotoptions
00076    * If a plotoption with the same Mode exists, then the old one is deleted first
00077    * The plotting is also initialized but only if the PlotOptionEngine is already intialized,
00078    * This can be forced by additional param.
00079    * @param plotoption The PlotOption to add
00080    * @param forceInit force initialization of PlotOption even if PlotOptionEngine is not initalized.
00081    *        This may cause problems. Use this at your own risk.
00082    * @return
00083    */
00084   virtual bool addAndInitPlotOption(PlotOption& plotoption, bool forceInit = false);
00085 
00086   /** removes the PlotOptions with the given type
00087       @return true if sucessful, false otherwise
00088    */
00089   virtual bool removePlotOption(PlotMode mode);
00090 
00091 
00092   /** adds an inspectable object for logging. Must be called before init!
00093    */
00094   virtual void addInspectable(const Inspectable* inspectable, bool front = false);
00095 
00096   /** adds an configureable object for logging. Must be called before init!
00097    */
00098   virtual void addConfigurable(const Configurable* c);
00099 
00100   /**
00101      write comment to output streams (PlotOptions). For instance changes in parameters.
00102   */
00103   virtual void writePlotComment(const char* cmt);
00104 
00105   virtual void plot(double time);
00106 
00107 protected:
00108 
00109   bool initPlotOption(PlotOption& po);
00110 
00111   std::list<PlotOption> plotOptions;
00112   std::list<const Inspectable* > inspectables;
00113   std::list< const Configurable* > configureables;
00114   long int t;
00115   
00116   bool initialised;
00117 
00118 
00119   // old artefact, should be removed in future releases
00120   AbstractController* maybe_controller;
00121 
00122   std::string name; // name given to PlotOptions
00123 };
00124 
00125 #endif /* PLOTOPTIONENGINE_H_ */
Generated on Thu Jun 28 14:45:37 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3