Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
plotoptionengine.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 
25 #ifndef PLOTOPTIONENGINE_H_
26 #define PLOTOPTIONENGINE_H_
27 
28 #include <list>
29 
30 #include "plotoption.h"
31 #include <selforg/abstractcontroller.h>
32 
33 class Inspectable;
34 
35 /*
36  *
37  */
39 {
40 public:
41  PlotOptionEngine(const PlotOption& plotOption);
42  PlotOptionEngine(const std::list<PlotOption>& plotOptions);
43 
44  virtual ~PlotOptionEngine();
45 
46  /** initializes PlotOptionEngine and opens all pipes and stuff.
47  The optional controller is used to print structure information
48  */
49  virtual bool init(AbstractController* maybe_controller =0);
50 
51  /**
52  * Reinitialises the PlotOptionEngine.
53  * This means it closes all open pipes by calling closePipes()
54  * and restarts them by calling init().
55  * @return true if succeeded, otherwise false.
56  */
57  virtual bool reInit();
58 
59  /**
60  * Closes all open pipes of the current used PlotOptions.
61  */
62  virtual void closePipes();
63 
64  /**
65  sets the name of all plotoptions (call before init, but after options are added)
66  */
67  virtual void setName(const std::string& name);
68 
69  /** adds the PlotOptions to the list of plotoptions
70  If a plotoption with the same Mode exists, then the old one is deleted first
71  */
72  virtual PlotOption& addPlotOption(const PlotOption& plotoption);
73 
74  /**
75  * Adds the PlotOptions to the list of plotoptions
76  * If a plotoption with the same Mode exists, then the old one is deleted first
77  * The plotting is also initialized but only if the PlotOptionEngine is already intialized,
78  * This can be forced by additional param.
79  * @param plotoption The PlotOption to add
80  * @param forceInit force initialization of PlotOption even if PlotOptionEngine is not initalized.
81  * This may cause problems. Use this at your own risk.
82  * @return
83  */
84  virtual bool addAndInitPlotOption(const PlotOption& plotoption, bool forceInit = false);
85 
86  /** removes the PlotOptions with the given type
87  @return true if sucessful, false otherwise
88  */
89  virtual bool removePlotOption(PlotMode mode);
90 
91 
92  /** adds an inspectable object for logging. Must be called before init!
93  */
94  virtual void addInspectable(const Inspectable* inspectable, bool front = false);
95 
96  /** adds an configureable object for logging. Must be called before init!
97  */
98  virtual void addConfigurable(const Configurable* c);
99 
100  /**
101  write comment to output streams (PlotOptions). For instance changes in parameters.
102  If addSpace then "# CMT" is output otherwise "#CMT".
103  */
104  virtual void writePlotComment(const char* cmt, bool addSpace=true );
105 
106  virtual void plot(double time);
107 
108 protected:
109 
110  bool initPlotOption(PlotOption& po);
111 
112  std::list<PlotOption> plotOptions;
113  std::list<const Inspectable* > inspectables;
114  std::list< const Configurable* > configureables;
115  long int t;
116 
118 
119 
120  // old artefact, should be removed in future releases
122 
123  std::string name; // name given to PlotOptions
124 };
125 
126 #endif /* PLOTOPTIONENGINE_H_ */
std::list< const Configurable * > configureables
Definition: plotoptionengine.h:114
PlotMode
Output mode for agent.
Definition: plotoption.h:40
Abstract class for robot controller (with some basic functionality).
Definition: abstractcontroller.h:46
std::string name
Definition: plotoptionengine.h:123
bool initialised
Definition: plotoptionengine.h:117
virtual bool addAndInitPlotOption(const PlotOption &plotoption, bool forceInit=false)
Adds the PlotOptions to the list of plotoptions If a plotoption with the same Mode exists...
Definition: plotoptionengine.cpp:146
virtual PlotOption & addPlotOption(const PlotOption &plotoption)
adds the PlotOptions to the list of plotoptions If a plotoption with the same Mode exists...
Definition: plotoptionengine.cpp:131
Definition: plotoptionengine.h:38
bool initPlotOption(PlotOption &po)
Definition: plotoptionengine.cpp:72
std::list< PlotOption > plotOptions
Definition: plotoptionengine.h:112
virtual ~PlotOptionEngine()
Definition: plotoptionengine.cpp:51
This class contains options for the use of an external plot utility like guilogger or neuronviz or ju...
Definition: plotoption.h:66
virtual void writePlotComment(const char *cmt, bool addSpace=true)
write comment to output streams (PlotOptions).
Definition: plotoptionengine.cpp:178
virtual void setName(const std::string &name)
sets the name of all plotoptions (call before init, but after options are added)
Definition: plotoptionengine.cpp:124
virtual void closePipes()
Closes all open pipes of the current used PlotOptions.
Definition: plotoptionengine.cpp:114
virtual bool reInit()
Reinitialises the PlotOptionEngine.
Definition: plotoptionengine.cpp:109
Interface for inspectable objects.
Definition: inspectable.h:48
Abstact class for configurable objects.
Definition: configurable.h:81
virtual void addConfigurable(const Configurable *c)
adds an configureable object for logging.
Definition: plotoptionengine.cpp:173
AbstractController * maybe_controller
Definition: plotoptionengine.h:121
long int t
Definition: plotoptionengine.h:115
virtual bool init(AbstractController *maybe_controller=0)
initializes PlotOptionEngine and opens all pipes and stuff.
Definition: plotoptionengine.cpp:56
std::list< const Inspectable * > inspectables
Definition: plotoptionengine.h:113
virtual void addInspectable(const Inspectable *inspectable, bool front=false)
adds an inspectable object for logging.
Definition: plotoptionengine.cpp:165
virtual bool removePlotOption(PlotMode mode)
removes the PlotOptions with the given type
Definition: plotoptionengine.cpp:154
PlotOptionEngine(const PlotOption &plotOption)
Definition: plotoptionengine.cpp:37
virtual void plot(double time)
Definition: plotoptionengine.cpp:194
int c
Definition: hexapod.cpp:56