16#include "ns3/nstime.h"
44 .SetGroupName(
"Stats")
56 std::string run =
dc.GetRunLabel();
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 (?, ?, ?, ?, ?)");
89 std::string description =
dc.GetDescription();
98 res =
m_sqliteOut->WaitExec(
"CREATE TABLE IF NOT EXISTS "
99 "Metadata ( run text, key text, value)");
103 "INSERT INTO Metadata "
108 for (
auto i =
dc.MetadataBegin();
i !=
dc.MetadataEnd();
i++)
110 const auto&
blob = (*i);
122 for (
auto i =
dc.DataCalculatorBegin();
i !=
dc.DataCalculatorEnd();
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 (?, ?, ?, ?)");
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());
173 if (!std::isnan(
statSum->getSqrSum()))
175 OutputSingleton(key, variable +
"-sqrsum",
statSum->getSqrSum());
177 if (!std::isnan(
statSum->getStddev()))
179 OutputSingleton(key, variable +
"-stddev",
statSum->getStddev());
185 std::string variable,
191 m_db->Bind(m_insertSingletonStatement, 2, key);
192 m_db->Bind(m_insertSingletonStatement, 3, variable);
193 m_db->Bind(m_insertSingletonStatement, 4,
val);
199 std::string variable,
205 m_db->Bind(m_insertSingletonStatement, 2, key);
206 m_db->Bind(m_insertSingletonStatement, 3, variable);
207 m_db->Bind(m_insertSingletonStatement, 4,
val);
213 std::string variable,
219 m_db->Bind(m_insertSingletonStatement, 2, key);
220 m_db->Bind(m_insertSingletonStatement, 3, variable);
221 m_db->Bind(m_insertSingletonStatement, 4,
val);
227 std::string variable,
233 m_db->Bind(m_insertSingletonStatement, 2, key);
234 m_db->Bind(m_insertSingletonStatement, 3, variable);
235 m_db->Bind(m_insertSingletonStatement, 4,
val);
241 std::string variable,
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());
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.
static int SpinStep(sqlite3_stmt *stmt)
Execute a step operation on a statement until the result is ok or an error.
static int SpinReset(sqlite3_stmt *stmt)
Reset a statement until the result is ok or an error.
static int SpinFinalize(sqlite3_stmt *stmt)
Finalize a statement until the result is ok or an error.
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.
Simulation virtual time values and global simulation resolution.
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 ",...
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.