CYCLUS
Loading...
Searching...
No Matches
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
14namespace cyclus {
15
17 kind_ = std::string("Facility");
18}
19
21
22
26
27void Facility::Build(Agent* parent) {
29}
30
33 context()->RegisterTrader(dynamic_cast<Trader*>(this));
35}
36
37std::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(dynamic_cast<Trader*>(this));
53}
54
56 return true;
57}
58
59} // namespace cyclus
The abstract base class used by all types of agents that live and interact in a simulation.
Definition agent.h:49
virtual void InitFrom(QueryableBackend *b)
Intializes an agent's internal state from the database.
Definition agent.cc:45
const std::string prototype() const
Returns the agent's prototype.
Definition agent.h:345
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
Context * context() const
Returns this agent's simulation context.
Definition agent.h:367
const int lifetime() const
Returns the number of time steps this agent operates between building and decommissioning (-1 if the ...
Definition agent.h:395
virtual void Decommission()
Decommissions the agent, removing it from the simulation.
Definition agent.cc:182
std::string kind_
describes the agent subclass (e.g.
Definition agent.h:447
virtual void EnterNotify()
Called to give the agent an opportunity to register for services (e.g.
Definition agent.cc:166
Agent * parent() const
Returns parent of this agent. Returns NULL if the agent has no parent.
Definition agent.h:373
virtual std::string str()
Description of this agent.
Definition agent.cc:96
const int enter_time() const
Returns the time step at which this agent's Build function was called (-1 if the agent has never been...
Definition agent.h:381
A simulation context provides access to necessary simulation-global functions and state.
Definition context.h:145
void UnregisterTrader(Trader *e)
Unregisters an agent as a participant in resource exchanges.
Definition context.h:181
void RegisterTrader(Trader *e)
Registers an agent as a participant in resource exchanges.
Definition context.h:176
void RegisterTimeListener(TimeListener *tl)
Registers an agent to receive tick/tock notifications every timestep.
Definition context.cc:343
void UnregisterTimeListener(TimeListener *tl)
Removes an agent from receiving tick/tock notifications.
Definition context.cc:347
A generic mechanism to manually manage exceptions.
Definition error.h:12
The Facility class is the abstract class/interface used by all facility agents.
Definition facility.h:68
virtual void Decommission()
decommissions the facility, default behavior is for the facility to delete itself
Definition facility.cc:45
virtual void EnterNotify()
Called to give the agent an opportunity to register for services.
Definition facility.cc:31
virtual ~Facility()
Definition facility.cc:20
virtual std::string str()
every agent should be able to print a verbose description
Definition facility.cc:37
virtual void Build(Agent *parent)
builds the facility in the simulation
Definition facility.cc:27
virtual void InitFrom(QueryableBackend *b)
Intializes an agent's internal state from the database.
Definition facility.h:78
Facility(Context *ctx)
Definition facility.cc:16
virtual bool CheckDecommissionCondition()
facilities over write this method if a condition must be met before their destructors can be called
Definition facility.cc:55
A simple API for agents that wish to exchange resources in the simulation.
Definition trader.h:24
Code providing rudimentary logging capability for the Cyclus core.
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