A Discrete-Event Network Simulator
API
data-collector.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 Drexel University
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Joe Kopena (tjkopena@cs.drexel.edu)
18  */
19 
20 #include "data-collector.h"
21 
22 #include "data-calculator.h"
23 
24 #include "ns3/log.h"
25 #include "ns3/object.h"
26 
27 using namespace ns3;
28 
29 NS_LOG_COMPONENT_DEFINE("DataCollector");
30 
31 //--------------------------------------------------------------
32 //----------------------------------------------
34 {
35  NS_LOG_FUNCTION(this);
36  // end DataCollector::DataCollector
37 }
38 
40 {
41  NS_LOG_FUNCTION(this);
42  // end DataCollector::~DataCollector
43 }
44 
45 /* static */
46 TypeId
48 {
49  static TypeId tid = TypeId("ns3::DataCollector")
50  .SetParent<Object>()
51  .SetGroupName("Stats")
52  .AddConstructor<DataCollector>();
53  return tid;
54 }
55 
56 void
58 {
59  NS_LOG_FUNCTION(this);
60 
61  m_calcList.clear();
62  m_metadata.clear();
63 
65  // end DataCollector::DoDispose
66 }
67 
68 void
70  std::string strategy,
71  std::string input,
72  std::string runID,
73  std::string description)
74 {
75  NS_LOG_FUNCTION(this << experiment << strategy << input << runID << description);
76 
78  m_strategyLabel = strategy;
79  m_inputLabel = input;
80  m_runLabel = runID;
81  m_description = description;
82 
83  // end DataCollector::DescribeRun
84 }
85 
86 void
88 {
89  NS_LOG_FUNCTION(this << datac);
90 
91  m_calcList.push_back(datac);
92 
93  // end DataCollector::AddDataCalculator
94 }
95 
96 DataCalculatorList::iterator
98 {
99  return m_calcList.begin();
100  // end DataCollector::DataCalculatorBegin
101 }
102 
103 DataCalculatorList::iterator
105 {
106  return m_calcList.end();
107  // end DataCollector::DataCalculatorEnd
108 }
109 
110 void
111 DataCollector::AddMetadata(std::string key, std::string value)
112 {
113  NS_LOG_FUNCTION(this << key << value);
114 
115  std::pair<std::string, std::string> blob(key, value);
116  m_metadata.push_back(blob);
117  // end DataCollector::AddMetadata
118 }
119 
120 void
121 DataCollector::AddMetadata(std::string key, uint32_t value)
122 {
123  NS_LOG_FUNCTION(this << key << value);
124 
125  std::stringstream st;
126  st << value;
127 
128  std::pair<std::string, std::string> blob(key, st.str());
129  m_metadata.push_back(blob);
130  // end DataCollector::AddMetadata
131 }
132 
133 void
134 DataCollector::AddMetadata(std::string key, double value)
135 {
136  NS_LOG_FUNCTION(this << key << value);
137 
138  std::stringstream st;
139  st << value;
140 
141  std::pair<std::string, std::string> blob(key, st.str());
142  m_metadata.push_back(blob);
143  // end DataCollector::AddMetadata
144 }
145 
146 MetadataList::iterator
148 {
149  return m_metadata.begin();
150  // end DataCollector::MetadataBegin
151 }
152 
153 MetadataList::iterator
155 {
156  return m_metadata.end();
157  // end DataCollector::MetadataEnd
158 }
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:89
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:352
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
void experiment(std::string queue_disc_type)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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.