27#include "ns3/nstime.h"
55 .SetGroupName(
"Stats")
72 res =
m_sqliteOut->SpinExec(
"CREATE TABLE IF NOT EXISTS Experiments (run, experiment, "
73 "strategy, input, description text)");
78 "INSERT INTO Experiments "
79 "(run, experiment, strategy, input, description)"
80 "values (?, ?, ?, ?, ?)");
109 res =
m_sqliteOut->WaitExec(
"CREATE TABLE IF NOT EXISTS "
110 "Metadata ( run text, key text, value)");
114 "INSERT INTO Metadata "
121 std::pair<std::string, std::string> blob = (*i);
135 (*i)->Output(callback);
149 m_db->WaitExec(
"CREATE TABLE IF NOT EXISTS Singletons "
150 "( run text, name text, variable text, value )");
153 "INSERT INTO Singletons "
154 "(run, name, variable, value)"
155 "values (?, ?, ?, ?)");
161 m_db->SpinFinalize(m_insertSingletonStatement);
166 std::string variable,
171 OutputSingleton(key, variable +
"-count",
static_cast<double>(statSum->
getCount()));
174 OutputSingleton(key, variable +
"-total", statSum->
getSum());
178 OutputSingleton(key, variable +
"-max", statSum->
getMax());
182 OutputSingleton(key, variable +
"-min", statSum->
getMin());
186 OutputSingleton(key, variable +
"-sqrsum", statSum->
getSqrSum());
190 OutputSingleton(key, variable +
"-stddev", statSum->
getStddev());
196 std::string variable,
201 m_db->SpinReset(m_insertSingletonStatement);
202 m_db->Bind(m_insertSingletonStatement, 2, key);
203 m_db->Bind(m_insertSingletonStatement, 3, variable);
204 m_db->Bind(m_insertSingletonStatement, 4, val);
205 m_db->SpinStep(m_insertSingletonStatement);
210 std::string variable,
215 m_db->SpinReset(m_insertSingletonStatement);
216 m_db->Bind(m_insertSingletonStatement, 2, key);
217 m_db->Bind(m_insertSingletonStatement, 3, variable);
218 m_db->Bind(m_insertSingletonStatement, 4, val);
219 m_db->SpinStep(m_insertSingletonStatement);
224 std::string variable,
229 m_db->SpinReset(m_insertSingletonStatement);
230 m_db->Bind(m_insertSingletonStatement, 2, key);
231 m_db->Bind(m_insertSingletonStatement, 3, variable);
232 m_db->Bind(m_insertSingletonStatement, 4, val);
233 m_db->SpinStep(m_insertSingletonStatement);
238 std::string variable,
243 m_db->SpinReset(m_insertSingletonStatement);
244 m_db->Bind(m_insertSingletonStatement, 2, key);
245 m_db->Bind(m_insertSingletonStatement, 3, variable);
246 m_db->Bind(m_insertSingletonStatement, 4, val);
247 m_db->SpinStep(m_insertSingletonStatement);
252 std::string variable,
257 m_db->SpinReset(m_insertSingletonStatement);
258 m_db->Bind(m_insertSingletonStatement, 2, key);
259 m_db->Bind(m_insertSingletonStatement, 3, variable);
260 m_db->Bind(m_insertSingletonStatement, 4, val.
GetTimeStep());
261 m_db->SpinStep(m_insertSingletonStatement);
std::string GetExperimentLabel() const
Return the experiment 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.
std::string GetDescription() const
Return the description label.
MetadataList::iterator MetadataBegin()
Returns an iterator to the beginning of the metadata list.
MetadataList::iterator MetadataEnd()
Returns an iterator to the past-the-end of the metadata list.
std::string GetStrategyLabel() const
Return the strategy label.
std::string GetRunLabel() const
Return the runID label.
std::string GetInputLabel() const
Return the input label.
Abstract Data Output Interface class s.
std::string m_filePrefix
File prefix for the DataOutputInterface.
Smart pointer class similar to boost::intrusive_ptr.
A C++ interface towards an SQLITE database.
Class to generate OMNeT output.
void OutputStatistic(std::string key, std::string variable, const StatisticalSummary *statSum) override
Generates data statistics.
~SqliteOutputCallback() override
Destructor.
sqlite3_stmt * m_insertSingletonStatement
Pointer to a Sqlite3 singleton statement.
SqliteOutputCallback(const Ptr< SQLiteOutput > &db, std::string run)
Constructor.
Ptr< SQLiteOutput > m_db
Db.
void OutputSingleton(std::string key, std::string variable, int val) override
Generates a single data output.
std::string m_runLabel
Run label.
Outputs data in a format compatible with SQLite.
void Output(DataCollector &dc) override
Outputs information from the provided DataCollector.
static TypeId GetTypeId()
Register this type.
Ptr< SQLiteOutput > m_sqliteOut
Database.
~SqliteDataOutput() override
Abstract class for calculating statistical data.
virtual double getMax() const =0
Returns the maximum of the values.
virtual double getStddev() const =0
Returns the standard deviation of the (weighted) observations.
virtual long getCount() const =0
Returns the number of observations.
virtual double getMin() const =0
Returns the minimum of the values.
virtual double getSum() const =0
virtual double getSqrSum() const =0
Simulation virtual time values and global simulation resolution.
int64_t GetTimeStep() const
Get the raw time value, in the current resolution unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#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.
bool isNaN(double x)
true if x is NaN