7 : cyclus::Institution(ctx) {}
9DeployInst::~DeployInst() {}
11void DeployInst::Build(cyclus::Agent* parent) {
12 cyclus::Institution::Build(parent);
13 BuildSched::iterator it;
14 std::set<std::string> protos;
15 for (
int i = 0; i < prototypes.size(); i++) {
16 std::string proto = prototypes[i];
21 if (lifetimes.size() == prototypes.size()) {
22 cyclus::Agent* a = context()->CreateAgent<Agent>(proto);
23 if (a->lifetime() != lifetimes[i]) {
24 a->lifetime(lifetimes[i]);
26 if (lifetimes[i] == -1) {
27 ss <<
"_life_forever";
29 ss <<
"_life_" << lifetimes[i];
32 if (protos.count(proto) == 0) {
34 context()->AddPrototype(proto, a);
39 int t = build_times[i];
40 for (
int j = 0; j < n_build[i]; j++) {
41 context()->SchedBuild(
this, proto, t);
46void DeployInst::EnterNotify() {
47 cyclus::Institution::EnterNotify();
48 int n = prototypes.size();
49 if (build_times.size() != n) {
51 ss <<
"prototype '" << prototype() <<
"' has " << build_times.size()
52 <<
" build_times vals, expected " << n;
53 throw cyclus::ValueError(ss.str());
54 }
else if (n_build.size() != n) {
56 ss <<
"prototype '" << prototype() <<
"' has " << n_build.size()
57 <<
" n_build vals, expected " << n;
58 throw cyclus::ValueError(ss.str());
59 }
else if (lifetimes.size() > 0 && lifetimes.size() != n) {
61 ss <<
"prototype '" << prototype() <<
"' has " << lifetimes.size()
62 <<
" lifetimes vals, expected " << n;
63 throw cyclus::ValueError(ss.str());
69void DeployInst::BuildNotify(Agent* a) {
73void DeployInst::DecomNotify(Agent* a) {
77void DeployInst::Register_(Agent* a) {
78 using cyclus::toolkit::CommodityProducer;
79 using cyclus::toolkit::CommodityProducerManager;
81 CommodityProducer* cp_cast =
dynamic_cast<CommodityProducer*
>(a);
82 if (cp_cast != NULL) {
83 LOG(cyclus::LEV_INFO3,
"mani") <<
"Registering agent "
84 << a->prototype() << a->id()
85 <<
" as a commodity producer.";
86 CommodityProducerManager::Register(cp_cast);
90void DeployInst::Unregister_(Agent* a) {
91 using cyclus::toolkit::CommodityProducer;
92 using cyclus::toolkit::CommodityProducerManager;
94 CommodityProducer* cp_cast =
dynamic_cast<CommodityProducer*
>(a);
96 CommodityProducerManager::Unregister(cp_cast);
100void DeployInst::WriteProducerInformation(
101 cyclus::toolkit::CommodityProducer* producer) {
103 set<cyclus::toolkit::Commodity,
104 cyclus::toolkit::CommodityCompare> commodities =
105 producer->ProducedCommodities();
106 set<cyclus::toolkit::Commodity, cyclus::toolkit::CommodityCompare>::
109 LOG(cyclus::LEV_DEBUG3,
"maninst") <<
" Clone produces " << commodities.size()
111 for (it = commodities.begin(); it != commodities.end(); it++) {
112 LOG(cyclus::LEV_DEBUG3,
"maninst") <<
" Commodity produced: " << it->name();
113 LOG(cyclus::LEV_DEBUG3,
"maninst") <<
" capacity: " <<
114 producer->Capacity(*it);
115 LOG(cyclus::LEV_DEBUG3,
"maninst") <<
" cost: " <<
121 return new DeployInst(ctx);
DeployInst(cyclus::Context *ctx)
cyclus::Agent * ConstructDeployInst(cyclus::Context *ctx)
void Unregister_(cyclus::Agent *agent)
unregister a child
void Register_(cyclus::Agent *agent)
register a child