CYCLUS
Loading...
Searching...
No Matches
db_init.cc
Go to the documentation of this file.
1#include "db_init.h"
2
3#include "context.h"
4#include "agent.h"
5
6namespace cyclus {
7
8DbInit::DbInit(Agent* m) : m_(m), full_prefix_(true) {}
9
10DbInit::DbInit(Agent* m, bool dummy) : m_(m), full_prefix_(false) {}
11
12Datum* DbInit::NewDatum(std::string title) {
13 std::string prefix = "AgentState";
14 if (full_prefix_) {
15 prefix += AgentSpec(m_->spec()).Sanitize();
16 }
17 Datum* d = m_->context()->NewDatum(prefix + title);
18 d->AddVal("AgentId", m_->id());
19 d->AddVal("SimTime", m_->context()->time());
20 return d;
21}
22
23} // namespace cyclus
std::string Sanitize()
The abstract base class used by all types of agents that live and interact in a simulation.
Definition agent.h:49
std::string spec()
The string representation of the agent spec that uniquely identifies the concrete agent class/module.
Definition agent.h:356
Context * context() const
Returns this agent's simulation context.
Definition agent.h:367
virtual const int id() const
The agent instance's unique ID within a simulation.
Definition agent.h:352
Datum * NewDatum(std::string title)
See Recorder::NewDatum documentation.
Definition context.cc:351
virtual int time()
Returns the current simulation timestep.
Definition context.cc:313
Used to specify and send a collection of key-value pairs to the Recorder for recording.
Definition datum.h:15
Datum * AddVal(const char *field, boost::spirit::hold_any val, std::vector< int > *shape=NULL)
Add an arbitrary field-value pair to the datum.
Definition datum.cc:22
Datum * NewDatum(std::string title)
Returns a new datum to be used exactly as the Context::NewDatum method.
Definition db_init.cc:12
DbInit(Agent *m)
Definition db_init.cc:8
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition agent.cc:14
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters