A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
data-collector.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 Drexel University
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Joe Kopena (tjkopena@cs.drexel.edu)
7 */
8
9#include "data-collector.h"
10
11#include "data-calculator.h"
12
13#include "ns3/log.h"
14#include "ns3/object.h"
15
16using namespace ns3;
17
18NS_LOG_COMPONENT_DEFINE("DataCollector");
19
20//--------------------------------------------------------------
21//----------------------------------------------
23{
24 NS_LOG_FUNCTION(this);
25 // end DataCollector::DataCollector
26}
27
29{
30 NS_LOG_FUNCTION(this);
31 // end DataCollector::~DataCollector
32}
33
34/* static */
37{
38 static TypeId tid = TypeId("ns3::DataCollector")
40 .SetGroupName("Stats")
41 .AddConstructor<DataCollector>();
42 return tid;
43}
44
45void
47{
48 NS_LOG_FUNCTION(this);
49
50 m_calcList.clear();
51 m_metadata.clear();
52
54 // end DataCollector::DoDispose
55}
56
57void
59 std::string strategy,
60 std::string input,
61 std::string runID,
62 std::string description)
63{
64 NS_LOG_FUNCTION(this << experiment << strategy << input << runID << description);
65
67 m_strategyLabel = strategy;
68 m_inputLabel = input;
69 m_runLabel = runID;
70 m_description = description;
71
72 // end DataCollector::DescribeRun
73}
74
75void
77{
78 NS_LOG_FUNCTION(this << datac);
79
80 m_calcList.push_back(datac);
81
82 // end DataCollector::AddDataCalculator
83}
84
85DataCalculatorList::iterator
87{
88 return m_calcList.begin();
89 // end DataCollector::DataCalculatorBegin
90}
91
92DataCalculatorList::iterator
94{
95 return m_calcList.end();
96 // end DataCollector::DataCalculatorEnd
97}
98
99void
100DataCollector::AddMetadata(std::string key, std::string value)
101{
102 NS_LOG_FUNCTION(this << key << value);
103
104 std::pair<std::string, std::string> blob(key, value);
105 m_metadata.push_back(blob);
106 // end DataCollector::AddMetadata
107}
108
109void
111{
112 NS_LOG_FUNCTION(this << key << value);
113
114 std::stringstream st;
115 st << value;
116
117 std::pair<std::string, std::string> blob(key, st.str());
118 m_metadata.push_back(blob);
119 // end DataCollector::AddMetadata
120}
121
122void
123DataCollector::AddMetadata(std::string key, double value)
124{
125 NS_LOG_FUNCTION(this << key << value);
126
127 std::stringstream st;
128 st << value;
129
130 std::pair<std::string, std::string> blob(key, st.str());
131 m_metadata.push_back(blob);
132 // end DataCollector::AddMetadata
133}
134
135MetadataList::iterator
137{
138 return m_metadata.begin();
139 // end DataCollector::MetadataBegin
140}
141
142MetadataList::iterator
144{
145 return m_metadata.end();
146 // end DataCollector::MetadataEnd
147}
Collects data.
std::string m_strategyLabel
Strategy label.
void DoDispose() override
Destructor implementation.
static TypeId GetTypeId()
Register this type.
DataCalculatorList::iterator DataCalculatorBegin()
Returns an iterator to the beginning of the DataCalculator list.
DataCalculatorList::iterator DataCalculatorEnd()
Returns an iterator to the past-the-end of the DataCalculator list.
std::string m_experimentLabel
Experiment label.
MetadataList::iterator MetadataBegin()
Returns an iterator to the beginning of the metadata list.
DataCalculatorList m_calcList
List of data calculators.
MetadataList::iterator MetadataEnd()
Returns an iterator to the past-the-end of the metadata list.
std::string m_description
Description label.
void AddMetadata(std::string key, std::string value)
Add the key and the value as a pair of strings to the metadata list.
std::string m_inputLabel
Input label.
void AddDataCalculator(Ptr< DataCalculator > datac)
Add a DataCalculator object to the DataCollector.
~DataCollector() override
MetadataList m_metadata
List of experiment metadata.
void DescribeRun(std::string experiment, std::string strategy, std::string input, std::string runID, std::string description="")
Provide specific parameters to the DataCollector.
std::string m_runLabel
Run label.
A base class which provides memory management and object aggregation.
Definition object.h:78
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
void experiment(std::string queue_disc_type)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.