CYCLUS
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 
6 namespace cyclus {
7 
8 DbInit::DbInit(Agent* m) : m_(m), full_prefix_(true) {}
9 
10 DbInit::DbInit(Agent* m, bool dummy) : m_(m), full_prefix_(false) {}
11 
12 Datum* 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
Datum * NewDatum(std::string title)
Returns a new datum to be used exactly as the Context::NewDatum method.
Definition: db_init.cc:12
std::string spec()
The string representation of the agent spec that uniquely identifies the concrete agent class/module...
Definition: agent.h:358
DbInit(Agent *m)
Definition: db_init.cc:8
virtual int time()
Returns the current simulation timestep.
Definition: context.cc:225
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:12
The abstract base class used by all types of agents that live and interact in a simulation.
Definition: agent.h:51
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
Definition: agent.cc:14
Context * context() const
Returns this agent&#39;s simulation context.
Definition: agent.h:369
virtual const int id() const
The agent instance&#39;s unique ID within a simulation.
Definition: agent.h:354
Datum * NewDatum(std::string title)
See Recorder::NewDatum documentation.
Definition: context.cc:237