CYCLUS
facility.cc
Go to the documentation of this file.
1 // Implements the Facility class
2 #include "facility.h"
3 
4 #include <limits>
5 #include <sstream>
6 #include <stdlib.h>
7 
8 #include "error.h"
9 #include "infile_tree.h"
10 #include "institution.h"
11 #include "logger.h"
12 #include "timer.h"
13 
14 namespace cyclus {
15 
16 Facility::Facility(Context* ctx) : Trader(this), Agent(ctx) {
17  kind_ = "Facility";
18 }
19 
21 
22 
24  Agent::InitFrom(m);
25 }
26 
28  Agent::Build(parent);
29 }
30 
33  context()->RegisterTrader(this);
35 }
36 
37 std::string Facility::str() {
38  std::stringstream ss("");
39  ss << Agent::str() << " with: "
40  << " lifetime: " << lifetime()
41  << " build date: " << enter_time();
42  return ss.str();
43 }
44 
47  throw Error("Cannot decommission " + prototype());
48  }
49 
50  context()->UnregisterTrader(this);
53 }
54 
56  return true;
57 }
58 
59 } // namespace cyclus
virtual void Decommission()
Decommissions the agent, removing it from the simulation.
Definition: agent.cc:168
void RegisterTrader(Trader *e)
Registers an agent as a participant in resource exchanges.
Definition: context.h:159
virtual std::string str()
every agent should be able to print a verbose description
Definition: facility.cc:37
A generic mechanism to manually manage exceptions.
Definition: error.h:12
const int lifetime() const
Returns the number of time steps this agent operates between building and decommissioning (-1 if the ...
Definition: agent.h:393
virtual std::string str()
Description of this agent.
Definition: agent.cc:96
virtual void Decommission()
decommissions the facility, default behavior is for the facility to delete itself ...
Definition: facility.cc:45
virtual ~Facility()
Definition: facility.cc:20
A simple API for agents that wish to exchange resources in the simulation.
Definition: trader.h:24
void UnregisterTimeListener(TimeListener *tl)
Removes an agent from receiving tick/tock notifications.
Definition: context.cc:233
virtual bool CheckDecommissionCondition()
facilities over write this method if a condition must be met before their destructors can be called ...
Definition: facility.cc:55
const std::string prototype() const
Returns the agent&#39;s prototype.
Definition: agent.h:347
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:139
virtual void EnterNotify()
Called to give the agent an opportunity to register for services (e.g.
Definition: facility.cc:31
The Facility class is the abstract class/interface used by all facility agents.
Definition: facility.h:68
void UnregisterTrader(Trader *e)
Unregisters an agent as a participant in resource exchanges.
Definition: context.h:164
virtual void EnterNotify()
Called to give the agent an opportunity to register for services (e.g.
Definition: agent.cc:152
std::string kind_
describes the agent subclass (e.g.
Definition: agent.h:445
void RegisterTimeListener(TimeListener *tl)
Registers an agent to receive tick/tock notifications every timestep.
Definition: context.cc:229
Facility(Context *ctx)
Definition: facility.cc:16
Code providing rudimentary logging capability for the Cyclus core.
A simulation context provides access to necessary simulation-global functions and state...
Definition: context.h:128
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
Agent * parent() const
Returns parent of this agent. Returns NULL if the agent has no parent.
Definition: agent.h:375
virtual void InitFrom(QueryableBackend *b)
Intializes an agent&#39;s internal state from the database.
Definition: facility.h:78
virtual void InitFrom(QueryableBackend *b)
Intializes an agent&#39;s internal state from the database.
Definition: agent.cc:45
Context * context() const
Returns this agent&#39;s simulation context.
Definition: agent.h:369
const int enter_time() const
Returns the time step at which this agent&#39;s Build function was called (-1 if the agent has never been...
Definition: agent.h:383
virtual void Build(Agent *parent)
builds the facility in the simulation
Definition: facility.cc:27