A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
gnuplot.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007 INRIA, 2008 Timo Bingmann
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
* Original Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
* Enhancements: Timo Bingmann <timo.bingmann@student.kit.edu>
20
*/
21
#ifndef GNUPLOT_H
22
#define GNUPLOT_H
23
24
#include <string>
25
#include <vector>
26
#include <utility>
27
28
namespace
ns3 {
29
38
class
GnuplotDataset
39
{
40
public
:
41
45
GnuplotDataset
(
const
GnuplotDataset
& original);
46
50
~GnuplotDataset
();
51
55
GnuplotDataset
&
operator=
(
const
GnuplotDataset
& original);
56
61
void
SetTitle
(
const
std::string& title);
62
67
static
void
SetDefaultExtra
(
const
std::string& extra);
68
73
void
SetExtra
(
const
std::string& extra);
74
75
protected
:
76
79
friend
class
Gnuplot
;
80
84
static
std::string
m_defaultExtra
;
85
89
struct
Data
;
90
95
GnuplotDataset
(
struct
Data
*
data
);
96
100
struct
Data
*
m_data
;
101
};
102
107
class
Gnuplot2dDataset
:
public
GnuplotDataset
108
{
109
public
:
113
enum
Style
{
114
LINES
,
115
POINTS
,
116
LINES_POINTS
,
117
DOTS
,
118
IMPULSES
,
119
STEPS
,
120
FSTEPS
,
121
HISTEPS
,
122
};
123
127
enum
ErrorBars
{
128
NONE
,
129
X
,
130
Y
,
131
XY
132
};
133
140
Gnuplot2dDataset
(
const
std::string& title =
"Untitled"
);
141
146
static
void
SetDefaultStyle
(
enum
Style
style);
147
151
void
SetStyle
(
enum
Style
style);
152
157
static
void
SetDefaultErrorBars
(
enum
ErrorBars
errorBars);
158
167
void
SetErrorBars
(
enum
ErrorBars
errorBars);
168
175
void
Add
(
double
x
,
double
y);
176
184
void
Add
(
double
x
,
double
y,
double
errorDelta);
185
194
void
Add
(
double
x
,
double
y,
double
xErrorDelta,
double
yErrorDelta);
195
200
void
AddEmptyLine
();
201
202
private
:
203
204
struct
Point
{
205
bool
empty
;
206
double
x
;
207
double
y
;
208
double
dx
;
209
double
dy
;
210
};
211
212
typedef
std::vector<struct Point>
PointSet
;
213
214
static
enum
Style
m_defaultStyle
;
215
static
enum
ErrorBars
m_defaultErrorBars
;
216
218
struct
Data2d
;
219
};
220
227
class
Gnuplot2dFunction
:
public
GnuplotDataset
228
{
229
public
:
237
Gnuplot2dFunction
(
const
std::string& title =
"Untitled"
,
const
std::string&
function
=
""
);
238
242
void
SetFunction
(
const
std::string&
function
);
243
244
private
:
245
247
struct
Function2d
;
248
};
249
254
class
Gnuplot3dDataset
:
public
GnuplotDataset
255
{
256
public
:
263
Gnuplot3dDataset
(
const
std::string& title =
"Untitled"
);
264
269
static
void
SetDefaultStyle
(
const
std::string& style);
270
274
void
SetStyle
(
const
std::string& style);
275
283
void
Add
(
double
x
,
double
y,
double
z);
284
289
void
AddEmptyLine
();
290
291
private
:
292
293
struct
Point
{
294
bool
empty
;
295
double
x
,
y
,
z
;
296
};
297
298
typedef
std::vector<struct Point>
PointSet
;
299
300
static
std::string
m_defaultStyle
;
301
303
struct
Data3d
;
304
};
305
313
class
Gnuplot3dFunction
:
public
GnuplotDataset
314
{
315
public
:
323
Gnuplot3dFunction
(
const
std::string& title =
"Untitled"
,
const
std::string&
function
=
""
);
324
328
void
SetFunction
(
const
std::string&
function
);
329
330
private
:
331
333
struct
Function3d
;
334
};
335
343
class
Gnuplot
344
{
345
public
:
352
Gnuplot
(
const
std::string& outputFilename=
""
,
const
std::string& title =
""
);
353
359
void
SetOutputFilename
(
const
std::string& outputFilename);
360
366
static
std::string
DetectTerminal
(
const
std::string& filename);
367
372
void
SetTerminal
(
const
std::string& terminal);
373
377
void
SetTitle
(
const
std::string& title);
378
383
void
SetLegend
(
const
std::string& xLegend,
const
std::string& yLegend);
384
388
void
SetExtra
(
const
std::string& extra);
389
393
void
AppendExtra
(
const
std::string& extra);
394
398
void
AddDataset
(
const
GnuplotDataset
& dataset);
399
408
void
GenerateOutput
(std::ostream &os);
409
422
void
GenerateOutput
(std::ostream &osControl,
423
std::ostream &osData,
424
std::string dataFileName);
425
431
void
SetDataFileDatasetIndex
(
unsigned
int
index);
432
433
private
:
434
typedef
std::vector<GnuplotDataset>
Datasets
;
435
436
std::string
m_outputFilename
;
437
std::string
m_terminal
;
438
439
Datasets
m_datasets
;
440
441
std::string
m_title
;
442
std::string
m_xLegend
;
443
std::string
m_yLegend
;
444
std::string
m_extra
;
445
446
bool
m_generateOneOutputFile
;
447
448
unsigned
int
m_dataFileDatasetIndex
;
449
};
450
455
class
GnuplotCollection
456
{
457
public
:
463
GnuplotCollection
(
const
std::string& outputFilename);
464
469
void
SetTerminal
(
const
std::string& terminal);
470
474
void
AddPlot
(
const
Gnuplot
& plot);
475
481
Gnuplot
&
GetPlot
(
unsigned
int
id
);
482
487
void
GenerateOutput
(std::ostream &os);
488
498
void
GenerateOutput
(std::ostream &osControl,
499
std::ostream &osData,
500
std::string dataFileName);
501
502
private
:
503
typedef
std::vector<Gnuplot>
Plots
;
504
505
std::string
m_outputFilename
;
506
std::string
m_terminal
;
507
508
Plots
m_plots
;
509
};
510
511
}
// namespace ns3
512
513
#endif
/* GNUPLOT_H */
src
stats
model
gnuplot.h
Generated on Fri Aug 30 2013 01:43:02 for ns-3 by
1.8.1.2