CYCAMORE
Loading...
Searching...
No Matches
build/cycamore/manager_inst.cc
Go to the documentation of this file.
1#line 1 "/cycamore/src/manager_inst.cc"
2// Implements the ManagerInst class
3#include "manager_inst.h"
4
5namespace cycamore {
6
7// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
8ManagerInst::ManagerInst(cyclus::Context* ctx)
9 : cyclus::Institution(ctx) {}
10
11// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
13
15 Register_(a);
16}
17
19 Unregister_(a);
20}
21
23 cyclus::Institution::EnterNotify();
24 std::set<cyclus::Agent*>::iterator sit;
25 for (sit = cyclus::Agent::children().begin();
26 sit != cyclus::Agent::children().end();
27 ++sit) {
28 Agent* a = *sit;
29 Register_(a);
30 }
31
32 using cyclus::toolkit::CommodityProducer;
33 std::vector<std::string>::iterator vit;
34 for (vit = prototypes.begin(); vit != prototypes.end(); ++vit) {
35 Agent* a = context()->CreateAgent<Agent>(*vit);
36 CommodityProducer* cp_cast = dynamic_cast<CommodityProducer*>(a);
37 if (cp_cast != NULL) {
38 LOG(cyclus::LEV_INFO3, "mani") << "Registering prototype "
39 << a->prototype() << a->id()
40 << " with the Builder interface.";
41 Builder::Register(cp_cast);
42 }
43 }
44
45 InitializePosition();
46}
47
48void ManagerInst::Register_(Agent* a) {
49 using cyclus::toolkit::CommodityProducer;
50 using cyclus::toolkit::CommodityProducerManager;
51
52 CommodityProducer* cp_cast = dynamic_cast<CommodityProducer*>(a);
53 if (cp_cast != NULL) {
54 LOG(cyclus::LEV_INFO3, "mani") << "Registering agent "
55 << a->prototype() << a->id()
56 << " as a commodity producer.";
57 CommodityProducerManager::Register(cp_cast);
58 }
59}
60
61void ManagerInst::Unregister_(Agent* a) {
62 using cyclus::toolkit::CommodityProducer;
63 using cyclus::toolkit::CommodityProducerManager;
64
65 CommodityProducer* cp_cast = dynamic_cast<CommodityProducer*>(a);
66 if (cp_cast != NULL)
67 CommodityProducerManager::Unregister(cp_cast);
68}
69
70// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
72 cyclus::toolkit::CommodityProducer* producer) {
73 using std::set;
74 set<cyclus::toolkit::Commodity,
75 cyclus::toolkit::CommodityCompare> commodities =
76 producer->ProducedCommodities();
77 set<cyclus::toolkit::Commodity, cyclus::toolkit::CommodityCompare>::
78 iterator it;
79
80 LOG(cyclus::LEV_DEBUG3, "maninst") << " Clone produces " << commodities.size()
81 << " commodities.";
82 for (it = commodities.begin(); it != commodities.end(); it++) {
83 LOG(cyclus::LEV_DEBUG3, "maninst") << " Commodity produced: " << it->name();
84 LOG(cyclus::LEV_DEBUG3, "maninst") << " capacity: " <<
85 producer->Capacity(*it);
86 LOG(cyclus::LEV_DEBUG3, "maninst") << " cost: " <<
87 producer->Cost(*it);
88 }
89}
90
91// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
92extern "C" cyclus::Agent* ConstructManagerInst(cyclus::Context* ctx) {
93 return new ManagerInst(ctx);
94}
95
96} // namespace cycamore
void Register_(cyclus::Agent *agent)
register a child
virtual void EnterNotify()
enter the simulation and register any children present
virtual ~ManagerInst()
Default destructor.
virtual void DecomNotify(Agent *m)
unregister a child
void WriteProducerInformation(cyclus::toolkit::CommodityProducer *producer)
write information about a commodity producer to a stream
virtual void BuildNotify(Agent *m)
register a new child
void Unregister_(cyclus::Agent *agent)
unregister a child
std::vector< std::string > prototypes
ManagerInst(cyclus::Context *ctx)
Default constructor.
cyclus::Agent * ConstructManagerInst(cyclus::Context *ctx)