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);
37 latitude = m->latitude;
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 " <a:documentation>Latitude of the agent's geographical position. The value should be expressed in degrees as a double.</a:documentation>\n"
128 " <data type=\"double\"/>\n"
129 " </element>\n"
130 " </optional>\n"
131 " <optional>\n"
132 " <element name=\"longitude\">\n"
133 " <a:documentation>Longitude of the agent's geographical position. The value should be expressed in degrees as a double.</a:documentation>\n"
134 " <data type=\"double\"/>\n"
135 " </element>\n"
136 " </optional>\n"
137 "</interleave>\n";
138 };
139
140 virtual Json::Value annotations() {
141 Json::Value root;
142 Json::Reader reader;
143 bool parsed_ok = reader.parse(
144 "{\"name\":\"cycamore::ManagerInst\",\"entity\":\"institut"
145 "ion\",\"parents\":[\"cyclus::Institution\",\"cyclus::too"
146 "lkit::Builder\",\"cyclus::toolkit::CommodityProducer"
147 "Manager\",\"cyclus::toolkit::Position\"],\"all_parents"
148 "\":[\"EconomicEntity\",\"cyclus::Agent\",\"cyclus::Ider\""
149 ",\"cyclus::Institution\",\"cyclus::StateWrangler\",\"cy"
150 "clus::TimeListener\",\"cyclus::toolkit::AgentManaged"
151 "\",\"cyclus::toolkit::Builder\",\"cyclus::toolkit::Com"
152 "modityProducerManager\",\"cyclus::toolkit::Position\""
153 "],\"vars\":{\"prototypes\":{\"tooltip\":[\"producer "
154 "facility prototypes\",\"\"],\"uilabel\":[\"Producer "
155 "Prototype List\",\"\"],\"uitype\":[\"oneormore\",\"prototy"
156 "pe\"],\"doc\":\"A set of facility prototypes that this"
157 " institution can build. All prototypes in this "
158 "list must be based on an archetype that implements"
159 " the cyclus::toolkit::CommodityProducer interface\""
160 ",\"type\":[\"std::vector\",\"std::string\"],\"index\":0,\"s"
161 "hape\":[-1,-"
162 "1],\"alias\":[\"prototypes\",\"val\"]},\"latitude\":{\"defa"
163 "ult\":0.0,\"uilabel\":\"Geographical latitude in "
164 "degrees as a double\",\"doc\":\"Latitude of the "
165 "agent's geographical position. The value should be"
166 " expressed in degrees as a double.\",\"type\":\"double"
167 "\",\"index\":1,\"shape\":[-"
168 "1],\"alias\":\"latitude\",\"tooltip\":\"latitude\"},\"longi"
169 "tude\":{\"default\":0.0,\"uilabel\":\"Geographical "
170 "longitude in degrees as a double\",\"doc\":\"Longitude"
171 " of the agent's geographical position. The value "
172 "should be expressed in degrees as a double.\",\"type"
173 "\":\"double\",\"index\":2,\"shape\":[-"
174 "1],\"alias\":\"longitude\",\"tooltip\":\"longitude\"}},\"do"
175 "c\":\"An institution that owns and operates a "
176 "manually entered list of facilities in the input "
177 "file\"}", root);
178 if (!parsed_ok) {
179 throw cyclus::ValueError("failed to parse annotations for cycamore::ManagerInst.");
180 }
181 return root;
182 };
183
184 virtual void InitInv(cyclus::Inventories& inv) {
185 };
186
187 virtual cyclus::Inventories SnapshotInv() {
188 cyclus::Inventories invs;
189 return invs;
190 };
191
192 virtual void Snapshot(cyclus::DbInit di) {
193 di.NewDatum("Info")
194 ->AddVal("prototypes", prototypes, &cycpp_shape_prototypes)
195 ->AddVal("latitude", latitude, &cycpp_shape_latitude)
196 ->AddVal("longitude", longitude, &cycpp_shape_longitude)
197 ->Record();
198 };
199
200 #pragma cyclus note {"doc": "An institution that owns and operates a " "manually entered list of facilities in " "the input file"}
201#line 32 "/cycamore/src/manager_inst.h"
202
204 virtual void EnterNotify();
205
207 virtual void BuildNotify(Agent* m);
208
210 virtual void DecomNotify(Agent* m);
211
214 void WriteProducerInformation(cyclus::toolkit::CommodityProducer*
215 producer);
216
217 private:
219 void Register_(cyclus::Agent* agent);
220
222 void Unregister_(cyclus::Agent* agent);
223
224 #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", }
225#line 62 "/cycamore/src/manager_inst.h"
226 std::vector<std::string> prototypes;
227 std::vector<int> cycpp_shape_prototypes;
228#line 63 "/cycamore/src/manager_inst.h"
229
230
231 #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." }
232#line 70 "/cycamore/src/manager_inst.h"
233 double latitude;
234 std::vector<int> cycpp_shape_latitude;
235#line 71 "/cycamore/src/manager_inst.h"
236
237
238 #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." }
239#line 78 "/cycamore/src/manager_inst.h"
240 double longitude;
241 std::vector<int> cycpp_shape_longitude;
242
243#line 79 "/cycamore/src/manager_inst.h"
244
245 cyclus::toolkit::Position coordinates;
246
248 void RecordPosition();
249};
250
251} // namespace cycamore
252
253#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.