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
25
29
32 context()->RegisterTrader(dynamic_cast<Trader*>(this));
34}
35
36std::string Facility::str() {
37 std::stringstream ss("");
38 ss << Agent::str() << " with: " << " lifetime: " << lifetime()
39 << " build date: " << enter_time();
40 return ss.str();
41}
42
45 throw Error("Cannot decommission " + prototype());
46 }
47
48 context()->UnregisterTrader(dynamic_cast<Trader*>(this));
51}
52
54 return true;
55}
56
57} // namespace cyclus
virtual void InitFrom(QueryableBackend *b)
Intializes an agent's internal state from the database.
Definition agent.cc:44
const std::string prototype() const
Returns the agent's prototype.
Definition agent.h:342
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:144
Agent(Context *ctx)
Creates a new agent that is managed by the given context.
Definition agent.cc:58
Context * context() const
Returns this agent's simulation context.
Definition agent.h:364
const int lifetime() const
Returns the number of time steps this agent operates between building and decommissioning (-1 if the ...
Definition agent.h:392
virtual void Decommission()
Decommissions the agent, removing it from the simulation.
Definition agent.cc:173
std::string kind_
describes the agent subclass (e.g.
Definition agent.h:443
virtual void EnterNotify()
Called to give the agent an opportunity to register for services (e.g.
Definition agent.cc:157
Agent * parent() const
Returns parent of this agent. Returns NULL if the agent has no parent.
Definition agent.h:370
virtual std::string str()
Description of this agent.
Definition agent.cc:95
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:378
A simulation context provides access to necessary simulation-global functions and state.
Definition context.h:146
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:178
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
virtual void Decommission()
decommissions the facility, default behavior is for the facility to delete itself
Definition facility.cc:43
virtual void EnterNotify()
Called to give the agent an opportunity to register for services.
Definition facility.cc:30
virtual ~Facility()
Definition facility.cc:20
virtual std::string str()
every agent should be able to print a verbose description
Definition facility.cc:36
virtual void Build(Agent *parent)
builds the facility in the simulation
Definition facility.cc:26
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:53
Trader(Agent *manager)
Definition trader.h:26
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