19 std::stringstream schema(
"");
23 std::vector<AgentSpec> specs =
ParseSpecs(infile);
25 for (
int i = 0; i < specs.size(); ++i) {
27 subschemas +=
"<element name=\"" + specs[i].alias() +
"\">\n";
28 subschemas += m->
schema() +
"\n";
29 subschemas +=
"</element>\n";
35 size_t pos = master.find(search_str);
36 if (pos != std::string::npos) {
37 master.replace(pos, search_str.size(), subschemas);
51 int num_protos = xqe.
NMatches(
"/*/prototype");
52 for (
int i = 0; i < num_protos; i++) {
62 agent->Agent::InfileToDb(qe,
DbInit(agent,
true));
67 std::vector<Cond> conds;
69 conds.push_back(
Cond(
"AgentId",
"==", agent->
id()));
70 conds.push_back(
Cond(
"SimTime",
"==", static_cast<int>(0)));
75 agent->Agent::InitFrom(&pi);
83 int num_agents = xqe.
NMatches(
"/*/agent");
84 std::map<std::string, std::string> protos;
85 std::map<std::string, std::string> parents;
86 std::set<std::string> agents;
87 std::map<std::string, InfileTree*> invs;
88 for (
int i = 0; i < num_agents; i++) {
100 std::map<std::string, Agent*> built;
101 std::set<std::string>::iterator it = agents.begin();
102 while (agents.size() > 0) {
110 }
else if (built.count(parent) > 0) {
117 if (it == agents.end()) {
boost::shared_ptr< XMLParser > parser_
the parser
std::string BuildFlatMasterSchema(std::string schema_path, std::string infile)
Builds and returns a master cyclus input xml schema defining a flat prototype and instance structure ...
boost::uuids::uuid sim_id()
returns the unique id associated with this cyclus simulation.
std::string schema_path_
filepath to the schema
std::string file_
the input file name
virtual int NMatches(std::string query)
investigates the current status and returns the number of elements matching a query ...
virtual void InfileToDb(InfileTree *qe, DbInit di)
Translates info for the agent from an input file to the database by reading parameters from the passe...
Agent * BuildAgent(std::string proto, Agent *parent)
Creates and builds an agent, notifying its parent.
A class for extracting information from a given XML parser.
virtual const int id() const
The agent instance's unique ID within a simulation.
std::string name(int nuc)
virtual std::string GetElementName(int index=0)
investigates the current status and returns a string representing the name of a given index ...
virtual std::string master_schema()
virtual std::string schema()
Returns an agent's xml rng schema for initializing from input files.
virtual std::string GetString(std::string query, int index=0)
investigates the current status and returns a string representing the content of a query at a given i...
int parent(int nuc, unsigned int rx, std::string z="n")
Wrapper class for QueryableBackends that injects a set of Cond's into every query before being execut...
std::map< std::string, AgentSpec > specs_
void AddPrototype(std::string name, Agent *m)
Adds a prototype to a simulation-wide accessible list, a prototype can not be added more than once...
DbInit provides an interface for agents to record data to the output db that automatically injects th...
void Flush()
Flushes all buffered Datum objects and flushes all registered backends.
Collects and manages output data generation for the cyclus core and agents during a simulation...
Wrapper class for QueryableBackends that injects prefix in front of the title/table for every query b...
InfileTree * SubTree(std::string query, int index=0)
populates a child infile based on a query and index
Code providing rudimentary logging capability for the Cyclus core.
A simulation context provides access to necessary simulation-global functions and state...
The abstract base class used by all types of agents that live and interact in a simulation.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
const double pi
pi = 3.14159265359
std::vector< AgentSpec > ParseSpecs(std::string infile, std::string format)
Returns a list of the full module+agent spec for all agents in the given input file.
virtual void InitFrom(QueryableBackend *b)
Intializes an agent's internal state from the database.
Represents a condition used to filter rows returned by a query.
void LoadStringstreamFromFile(std::stringstream &stream, std::string file, std::string format)
Reads the given file path as XML into the passed stream.
static Agent * Make(Context *ctx, AgentSpec spec)
Returns a newly constructed agent for the given module spec.
void LoadInitialAgents()
Creates all initial agent instances from the input file.
void DelAgent(Agent *m)
Destructs and cleans up m (and it's children recursively).
Controls simulation timestepping and inter-timestep phases.