CYCLUS
institution.cc
Go to the documentation of this file.
1 // Implements the Institution class
2 #include "institution.h"
3 
4 #include <iostream>
5 #include <sstream>
6 #include <string>
7 
8 #include "error.h"
9 #include "facility.h"
10 #include "infile_tree.h"
11 #include "logger.h"
12 #include "timer.h"
13 
14 namespace cyclus {
15 
17  kind_ = "Inst";
18 }
19 
21 }
22 
24  Agent::InitFrom(m);
25 }
26 
28  if (parent() != NULL) {
29  return Agent::str() + " in region" + parent()->prototype();
30  } else {
31  return Agent::str() + " with no region.";
32  }
33 }
34 
36  Agent::Build(parent);
37 }
38 
41 }
42 
46 }
47 
49  std::set<Agent*>::iterator it;
50  for (it = children().begin(); it != children().end(); ++it) {
51  Agent* a = *it;
52  if (a->lifetime() != -1 && context()->time() >= a->exit_time()) {
53  Facility* fac = dynamic_cast<Facility*>(a);
54  if (fac == NULL || fac->CheckDecommissionCondition()) {
55  CLOG(LEV_INFO3) << a->prototype()
56  << " has reached the end of its lifetime";
57  context()->SchedDecom(a);
58  }
59  }
60  }
61 }
62 
63 } // namespace cyclus
virtual void InitFrom(QueryableBackend *b)
Intializes an agent&#39;s internal state from the database.
Definition: institution.h:44
virtual void Decommission()
Decommissions the agent, removing it from the simulation.
Definition: agent.cc:182
const int exit_time() const
Returns the default time step at which this agent will exit the simulation (-1 if the agent has an in...
Definition: agent.h:407
virtual std::string str()
Description of this agent.
Definition: agent.cc:96
Institution(Context *ctx)
Default constructor for Institution Class.
Definition: institution.cc:16
const std::string prototype() const
Returns the agent&#39;s prototype.
Definition: agent.h:347
virtual void EnterNotify()
Called to give the agent an opportunity to register for services (e.g.
Definition: institution.cc:39
virtual void Decommission()
Decommissions the agent, removing it from the simulation.
Definition: institution.cc:43
void UnregisterTimeListener(TimeListener *tl)
Removes an agent from receiving tick/tock notifications.
Definition: context.cc:235
virtual ~Institution()
every agent should be destructable
Definition: institution.cc:20
#define CLOG(level)
Definition: logger.h:39
virtual bool CheckDecommissionCondition()
facilities over write this method if a condition must be met before their destructors can be called ...
Definition: facility.cc:55
virtual void Build(Agent *parent)
Called when the agent enters the smiulation as an active participant and is only ever called once...
Definition: agent.cc:153
virtual void Build(Agent *parent)
perform all tasks required when an inst enters the simulation
Definition: institution.cc:35
void lifetime(int n_timesteps)
Sets the number of time steps this agent operates between building and decommissioning (-1 if the age...
Definition: agent.cc:108
virtual std::string str()
every agent should be able to print a verbose description
Definition: institution.cc:27
virtual int time()
Returns the current simulation timestep.
Definition: context.cc:227
The Facility class is the abstract class/interface used by all facility agents.
Definition: facility.h:68
Context * context() const
Returns this agent&#39;s simulation context.
Definition: agent.h:369
std::string kind_
describes the agent subclass (e.g.
Definition: agent.h:449
virtual void Tock()
Simulation agents do their end-of-timestep activities in the Tock method.
Definition: institution.cc:48
void RegisterTimeListener(TimeListener *tl)
Registers an agent to receive tick/tock notifications every timestep.
Definition: context.cc:231
Agent * parent() const
Returns parent of this agent. Returns NULL if the agent has no parent.
Definition: agent.h:375
Code providing rudimentary logging capability for the Cyclus core.
A simulation context provides access to necessary simulation-global functions and state...
Definition: context.h:130
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
Information helpful for simulation users and developers alike.
Definition: logger.h:55
virtual void InitFrom(QueryableBackend *b)
Intializes an agent&#39;s internal state from the database.
Definition: agent.cc:45
const std::set< Agent * > & children() const
Returns a list of children this agent has.
Definition: agent.h:414
The Institution class is the abstract class/interface used by all institution agents.
Definition: institution.h:29
enable_if< has_const_iterator< T >::value, typename T::const_iterator >::type begin(const T &c)
void SchedDecom(Agent *m, int time=-1)
Schedules the given Agent to be decommissioned at the specified timestep t.
Definition: context.cc:121