16#include "ns3/nstime.h"
44 .SetGroupName(
"Stats")
61 res =
m_sqliteOut->SpinExec(
"CREATE TABLE IF NOT EXISTS Experiments (run, experiment, "
62 "strategy, input, description text)");
67 "INSERT INTO Experiments "
68 "(run, experiment, strategy, input, description)"
69 "values (?, ?, ?, ?, ?)");
98 res =
m_sqliteOut->WaitExec(
"CREATE TABLE IF NOT EXISTS "
99 "Metadata ( run text, key text, value)");
103 "INSERT INTO Metadata "
110 std::pair<std::string, std::string> blob = (*i);
124 (*i)->Output(callback);
138 m_db->WaitExec(
"CREATE TABLE IF NOT EXISTS Singletons "
139 "( run text, name text, variable text, value )");
142 "INSERT INTO Singletons "
143 "(run, name, variable, value)"
144 "values (?, ?, ?, ?)");
150 m_db->SpinFinalize(m_insertSingletonStatement);
155 std::string variable,
160 OutputSingleton(key, variable +
"-count",
static_cast<double>(statSum->
getCount()));
161 if (!std::isnan(statSum->
getSum()))
163 OutputSingleton(key, variable +
"-total", statSum->
getSum());
165 if (!std::isnan(statSum->
getMax()))
167 OutputSingleton(key, variable +
"-max", statSum->
getMax());
169 if (!std::isnan(statSum->
getMin()))
171 OutputSingleton(key, variable +
"-min", statSum->
getMin());
175 OutputSingleton(key, variable +
"-sqrsum", statSum->
getSqrSum());
179 OutputSingleton(key, variable +
"-stddev", statSum->
getStddev());
185 std::string variable,
190 m_db->SpinReset(m_insertSingletonStatement);
191 m_db->Bind(m_insertSingletonStatement, 2, key);
192 m_db->Bind(m_insertSingletonStatement, 3, variable);
193 m_db->Bind(m_insertSingletonStatement, 4, val);
194 m_db->SpinStep(m_insertSingletonStatement);
199 std::string variable,
204 m_db->SpinReset(m_insertSingletonStatement);
205 m_db->Bind(m_insertSingletonStatement, 2, key);
206 m_db->Bind(m_insertSingletonStatement, 3, variable);
207 m_db->Bind(m_insertSingletonStatement, 4, val);
208 m_db->SpinStep(m_insertSingletonStatement);
213 std::string variable,
218 m_db->SpinReset(m_insertSingletonStatement);
219 m_db->Bind(m_insertSingletonStatement, 2, key);
220 m_db->Bind(m_insertSingletonStatement, 3, variable);
221 m_db->Bind(m_insertSingletonStatement, 4, val);
222 m_db->SpinStep(m_insertSingletonStatement);
227 std::string variable,
232 m_db->SpinReset(m_insertSingletonStatement);
233 m_db->Bind(m_insertSingletonStatement, 2, key);
234 m_db->Bind(m_insertSingletonStatement, 3, variable);
235 m_db->Bind(m_insertSingletonStatement, 4, val);
236 m_db->SpinStep(m_insertSingletonStatement);
241 std::string variable,
246 m_db->SpinReset(m_insertSingletonStatement);
247 m_db->Bind(m_insertSingletonStatement, 2, key);
248 m_db->Bind(m_insertSingletonStatement, 3, variable);
249 m_db->Bind(m_insertSingletonStatement, 4, val.
GetTimeStep());
250 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.