A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::GnuplotAggregator Class Reference

This aggregator produces output used to make gnuplot plots. More...

#include "gnuplot-aggregator.h"

+ Inheritance diagram for ns3::GnuplotAggregator:
+ Collaboration diagram for ns3::GnuplotAggregator:

Public Types

enum  KeyLocation { NO_KEY , KEY_INSIDE , KEY_ABOVE , KEY_BELOW }
 The location of the key in the plot. More...
 

Public Member Functions

 GnuplotAggregator (const std::string &outputFileNameWithoutExtension)
 
 ~GnuplotAggregator () override
 
void Add2dDataset (const std::string &dataset, const std::string &title)
 Adds a 2D dataset to the plot.
 
void AppendExtra (const std::string &extra)
 
void Set2dDatasetErrorBars (const std::string &dataset, Gnuplot2dDataset::ErrorBars errorBars)
 Set the error bars to use for this dataset.
 
void Set2dDatasetExtra (const std::string &dataset, const std::string &extra)
 Add extra formatting parameters to this dataset.
 
void Set2dDatasetStyle (const std::string &dataset, Gnuplot2dDataset::Style style)
 Set the style of plotting to use for this dataset.
 
void SetExtra (const std::string &extra)
 
void SetKeyLocation (KeyLocation keyLocation)
 Set the location of the key in the plot.
 
void SetLegend (const std::string &xLegend, const std::string &yLegend)
 
void SetTerminal (const std::string &terminal)
 
void SetTitle (const std::string &title)
 
void Write2d (std::string context, double x, double y)
 Writes a 2D value to a 2D gnuplot dataset.
 
void Write2dDatasetEmptyLine (const std::string &dataset)
 Add an empty line in the data output sequence.
 
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.
 
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.
 
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.
 
- Public Member Functions inherited from ns3::DataCollectionObject
 DataCollectionObject ()
 
 ~DataCollectionObject () override
 
void Disable ()
 Unset the status of an individual object.
 
void Enable ()
 Set the status of an individual object.
 
std::string GetName () const
 Get the object's name.
 
virtual bool IsEnabled () const
 Check the status of an individual object.
 
void SetName (std::string name)
 Set the object's name.
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~Object () override
 Destructor.
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
 
void Dispose ()
 Dispose of this Object.
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object.
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
 
bool IsInitialized () const
 Check if the object has been initialized.
 
void UnidirectionalAggregateObject (Ptr< Object > other)
 Aggregate an Object to another Object.
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

static TypeId GetTypeId ()
 Get the type ID.
 
static void Set2dDatasetDefaultErrorBars (Gnuplot2dDataset::ErrorBars errorBars)
 Change default errorbars style for all newly created objects.
 
static void Set2dDatasetDefaultExtra (const std::string &extra)
 Change extra formatting style parameters for newly created objects.
 
static void Set2dDatasetDefaultStyle (Gnuplot2dDataset::Style style)
 Change default style for all newly created objects.
 
- Static Public Member Functions inherited from ns3::DataCollectionObject
static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.
 

Private Attributes

std::map< std::string, Gnuplot2dDatasetm_2dDatasetMap
 Maps context strings to 2D datasets.
 
std::string m_extra
 The extra gnuplot command that will be added to the gnuplot control statements.
 
Gnuplot m_gnuplot
 Used to create gnuplot files.
 
std::string m_graphicsFileName
 The graphics file name with its extension.
 
std::string m_outputFileNameWithoutExtension
 The output file name without any extension.
 
std::string m_terminal
 The terminal.
 
std::string m_title
 The title.
 
bool m_titleSet
 Set equal to true after setting the title.
 
bool m_xAndYLegendsSet
 Set equal to true after setting the x and y legends.
 
std::string m_xLegend
 The x legend.
 
std::string m_yLegend
 The y legend.
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
 
virtual void DoDispose ()
 Destructor implementation.
 
virtual void DoInitialize ()
 Initialize() implementation.
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated.
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 
- Protected Attributes inherited from ns3::DataCollectionObject
bool m_enabled
 Object's activation state.
 
std::string m_name
 Name of the object within the data collection framework.
 

Detailed Description

This aggregator produces output used to make gnuplot plots.

Definition at line 28 of file gnuplot-aggregator.h.

Member Enumeration Documentation

◆ KeyLocation

The location of the key in the plot.

Enumerator
NO_KEY 
KEY_INSIDE 
KEY_ABOVE 
KEY_BELOW 

Definition at line 32 of file gnuplot-aggregator.h.

Constructor & Destructor Documentation

◆ GnuplotAggregator()

ns3::GnuplotAggregator::GnuplotAggregator ( const std::string & outputFileNameWithoutExtension)
Parameters
outputFileNameWithoutExtensionname of gnuplot related files to write with no extension

Constructs a gnuplot file aggregator that will create a space separated gnuplot data file named outputFileNameWithoutExtension

  • ".dat", a gnuplot control file named outputFileNameWithoutExtension + ".plt", and a shell script to generate the gnuplot named outputFileNameWithoutExtension + ".sh".

Definition at line 34 of file gnuplot-aggregator.cc.

References NS_LOG_FUNCTION.

◆ ~GnuplotAggregator()

ns3::GnuplotAggregator::~GnuplotAggregator ( )
override

Definition at line 47 of file gnuplot-aggregator.cc.

References ns3::Gnuplot::AppendExtra(), ns3::Gnuplot::GenerateOutput(), m_gnuplot, m_outputFileNameWithoutExtension, m_titleSet, m_xAndYLegendsSet, NS_LOG_FUNCTION, and NS_LOG_WARN.

+ Here is the call graph for this function:

Member Function Documentation

◆ Add2dDataset()

void ns3::GnuplotAggregator::Add2dDataset ( const std::string & dataset,
const std::string & title )

Adds a 2D dataset to the plot.

Parameters
datasetthe gnuplot 2D dataset to be plotted.
titlethe title to be associated to this dataset.

Creates an empty dataset. Usually, the dataset's title is displayed in the legend box.

The string in dataset should match the context for the Collector it is connected to.

Definition at line 212 of file gnuplot-aggregator.cc.

References ns3::Gnuplot::AddDataset(), m_2dDatasetMap, m_gnuplot, NS_ABORT_MSG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ AppendExtra()

void ns3::GnuplotAggregator::AppendExtra ( const std::string & extra)
Parameters
extraappend extra gnuplot directive for output.

Definition at line 205 of file gnuplot-aggregator.cc.

References ns3::Gnuplot::AppendExtra(), m_gnuplot, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ GetTypeId()

TypeId ns3::GnuplotAggregator::GetTypeId ( )
static

Get the type ID.

Returns
the object TypeId

Definition at line 26 of file gnuplot-aggregator.cc.

References ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ Set2dDatasetDefaultErrorBars()

void ns3::GnuplotAggregator::Set2dDatasetDefaultErrorBars ( Gnuplot2dDataset::ErrorBars errorBars)
static

Change default errorbars style for all newly created objects.

Parameters
errorBarsthe style of errorbars to use for newly created datasets.

Definition at line 286 of file gnuplot-aggregator.cc.

References NS_LOG_FUNCTION, and ns3::Gnuplot2dDataset::SetDefaultErrorBars().

+ Here is the call graph for this function:

◆ Set2dDatasetDefaultExtra()

void ns3::GnuplotAggregator::Set2dDatasetDefaultExtra ( const std::string & extra)
static

Change extra formatting style parameters for newly created objects.

Parameters
extraextra formatting

Definition at line 230 of file gnuplot-aggregator.cc.

References NS_LOG_FUNCTION, and ns3::GnuplotDataset::SetDefaultExtra().

+ Here is the call graph for this function:

◆ Set2dDatasetDefaultStyle()

void ns3::GnuplotAggregator::Set2dDatasetDefaultStyle ( Gnuplot2dDataset::Style style)
static

Change default style for all newly created objects.

Parameters
stylethe style of plotting to use for newly created datasets.

Definition at line 266 of file gnuplot-aggregator.cc.

References NS_LOG_FUNCTION, and ns3::Gnuplot2dDataset::SetDefaultStyle().

+ Here is the call graph for this function:

◆ Set2dDatasetErrorBars()

void ns3::GnuplotAggregator::Set2dDatasetErrorBars ( const std::string & dataset,
Gnuplot2dDataset::ErrorBars errorBars )

Set the error bars to use for this dataset.

Parameters
datasetthe gnuplot 2D dataset to be plotted.
errorBarsthe style of errorbars to display.

If you use any style other than none, you need to make sure you store the delta information in this dataset with the right GnuplotDataset::Add method.

The string in dataset should match the context for the Collector it is connected to.

Definition at line 293 of file gnuplot-aggregator.cc.

References m_2dDatasetMap, NS_ABORT_MSG, and NS_LOG_FUNCTION.

◆ Set2dDatasetExtra()

void ns3::GnuplotAggregator::Set2dDatasetExtra ( const std::string & dataset,
const std::string & extra )

Add extra formatting parameters to this dataset.

Parameters
datasetthe gnuplot 2D dataset to be plotted.
extraextra formatting

The string in dataset should match the context for the Collector it is connected to.

Definition at line 237 of file gnuplot-aggregator.cc.

References m_2dDatasetMap, NS_ABORT_MSG, and NS_LOG_FUNCTION.

◆ Set2dDatasetStyle()

void ns3::GnuplotAggregator::Set2dDatasetStyle ( const std::string & dataset,
Gnuplot2dDataset::Style style )

Set the style of plotting to use for this dataset.

Parameters
datasetthe gnuplot 2D dataset to be plotted.
stylethe style of plotting to use for this dataset.

The string in dataset should match the context for the Collector it is connected to.

Definition at line 273 of file gnuplot-aggregator.cc.

References m_2dDatasetMap, NS_ABORT_MSG, and NS_LOG_FUNCTION.

◆ SetExtra()

void ns3::GnuplotAggregator::SetExtra ( const std::string & extra)
Parameters
extraset extra gnuplot directive for output.

Definition at line 198 of file gnuplot-aggregator.cc.

References m_gnuplot, NS_LOG_FUNCTION, and ns3::Gnuplot::SetExtra().

+ Here is the call graph for this function:

◆ SetKeyLocation()

void ns3::GnuplotAggregator::SetKeyLocation ( GnuplotAggregator::KeyLocation keyLocation)

Set the location of the key in the plot.

Parameters
keyLocationthe location of the key in the plot.

Definition at line 307 of file gnuplot-aggregator.cc.

References ns3::Gnuplot::AppendExtra(), KEY_ABOVE, KEY_BELOW, m_gnuplot, NO_KEY, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ SetLegend()

void ns3::GnuplotAggregator::SetLegend ( const std::string & xLegend,
const std::string & yLegend )
Parameters
xLegendthe legend for the x horizontal axis
yLegendthe legend for the y vertical axis

Definition at line 190 of file gnuplot-aggregator.cc.

References m_gnuplot, m_xAndYLegendsSet, NS_LOG_FUNCTION, and ns3::Gnuplot::SetLegend().

+ Here is the call graph for this function:

◆ SetTerminal()

void ns3::GnuplotAggregator::SetTerminal ( const std::string & terminal)
Parameters
terminalterminal setting string for output. The default terminal string is "png"

Definition at line 171 of file gnuplot-aggregator.cc.

References m_gnuplot, m_graphicsFileName, m_outputFileNameWithoutExtension, ns3::Gnuplot::SetOutputFilename(), and ns3::Gnuplot::SetTerminal().

+ Here is the call graph for this function:

◆ SetTitle()

void ns3::GnuplotAggregator::SetTitle ( const std::string & title)
Parameters
titleset new plot title string to use for this plot.

Definition at line 182 of file gnuplot-aggregator.cc.

References m_gnuplot, m_titleSet, NS_LOG_FUNCTION, and ns3::Gnuplot::SetTitle().

+ Here is the call graph for this function:

◆ Write2d()

void ns3::GnuplotAggregator::Write2d ( std::string context,
double x,
double y )

Writes a 2D value to a 2D gnuplot dataset.

Parameters
contextspecifies the gnuplot 2D dataset for these values
xx coordinate for the new data point
yy coordinate for the new data point

Use this method with error bar style NONE.

Definition at line 93 of file gnuplot-aggregator.cc.

References m_2dDatasetMap, ns3::DataCollectionObject::m_enabled, NS_ABORT_MSG, and NS_LOG_FUNCTION.

Referenced by ns3::GnuplotHelper::ConnectProbeToAggregator().

+ Here is the caller graph for this function:

◆ Write2dDatasetEmptyLine()

void ns3::GnuplotAggregator::Write2dDatasetEmptyLine ( const std::string & dataset)

Add an empty line in the data output sequence.

Parameters
datasetthe gnuplot 2D dataset to be plotted.

Writes an empty line in the plot data, which breaks continuous lines and does other things in the output.

The string in dataset should match the context for the Collector it is connected to.

Definition at line 250 of file gnuplot-aggregator.cc.

References m_2dDatasetMap, ns3::DataCollectionObject::m_enabled, NS_ABORT_MSG, and NS_LOG_FUNCTION.

◆ Write2dWithXErrorDelta()

void ns3::GnuplotAggregator::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.

Parameters
contextspecifies the gnuplot 2D dataset for these values
xx coordinate for the new data point
yy coordinate for the new data point
errorDeltax data point uncertainty

Use this method with error bar style X.

Definition at line 110 of file gnuplot-aggregator.cc.

References m_2dDatasetMap, ns3::DataCollectionObject::m_enabled, NS_ABORT_MSG, and NS_LOG_FUNCTION.

◆ Write2dWithXYErrorDelta()

void ns3::GnuplotAggregator::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.

Parameters
contextspecifies the gnuplot 2D dataset for these values
xx coordinate for the new data point
yy coordinate for the new data point
xErrorDeltax data point uncertainty
yErrorDeltay data point uncertainty

Use this method with error bar style XY.

Definition at line 150 of file gnuplot-aggregator.cc.

References m_2dDatasetMap, ns3::DataCollectionObject::m_enabled, NS_ABORT_MSG, and NS_LOG_FUNCTION.

◆ Write2dWithYErrorDelta()

void ns3::GnuplotAggregator::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.

Parameters
contextspecifies the gnuplot 2D dataset for these values
xx coordinate for the new data point
yy coordinate for the new data point
errorDeltay data point uncertainty

Use this method with error bar style Y.

Definition at line 130 of file gnuplot-aggregator.cc.

References m_2dDatasetMap, ns3::DataCollectionObject::m_enabled, NS_ABORT_MSG, and NS_LOG_FUNCTION.

Member Data Documentation

◆ m_2dDatasetMap

std::map<std::string, Gnuplot2dDataset> ns3::GnuplotAggregator::m_2dDatasetMap
private

◆ m_extra

std::string ns3::GnuplotAggregator::m_extra
private

The extra gnuplot command that will be added to the gnuplot control statements.

Definition at line 266 of file gnuplot-aggregator.h.

◆ m_gnuplot

Gnuplot ns3::GnuplotAggregator::m_gnuplot
private

Used to create gnuplot files.

Definition at line 275 of file gnuplot-aggregator.h.

Referenced by ~GnuplotAggregator(), Add2dDataset(), AppendExtra(), SetExtra(), SetKeyLocation(), SetLegend(), SetTerminal(), and SetTitle().

◆ m_graphicsFileName

std::string ns3::GnuplotAggregator::m_graphicsFileName
private

The graphics file name with its extension.

Definition at line 250 of file gnuplot-aggregator.h.

Referenced by SetTerminal().

◆ m_outputFileNameWithoutExtension

std::string ns3::GnuplotAggregator::m_outputFileNameWithoutExtension
private

The output file name without any extension.

Definition at line 247 of file gnuplot-aggregator.h.

Referenced by ~GnuplotAggregator(), and SetTerminal().

◆ m_terminal

std::string ns3::GnuplotAggregator::m_terminal
private

The terminal.

Definition at line 256 of file gnuplot-aggregator.h.

◆ m_title

std::string ns3::GnuplotAggregator::m_title
private

The title.

Definition at line 253 of file gnuplot-aggregator.h.

◆ m_titleSet

bool ns3::GnuplotAggregator::m_titleSet
private

Set equal to true after setting the title.

Definition at line 269 of file gnuplot-aggregator.h.

Referenced by ~GnuplotAggregator(), and SetTitle().

◆ m_xAndYLegendsSet

bool ns3::GnuplotAggregator::m_xAndYLegendsSet
private

Set equal to true after setting the x and y legends.

Definition at line 272 of file gnuplot-aggregator.h.

Referenced by ~GnuplotAggregator(), and SetLegend().

◆ m_xLegend

std::string ns3::GnuplotAggregator::m_xLegend
private

The x legend.

Definition at line 259 of file gnuplot-aggregator.h.

◆ m_yLegend

std::string ns3::GnuplotAggregator::m_yLegend
private

The y legend.

Definition at line 262 of file gnuplot-aggregator.h.


The documentation for this class was generated from the following files: