A Discrete-Event Network Simulator
API
gnuplot-aggregator.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Bucknell University
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: L. Felipe Perrone (perrone@bucknell.edu)
19  *
20  * Modified by: Mitch Watrous (watrous@u.washington.edu)
21  *
22  */
23 
24 #ifndef GNUPLOT_AGGREGATOR_H
25 #define GNUPLOT_AGGREGATOR_H
26 
27 #include <map>
28 #include <string>
29 #include "ns3/gnuplot.h"
30 #include "ns3/data-collection-object.h"
31 
32 namespace ns3 {
33 
39 {
40 public:
43  {
47  KEY_BELOW
48  };
49 
54  static TypeId GetTypeId ();
55 
67  GnuplotAggregator (const std::string &outputFileNameWithoutExtension);
68 
69  virtual ~GnuplotAggregator ();
70 
71  // Below are hooked to connectors exporting data
72  // They are not overloaded since it confuses the compiler when made
73  // into callbacks
74 
84  void Write2d (std::string context, double x, double y);
85 
97  void Write2dWithXErrorDelta (std::string context,
98  double x,
99  double y,
100  double errorDelta);
101 
113  void Write2dWithYErrorDelta (std::string context,
114  double x,
115  double y,
116  double errorDelta);
117 
130  void Write2dWithXYErrorDelta (std::string context,
131  double x,
132  double y,
133  double xErrorDelta,
134  double yErrorDelta);
135 
136  // Methods to configure the plot
137 
142  void SetTerminal (const std::string &terminal);
143 
147  void SetTitle (const std::string &title);
148 
153  void SetLegend (const std::string &xLegend, const std::string &yLegend);
154 
158  void SetExtra (const std::string &extra);
159 
163  void AppendExtra (const std::string &extra);
164 
165  // Methods for datasets
166 
179  void Add2dDataset (const std::string &dataset, const std::string &title);
180 
187  static void Set2dDatasetDefaultExtra (const std::string &extra);
188 
198  void Set2dDatasetExtra (const std::string &dataset, const std::string &extra);
199 
211  void Write2dDatasetEmptyLine (const std::string &dataset);
212 
218  static void Set2dDatasetDefaultStyle (enum Gnuplot2dDataset::Style style);
219 
229  void Set2dDatasetStyle (const std::string &dataset, enum Gnuplot2dDataset::Style style);
230 
236  static void Set2dDatasetDefaultErrorBars (enum Gnuplot2dDataset::ErrorBars errorBars);
237 
252  void Set2dDatasetErrorBars (const std::string &dataset, enum Gnuplot2dDataset::ErrorBars errorBars);
253 
259  void SetKeyLocation (enum KeyLocation keyLocation);
260 
261 private:
264 
266  std::string m_graphicsFileName;
267 
269  std::string m_title;
270 
272  std::string m_terminal;
273 
275  std::string m_xLegend;
276 
278  std::string m_yLegend;
279 
282  std::string m_extra;
283 
286 
289 
292 
294  std::map<std::string, Gnuplot2dDataset> m_2dDatasetMap;
295 
296 }; // class GnuplotAggregator
297 
298 
299 } // namespace ns3
300 
301 #endif // GNUPLOT_AGGREGATOR_H
Base class for data collection framework objects.
ErrorBars
Whether errorbars should be used for this dataset.
Definition: gnuplot.h:138
Style
The plotting style to use for this dataset.
Definition: gnuplot.h:123
This aggregator produces output used to make gnuplot plots.
void Write2dDatasetEmptyLine(const std::string &dataset)
Add an empty line in the data output sequence.
std::string m_title
The title.
GnuplotAggregator(const std::string &outputFileNameWithoutExtension)
void Write2dWithXErrorDelta(std::string context, double x, double y, double errorDelta)
Writes a 2D value to a 2D gnuplot dataset with error bars in the x direction.
static void Set2dDatasetDefaultExtra(const std::string &extra)
Change extra formatting style parameters for newly created objects.
Gnuplot m_gnuplot
Used to create gnuplot files.
void Write2d(std::string context, double x, double y)
Writes a 2D value to a 2D gnuplot dataset.
std::string m_graphicsFileName
The graphics file name with its extension.
bool m_xAndYLegendsSet
Set equal to true after setting the x and y legends.
void Set2dDatasetExtra(const std::string &dataset, const std::string &extra)
Add extra formatting parameters to this dataset.
std::string m_yLegend
The y legend.
void AppendExtra(const std::string &extra)
void Write2dWithYErrorDelta(std::string context, double x, double y, double errorDelta)
Writes a 2D value to a 2D gnuplot dataset with error bars in the y direction.
std::string m_outputFileNameWithoutExtension
The output file name without any extension.
static TypeId GetTypeId()
Get the type ID.
bool m_titleSet
Set equal to true after setting the title.
std::string m_terminal
The terminal.
std::string m_xLegend
The x legend.
void Set2dDatasetStyle(const std::string &dataset, enum Gnuplot2dDataset::Style style)
Set the style of plotting to use for this dataset.
void Set2dDatasetErrorBars(const std::string &dataset, enum Gnuplot2dDataset::ErrorBars errorBars)
Set the error bars to use for this dataset.
void Write2dWithXYErrorDelta(std::string context, double x, double y, double xErrorDelta, double yErrorDelta)
Writes a 2D value to a 2D gnuplot dataset with error bars in the x and y directions.
std::string m_extra
The extra gnuplot command that will be added to the gnuplot control statements.
KeyLocation
The location of the key in the plot.
void SetKeyLocation(enum KeyLocation keyLocation)
Set the location of the key in the plot.
static void Set2dDatasetDefaultErrorBars(enum Gnuplot2dDataset::ErrorBars errorBars)
Change default errorbars style for all newly created objects.
void SetTerminal(const std::string &terminal)
void Add2dDataset(const std::string &dataset, const std::string &title)
Adds a 2D dataset to the plot.
std::map< std::string, Gnuplot2dDataset > m_2dDatasetMap
Maps context strings to 2D datasets.
void SetLegend(const std::string &xLegend, const std::string &yLegend)
void SetTitle(const std::string &title)
static void Set2dDatasetDefaultStyle(enum Gnuplot2dDataset::Style style)
Change default style for all newly created objects.
void SetExtra(const std::string &extra)
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
Definition: gnuplot.h:373
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
list x
Random number samples.