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);
136 (*i)->Output(callback);
150 m_db->WaitExec(
"CREATE TABLE IF NOT EXISTS Singletons "
151 "( run text, name text, variable text, value )");
154 "INSERT INTO Singletons "
155 "(run, name, variable, value)"
156 "values (?, ?, ?, ?)");
162 m_db->SpinFinalize(m_insertSingletonStatement);
167 std::string variable,
172 OutputSingleton(key, variable +
"-count",
static_cast<double>(statSum->
getCount()));
175 OutputSingleton(key, variable +
"-total", statSum->
getSum());
179 OutputSingleton(key, variable +
"-max", statSum->
getMax());
183 OutputSingleton(key, variable +
"-min", statSum->
getMin());
187 OutputSingleton(key, variable +
"-sqrsum", statSum->
getSqrSum());
191 OutputSingleton(key, variable +
"-stddev", statSum->
getStddev());
197 std::string variable,
202 m_db->SpinReset(m_insertSingletonStatement);
203 m_db->Bind(m_insertSingletonStatement, 2, key);
204 m_db->Bind(m_insertSingletonStatement, 3, variable);
205 m_db->Bind(m_insertSingletonStatement, 4, val);
206 m_db->SpinStep(m_insertSingletonStatement);
211 std::string variable,
216 m_db->SpinReset(m_insertSingletonStatement);
217 m_db->Bind(m_insertSingletonStatement, 2, key);
218 m_db->Bind(m_insertSingletonStatement, 3, variable);
219 m_db->Bind(m_insertSingletonStatement, 4, val);
220 m_db->SpinStep(m_insertSingletonStatement);
225 std::string variable,
230 m_db->SpinReset(m_insertSingletonStatement);
231 m_db->Bind(m_insertSingletonStatement, 2, key);
232 m_db->Bind(m_insertSingletonStatement, 3, variable);
233 m_db->Bind(m_insertSingletonStatement, 4, val);
234 m_db->SpinStep(m_insertSingletonStatement);
239 std::string variable,
244 m_db->SpinReset(m_insertSingletonStatement);
245 m_db->Bind(m_insertSingletonStatement, 2, key);
246 m_db->Bind(m_insertSingletonStatement, 3, variable);
247 m_db->Bind(m_insertSingletonStatement, 4, val);
248 m_db->SpinStep(m_insertSingletonStatement);
253 std::string variable,
258 m_db->SpinReset(m_insertSingletonStatement);
259 m_db->Bind(m_insertSingletonStatement, 2, key);
260 m_db->Bind(m_insertSingletonStatement, 3, variable);
261 m_db->Bind(m_insertSingletonStatement, 4, val.
GetTimeStep());
262 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