CYCAMORE
src/deploy_inst.cc
Go to the documentation of this file.
1 // Implements the DeployInst class
2 #include "deploy_inst.h"
3 
4 namespace cycamore {
5 
6 DeployInst::DeployInst(cyclus::Context* ctx) : cyclus::Institution(ctx) {}
7 
9 
10 void DeployInst::Build(cyclus::Agent* parent) {
11  cyclus::Institution::Build(parent);
12  BuildSched::iterator it;
13  std::set<std::string> protos;
14  for (int i = 0; i < prototypes.size(); i++) {
15  std::string proto = prototypes[i];
16 
17  std::stringstream ss;
18  ss << proto;
19 
20  if (lifetimes.size() == prototypes.size()) {
21  cyclus::Agent* a = context()->CreateAgent<Agent>(proto);
22  if (a->lifetime() != lifetimes[i]) {
23  a->lifetime(lifetimes[i]);
24 
25  if (lifetimes[i] == -1) {
26  ss << "_life_forever";
27  } else {
28  ss << "_life_" << lifetimes[i];
29  }
30  proto = ss.str();
31  if (protos.count(proto) == 0) {
32  protos.insert(proto);
33  context()->AddPrototype(proto, a);
34  }
35  }
36  }
37 
38  int t = build_times[i];
39  for (int j = 0; j < n_build[i]; j++) {
40  context()->SchedBuild(this, proto, t);
41  }
42  }
43 }
44 
46  cyclus::Institution::EnterNotify();
47  int n = prototypes.size();
48  if (build_times.size() != n) {
49  std::stringstream ss;
50  ss << "prototype '" << prototype() << "' has " << build_times.size()
51  << " build_times vals, expected " << n;
52  throw cyclus::ValueError(ss.str());
53  } else if (n_build.size() != n) {
54  std::stringstream ss;
55  ss << "prototype '" << prototype() << "' has " << n_build.size()
56  << " n_build vals, expected " << n;
57  throw cyclus::ValueError(ss.str());
58  } else if (lifetimes.size() > 0 && lifetimes.size() != n) {
59  std::stringstream ss;
60  ss << "prototype '" << prototype() << "' has " << lifetimes.size()
61  << " lifetimes vals, expected " << n;
62  throw cyclus::ValueError(ss.str());
63  }
64 }
65 
66 extern "C" cyclus::Agent* ConstructDeployInst(cyclus::Context* ctx) {
67  return new DeployInst(ctx);
68 }
69 
70 } // namespace cycamore
virtual void Build(cyclus::Agent *parent)
cyclus::Agent * ConstructDeployInst(cyclus::Context *ctx)
std::vector< std::string > prototypes
cycamore::GrowthRegion string