A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
44  NS_LOG_FUNCTION (this);
45 
46  m_calcList.clear ();
47  m_metadata.clear ();
48 
50  // end DataCollector::DoDispose
51 }
52 
53 void
55  std::string strategy,
56  std::string input,
57  std::string runID,
58  std::string description)
59 {
60  NS_LOG_FUNCTION (this << experiment << strategy << input << runID << description);
61 
63  m_strategyLabel = strategy;
64  m_inputLabel = input;
65  m_runLabel = runID;
66  m_description = description;
67 
68  // end DataCollector::DescribeRun
69 }
70 
71 void
73 {
74  NS_LOG_FUNCTION (this << datac);
75 
76  m_calcList.push_back (datac);
77 
78  // end DataCollector::AddDataCalculator
79 }
80 
81 DataCalculatorList::iterator
83 {
84  return m_calcList.begin ();
85  // end DataCollector::DataCalculatorBegin
86 }
87 DataCalculatorList::iterator
89 {
90  return m_calcList.end ();
91  // end DataCollector::DataCalculatorEnd
92 }
93 
94 void
95 DataCollector::AddMetadata (std::string key, std::string value)
96 {
97  NS_LOG_FUNCTION (this << key << value);
98 
99  std::pair<std::string, std::string> blob (key, value);
100  m_metadata.push_back (blob);
101  // end DataCollector::AddMetadata
102 }
103 void
104 DataCollector::AddMetadata (std::string key, uint32_t value)
105 {
106  NS_LOG_FUNCTION (this << key << value);
107 
108  std::stringstream st;
109  st << value;
110 
111  std::pair<std::string, std::string> blob (key, st.str ());
112  m_metadata.push_back (blob);
113  // end DataCollector::AddMetadata
114 }
115 void
116 DataCollector::AddMetadata (std::string key, double 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 
128 MetadataList::iterator
130 {
131  return m_metadata.begin ();
132  // end DataCollector::MetadataBegin
133 }
134 MetadataList::iterator
136 {
137  return m_metadata.end ();
138  // end DataCollector::MetadataEnd
139 }
std::string m_strategyLabel
Strategy label.
DataCalculatorList::iterator DataCalculatorEnd()
Returns an iterator to the past-the-end of the DataCalculator list.
void experiment(bool enableCtsRts)
Run single 10 seconds experiment with enabled or disabled RTS/CTS mechanism.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: object.cc:335
std::string m_description
Description label.
virtual ~DataCollector()
MetadataList::iterator MetadataBegin()
Returns an iterator to the beginning of the metadata list.
void AddDataCalculator(Ptr< DataCalculator > datac)
Add a DataCalculator object to the DataCollector.
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_experimentLabel
Experiment label.
std::string m_runLabel
Run label.
DataCalculatorList m_calcList
List of data calculators.
std::string m_inputLabel
Input label.
DataCalculatorList::iterator DataCalculatorBegin()
Returns an iterator to the beginning of the DataCalculator list.
void DescribeRun(std::string experiment, std::string strategy, std::string input, std::string runID, std::string description="")
Provide specific parameters to the DataCollector.
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
MetadataList m_metadata
List of experiment metadata.
MetadataList::iterator MetadataEnd()
Returns an iterator to the past-the-end of the metadata list.