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_latitude[1] = {-1};
31 cycpp_shape_latitude = std::vector<int>(rawcycpp_shape_latitude, rawcycpp_shape_latitude + 1);
32 int rawcycpp_shape_longitude[1] = {-1};
33 cycpp_shape_longitude = std::vector<int>(rawcycpp_shape_longitude, rawcycpp_shape_longitude + 1);
34 int rawcycpp_shape_prototypes[2] = {-1, -1};
35 cycpp_shape_prototypes = std::vector<int>(rawcycpp_shape_prototypes, rawcycpp_shape_prototypes + 2);
36 latitude = m->latitude;
37 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_latitude[1] = {-1};
45 cycpp_shape_latitude = std::vector<int>(rawcycpp_shape_latitude, rawcycpp_shape_latitude + 1);
46 int rawcycpp_shape_longitude[1] = {-1};
47 cycpp_shape_longitude = std::vector<int>(rawcycpp_shape_longitude, rawcycpp_shape_longitude + 1);
48 int rawcycpp_shape_prototypes[2] = {-1, -1};
49 cycpp_shape_prototypes = std::vector<int>(rawcycpp_shape_prototypes, rawcycpp_shape_prototypes + 2);
50 cyclus::QueryResult qr = b->Query("Info", NULL);
51 latitude = qr.GetVal<double>("latitude");
52 longitude = qr.GetVal<double>("longitude");
53 prototypes = qr.GetVal<std::vector< std::string > >("prototypes");
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_latitude[1] = {-1};
60 cycpp_shape_latitude = std::vector<int>(rawcycpp_shape_latitude, rawcycpp_shape_latitude + 1);
61 int rawcycpp_shape_longitude[1] = {-1};
62 cycpp_shape_longitude = std::vector<int>(rawcycpp_shape_longitude, rawcycpp_shape_longitude + 1);
63 int rawcycpp_shape_prototypes[2] = {-1, -1};
64 cycpp_shape_prototypes = std::vector<int>(rawcycpp_shape_prototypes, rawcycpp_shape_prototypes + 2);
65 cyclus::InfileTree* sub = tree->SubTree("config/*");
66 int i;
67 int n;
68 if (sub->NMatches("latitude") > 0) {
69 {
70 double latitude_val = cyclus::Query<double>(sub, "latitude");
71 latitude = latitude_val;
72 }
73 } else {
74 double latitude_tmp = 0.0;
75 latitude = latitude_tmp;
76 }
77 if (sub->NMatches("longitude") > 0) {
78 {
79 double longitude_val = cyclus::Query<double>(sub, "longitude");
80 longitude = longitude_val;
81 }
82 } else {
83 double longitude_tmp = 0.0;
84 longitude = longitude_tmp;
85 }
86 {
87 cyclus::InfileTree* bub = sub->SubTree("prototypes", 0);
88 cyclus::InfileTree* sub = bub;
89 int n1 = sub->NMatches("val");
90 std::vector< std::string > prototypes_val;
91 prototypes_val.resize(n1);
92 for (int i1 = 0; i1 < n1; ++i1) {
93 std::string elem;
94 {
95 std::string elem_in = cyclus::Query<std::string>(sub, "val", i1);
96 elem = elem_in;
97 }
98 prototypes_val[i1] = elem;
99 }
100 prototypes = prototypes_val;
101 }
102 di.NewDatum("Info")
103 ->AddVal("latitude", latitude, &cycpp_shape_latitude)
104 ->AddVal("longitude", longitude, &cycpp_shape_longitude)
105 ->AddVal("prototypes", prototypes, &cycpp_shape_prototypes)
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 " <optional>\n"
119 " <element name=\"latitude\">\n"
120 " <a:documentation>Latitude of the agent's geographical position. The value should be expressed in degrees as a double.</a:documentation>\n"
121 " <data type=\"double\"/>\n"
122 " </element>\n"
123 " </optional>\n"
124 " <optional>\n"
125 " <element name=\"longitude\">\n"
126 " <a:documentation>Longitude of the agent's geographical position. The value should be expressed in degrees as a double.</a:documentation>\n"
127 " <data type=\"double\"/>\n"
128 " </element>\n"
129 " </optional>\n"
130 " <element name=\"prototypes\">\n"
131 " <oneOrMore>\n"
132 " <element name=\"val\">\n"
133 " <data type=\"string\"/>\n"
134 " </element>\n"
135 " </oneOrMore>\n"
136 " </element>\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\":{\"latitude\":{\"default\":0.0,\"uilabel\":\"Geo"
154 "graphical latitude in degrees as a "
155 "double\",\"doc\":\"Latitude of the agent's "
156 "geographical position. The value should be "
157 "expressed in degrees as a double.\",\"type\":\"double\""
158 ",\"index\":0,\"shape\":[-"
159 "1],\"alias\":\"latitude\",\"tooltip\":\"latitude\"},\"longi"
160 "tude\":{\"default\":0.0,\"uilabel\":\"Geographical "
161 "longitude in degrees as a double\",\"doc\":\"Longitude"
162 " of the agent's geographical position. The value "
163 "should be expressed in degrees as a double.\",\"type"
164 "\":\"double\",\"index\":1,\"shape\":[-"
165 "1],\"alias\":\"longitude\",\"tooltip\":\"longitude\"},\"pro"
166 "totypes\":{\"tooltip\":[\"producer facility "
167 "prototypes\",\"\"],\"uilabel\":[\"Producer Prototype Lis"
168 "t\",\"\"],\"uitype\":[\"oneormore\",\"prototype\"],\"doc\":\"A"
169 " set of facility prototypes that this institution "
170 "can build. All prototypes in this list must be "
171 "based on an archetype that implements the "
172 "cyclus::toolkit::CommodityProducer interface\",\"typ"
173 "e\":[\"std::vector\",\"std::string\"],\"index\":2,\"shape\""
174 ":[-1,-1],\"alias\":[\"prototypes\",\"val\"]}},\"doc\":\"An "
175 "institution that owns and operates a manually "
176 "entered list of facilities in the input file\"}", root);
177 if (!parsed_ok) {
178 throw cyclus::ValueError("failed to parse annotations for cycamore::ManagerInst.");
179 }
180 return root;
181 };
182
183 virtual void InitInv(cyclus::Inventories& inv) {
184 };
185
186 virtual cyclus::Inventories SnapshotInv() {
187 cyclus::Inventories invs;
188 return invs;
189 };
190
191 virtual void Snapshot(cyclus::DbInit di) {
192 di.NewDatum("Info")
193 ->AddVal("latitude", latitude, &cycpp_shape_latitude)
194 ->AddVal("longitude", longitude, &cycpp_shape_longitude)
195 ->AddVal("prototypes", prototypes, &cycpp_shape_prototypes)
196 ->Record();
197 };
198
199 #pragma cyclus note {"doc": "An institution that owns and operates a " "manually entered list of facilities in " "the input file"}
200#line 32 "/cycamore/src/manager_inst.h"
201
203 virtual void EnterNotify();
204
206 virtual void BuildNotify(Agent* m);
207
209 virtual void DecomNotify(Agent* m);
210
213 void WriteProducerInformation(cyclus::toolkit::CommodityProducer*
214 producer);
215
216 private:
217 // Code Injection:
218 #include "toolkit/position.cycpp.h"
219
221 void Register_(cyclus::Agent* agent);
222
224 void Unregister_(cyclus::Agent* agent);
225
226 #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", }
227#line 65 "/cycamore/src/manager_inst.h"
228 std::vector<std::string> prototypes;
229 std::vector<int> cycpp_shape_prototypes;
230
231#line 66 "/cycamore/src/manager_inst.h"
232
233};
234
235} // namespace cycamore
236
237#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()
void Unregister_(cyclus::Agent *agent)
unregister a child
virtual void InitInv(cyclus::Inventories &inv)
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.