A Discrete-Event Network Simulator
API
data-collector.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 Drexel 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: Joe Kopena (tjkopena@cs.drexel.edu)
19  */
20 
21 #include "ns3/object.h"
22 #include "ns3/log.h"
23 
24 #include "data-collector.h"
25 #include "data-calculator.h"
26 
27 using namespace ns3;
28 
29 NS_LOG_COMPONENT_DEFINE ("DataCollector");
30 
31 //--------------------------------------------------------------
32 //----------------------------------------------
34  NS_LOG_FUNCTION (this);
35  // end DataCollector::DataCollector
36 }
37 
39  NS_LOG_FUNCTION (this);
40  // end DataCollector::~DataCollector
41 }
42 
43 /* static */
44 TypeId
46 {
47  static TypeId tid = TypeId ("ns3::DataCollector")
48  .SetParent<Object> ()
49  .SetGroupName ("Stats")
50  .AddConstructor<DataCollector> ()
51  ;
52  return tid;
53 }
54 
56  NS_LOG_FUNCTION (this);
57 
58  m_calcList.clear ();
59  m_metadata.clear ();
60 
62  // end DataCollector::DoDispose
63 }
64 
65 void
67  std::string strategy,
68  std::string input,
69  std::string runID,
70  std::string description)
71 {
72  NS_LOG_FUNCTION (this << experiment << strategy << input << runID << description);
73 
75  m_strategyLabel = strategy;
76  m_inputLabel = input;
77  m_runLabel = runID;
78  m_description = description;
79 
80  // end DataCollector::DescribeRun
81 }
82 
83 void
85 {
86  NS_LOG_FUNCTION (this << datac);
87 
88  m_calcList.push_back (datac);
89 
90  // end DataCollector::AddDataCalculator
91 }
92 
93 DataCalculatorList::iterator
95 {
96  return m_calcList.begin ();
97  // end DataCollector::DataCalculatorBegin
98 }
99 DataCalculatorList::iterator
101 {
102  return m_calcList.end ();
103  // end DataCollector::DataCalculatorEnd
104 }
105 
106 void
107 DataCollector::AddMetadata (std::string key, std::string value)
108 {
109  NS_LOG_FUNCTION (this << key << value);
110 
111  std::pair<std::string, std::string> blob (key, value);
112  m_metadata.push_back (blob);
113  // end DataCollector::AddMetadata
114 }
115 void
116 DataCollector::AddMetadata (std::string key, uint32_t value)
117 {
118  NS_LOG_FUNCTION (this << key << value);
119 
120  std::stringstream st;
121  st << value;
122 
123  std::pair<std::string, std::string> blob (key, st.str ());
124  m_metadata.push_back (blob);
125  // end DataCollector::AddMetadata
126 }
127 void
128 DataCollector::AddMetadata (std::string key, double value)
129 {
130  NS_LOG_FUNCTION (this << key << value);
131 
132  std::stringstream st;
133  st << value;
134 
135  std::pair<std::string, std::string> blob (key, st.str ());
136  m_metadata.push_back (blob);
137  // end DataCollector::AddMetadata
138 }
139 
140 MetadataList::iterator
142 {
143  return m_metadata.begin ();
144  // end DataCollector::MetadataBegin
145 }
146 MetadataList::iterator
148 {
149  return m_metadata.end ();
150  // end DataCollector::MetadataEnd
151 }
Collects data.
std::string m_strategyLabel
Strategy label.
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.
static TypeId GetTypeId(void)
Register this type.
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.
virtual ~DataCollector()
MetadataList m_metadata
List of experiment metadata.
virtual void DoDispose()
Destructor implementation.
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:88
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
void experiment(std::string queue_disc_type)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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.