CYCAMORE
Loading...
Searching...
No Matches
build/cycamore/manager_inst.h
Go to the documentation of this file.
1
2#line 1 "/cycamore/src/manager_inst.h"
3#ifndef CYCAMORE_SRC_MANAGER_INST_H_
4#define CYCAMORE_SRC_MANAGER_INST_H_
5
6#include "cyclus.h"
7#include "cycamore_version.h"
8
9namespace cycamore {
10
16 : public cyclus::Institution,
17 public cyclus::toolkit::CommodityProducerManager,
18 public cyclus::toolkit::Builder,
19 public cyclus::toolkit::Position {
20 public:
22 ManagerInst(cyclus::Context* ctx);
23
25 virtual ~ManagerInst();
26
27 virtual std::string version() { return CYCAMORE_VERSION; }
29 cyclus::Institution::InitFrom(m);
30 int rawcycpp_shape_prototypes[2] = {-1, -1};
31 cycpp_shape_prototypes = std::vector<int>(rawcycpp_shape_prototypes, rawcycpp_shape_prototypes + 2);
32 int rawcycpp_shape_latitude[1] = {-1};
33 cycpp_shape_latitude = std::vector<int>(rawcycpp_shape_latitude, rawcycpp_shape_latitude + 1);
34 int rawcycpp_shape_longitude[1] = {-1};
35 cycpp_shape_longitude = std::vector<int>(rawcycpp_shape_longitude, rawcycpp_shape_longitude + 1);
36 prototypes = m->prototypes;
37 latitude = m->latitude;
38 longitude = m->longitude;
39 };
40#line 26 "/cycamore/src/manager_inst.h"
41
42 virtual void InitFrom(cyclus::QueryableBackend* b) {
43 cyclus::Institution::InitFrom(b);
44 int rawcycpp_shape_prototypes[2] = {-1, -1};
45 cycpp_shape_prototypes = std::vector<int>(rawcycpp_shape_prototypes, rawcycpp_shape_prototypes + 2);
46 int rawcycpp_shape_latitude[1] = {-1};
47 cycpp_shape_latitude = std::vector<int>(rawcycpp_shape_latitude, rawcycpp_shape_latitude + 1);
48 int rawcycpp_shape_longitude[1] = {-1};
49 cycpp_shape_longitude = std::vector<int>(rawcycpp_shape_longitude, rawcycpp_shape_longitude + 1);
50 cyclus::QueryResult qr = b->Query("Info", NULL);
51 prototypes = qr.GetVal<std::vector< std::string > >("prototypes");
52 latitude = qr.GetVal<double>("latitude");
53 longitude = qr.GetVal<double>("longitude");
54 };
55#line 28 "/cycamore/src/manager_inst.h"
56
57 virtual void InfileToDb(cyclus::InfileTree* tree, cyclus::DbInit di) {
58 cyclus::Institution::InfileToDb(tree, di);
59 int rawcycpp_shape_prototypes[2] = {-1, -1};
60 cycpp_shape_prototypes = std::vector<int>(rawcycpp_shape_prototypes, rawcycpp_shape_prototypes + 2);
61 int rawcycpp_shape_latitude[1] = {-1};
62 cycpp_shape_latitude = std::vector<int>(rawcycpp_shape_latitude, rawcycpp_shape_latitude + 1);
63 int rawcycpp_shape_longitude[1] = {-1};
64 cycpp_shape_longitude = std::vector<int>(rawcycpp_shape_longitude, rawcycpp_shape_longitude + 1);
65 cyclus::InfileTree* sub = tree->SubTree("config/*");
66 int i;
67 int n;
68 {
69 cyclus::InfileTree* bub = sub->SubTree("prototypes", 0);
70 cyclus::InfileTree* sub = bub;
71 int n1 = sub->NMatches("val");
72 std::vector< std::string > prototypes_val;
73 prototypes_val.resize(n1);
74 for (int i1 = 0; i1 < n1; ++i1) {
75 std::string elem;
76 {
77 std::string elem_in = cyclus::Query<std::string>(sub, "val", i1);
78 elem = elem_in;
79 }
80 prototypes_val[i1] = elem;
81 }
82 prototypes = prototypes_val;
83 }
84 if (sub->NMatches("latitude") > 0) {
85 {
86 double latitude_val = cyclus::Query<double>(sub, "latitude");
87 latitude = latitude_val;
88 }
89 } else {
90 double latitude_tmp = 0.0;
91 latitude = latitude_tmp;
92 }
93 if (sub->NMatches("longitude") > 0) {
94 {
95 double longitude_val = cyclus::Query<double>(sub, "longitude");
96 longitude = longitude_val;
97 }
98 } else {
99 double longitude_tmp = 0.0;
100 longitude = longitude_tmp;
101 }
102 di.NewDatum("Info")
103 ->AddVal("prototypes", prototypes, &cycpp_shape_prototypes)
104 ->AddVal("latitude", latitude, &cycpp_shape_latitude)
105 ->AddVal("longitude", longitude, &cycpp_shape_longitude)
106 ->Record();
107 };
108
109 virtual cyclus::Agent* Clone() {
111 m->InitFrom(this);
112 return m;
113 };
114
115 virtual std::string schema() {
116 return ""
117 "<interleave>\n"
118 " <element name=\"prototypes\">\n"
119 " <oneOrMore>\n"
120 " <element name=\"val\">\n"
121 " <data type=\"string\"/>\n"
122 " </element>\n"
123 " </oneOrMore>\n"
124 " </element>\n"
125 " <optional>\n"
126 " <element name=\"latitude\">\n"
127 " <data type=\"double\"/>\n"
128 " </element>\n"
129 " </optional>\n"
130 " <optional>\n"
131 " <element name=\"longitude\">\n"
132 " <data type=\"double\"/>\n"
133 " </element>\n"
134 " </optional>\n"
135 "</interleave>\n";
136 };
137
138 virtual Json::Value annotations() {
139 Json::Value root;
140 Json::Reader reader;
141 bool parsed_ok = reader.parse(
142 "{\"name\":\"cycamore::ManagerInst\",\"entity\":\"institut"
143 "ion\",\"parents\":[\"cyclus::Institution\",\"cyclus::too"
144 "lkit::Builder\",\"cyclus::toolkit::CommodityProducer"
145 "Manager\",\"cyclus::toolkit::Position\"],\"all_parents"
146 "\":[\"cyclus::Agent\",\"cyclus::Ider\",\"cyclus::Institu"
147 "tion\",\"cyclus::StateWrangler\",\"cyclus::TimeListene"
148 "r\",\"cyclus::toolkit::AgentManaged\",\"cyclus::toolki"
149 "t::Builder\",\"cyclus::toolkit::CommodityProducerMan"
150 "ager\",\"cyclus::toolkit::Position\"],\"vars\":{\"protot"
151 "ypes\":{\"tooltip\":[\"producer facility "
152 "prototypes\",\"\"],\"uilabel\":[\"Producer Prototype Lis"
153 "t\",\"\"],\"uitype\":[\"oneormore\",\"prototype\"],\"doc\":\"A"
154 " set of facility prototypes that this institution "
155 "can build. All prototypes in this list must be "
156 "based on an archetype that implements the "
157 "cyclus::toolkit::CommodityProducer interface\",\"typ"
158 "e\":[\"std::vector\",\"std::string\"],\"index\":0,\"shape\""
159 ":[-1,-"
160 "1],\"alias\":[\"prototypes\",\"val\"]},\"latitude\":{\"defa"
161 "ult\":0.0,\"uilabel\":\"Geographical latitude in "
162 "degrees as a double\",\"doc\":\"Latitude of the "
163 "agent's geographical position. The value should be"
164 " expressed in degrees as a double.\",\"type\":\"double"
165 "\",\"index\":1,\"shape\":[-"
166 "1],\"alias\":\"latitude\",\"tooltip\":\"latitude\"},\"longi"
167 "tude\":{\"default\":0.0,\"uilabel\":\"Geographical "
168 "longitude in degrees as a double\",\"doc\":\"Longitude"
169 " of the agent's geographical position. The value "
170 "should be expressed in degrees as a double.\",\"type"
171 "\":\"double\",\"index\":2,\"shape\":[-"
172 "1],\"alias\":\"longitude\",\"tooltip\":\"longitude\"}},\"do"
173 "c\":\"An institution that owns and operates a "
174 "manually entered list of facilities in the input "
175 "file\"}", root);
176 if (!parsed_ok) {
177 throw cyclus::ValueError("failed to parse annotations for cycamore::ManagerInst.");
178 }
179 return root;
180 };
181
182 virtual void InitInv(cyclus::Inventories& inv) {
183 };
184
185 virtual cyclus::Inventories SnapshotInv() {
186 cyclus::Inventories invs;
187 return invs;
188 };
189
190 virtual void Snapshot(cyclus::DbInit di) {
191 di.NewDatum("Info")
192 ->AddVal("prototypes", prototypes, &cycpp_shape_prototypes)
193 ->AddVal("latitude", latitude, &cycpp_shape_latitude)
194 ->AddVal("longitude", longitude, &cycpp_shape_longitude)
195 ->Record();
196 };
197
198 #pragma cyclus note {"doc": "An institution that owns and operates a " "manually entered list of facilities in " "the input file"}
199#line 32 "/cycamore/src/manager_inst.h"
200
202 virtual void EnterNotify();
203
205 virtual void BuildNotify(Agent* m);
206
208 virtual void DecomNotify(Agent* m);
209
212 void WriteProducerInformation(cyclus::toolkit::CommodityProducer*
213 producer);
214
215 private:
217 void Register_(cyclus::Agent* agent);
218
220 void Unregister_(cyclus::Agent* agent);
221
222 #pragma cyclus var { "tooltip": "producer facility prototypes", "uilabel": "Producer Prototype List", "uitype": ["oneormore", "prototype"], "doc": "A set of facility prototypes that this institution can build. " "All prototypes in this list must be based on an archetype that " "implements the cyclus::toolkit::CommodityProducer interface", }
223#line 62 "/cycamore/src/manager_inst.h"
224 std::vector<std::string> prototypes;
225 std::vector<int> cycpp_shape_prototypes;
226#line 63 "/cycamore/src/manager_inst.h"
227
228
229 #pragma cyclus var { "default": 0.0, "uilabel": "Geographical latitude in degrees as a double", "doc": "Latitude of the agent's geographical position. The value should " "be expressed in degrees as a double." }
230#line 70 "/cycamore/src/manager_inst.h"
231 double latitude;
232 std::vector<int> cycpp_shape_latitude;
233#line 71 "/cycamore/src/manager_inst.h"
234
235
236 #pragma cyclus var { "default": 0.0, "uilabel": "Geographical longitude in degrees as a double", "doc": "Longitude of the agent's geographical position. The value should " "be expressed in degrees as a double." }
237#line 78 "/cycamore/src/manager_inst.h"
238 double longitude;
239 std::vector<int> cycpp_shape_longitude;
240
241#line 79 "/cycamore/src/manager_inst.h"
242
243 cyclus::toolkit::Position coordinates;
244
246 void RecordPosition();
247};
248
249} // namespace cycamore
250
251#endif // CYCAMORE_SRC_MANAGER_INST_H_
#define CYCAMORE_VERSION
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 Snapshot(cyclus::DbInit di)
virtual void InfileToDb(cyclus::InfileTree *tree, cyclus::DbInit di)
std::vector< int > cycpp_shape_prototypes
virtual void BuildNotify(Agent *m)
register a new child
virtual cyclus::Agent * Clone()
cyclus::toolkit::Position coordinates
void Unregister_(cyclus::Agent *agent)
unregister a child
virtual void InitInv(cyclus::Inventories &inv)
void RecordPosition()
Records an agent's latitude and longitude to the output db.
std::vector< std::string > prototypes
virtual cyclus::Inventories SnapshotInv()
virtual void InitFrom(cyclus::QueryableBackend *b)
virtual void InitFrom(cycamore::ManagerInst *m)
ManagerInst(cyclus::Context *ctx)
Default constructor.