about summary refs log tree commit diff stats
path: root/tools/validator/validator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/validator/validator.cpp')
-rw-r--r--tools/validator/validator.cpp79
1 files changed, 78 insertions, 1 deletions
diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index ab1612e..dd41f5c 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp
@@ -48,6 +48,9 @@ class Validator {
48 for (const auto& [prog_name, prog_info] : info_.progressives) { 48 for (const auto& [prog_name, prog_info] : info_.progressives) {
49 ValidateProgressive(prog_name, prog_info); 49 ValidateProgressive(prog_name, prog_info);
50 } 50 }
51 for (const auto& [group_name, group_info] : info_.door_groups) {
52 ValidateDoorGroup(group_name, group_info);
53 }
51 } 54 }
52 55
53 private: 56 private:
@@ -103,7 +106,8 @@ class Validator {
103 return false; 106 return false;
104 } 107 }
105 108
106 if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0) { 109 if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0 ||
110 h_door.complete_at() > 0) {
107 return true; 111 return true;
108 } 112 }
109 113
@@ -173,6 +177,11 @@ class Validator {
173 std::cout << " PROGRESSIVE " << prog_name << std::endl; 177 std::cout << " PROGRESSIVE " << prog_name << std::endl;
174 } 178 }
175 179
180 for (const std::string& group_name :
181 door_info.door_groups_referenced_by) {
182 std::cout << " DOOR GROUP " << group_name << std::endl;
183 }
184
176 if (door_info.has_id) { 185 if (door_info.has_id) {
177 std::cout << " An AP ID is present." << std::endl; 186 std::cout << " An AP ID is present." << std::endl;
178 } 187 }
@@ -248,6 +257,22 @@ class Validator {
248 std::cout << "Port " << port_identifier.ShortDebugString() 257 std::cout << "Port " << port_identifier.ShortDebugString()
249 << " was defined multiple times." << std::endl; 258 << " was defined multiple times." << std::endl;
250 } 259 }
260
261 if (!port_info.target_connections_referenced_by.empty()) {
262 for (const HumanPort& port : port_info.definitions) {
263 if (port.has_required_door()) {
264 std::cout << "Port " << port_identifier.ShortDebugString()
265 << " has a required door but is the target of a connection:"
266 << std::endl;
267
268 for (const HumanConnection& connection :
269 port_info.target_connections_referenced_by) {
270 std::cout << " CONNECTION " << connection.ShortDebugString()
271 << std::endl;
272 }
273 }
274 }
275 }
251 } 276 }
252 277
253 void ValidatePainting(const PaintingIdentifier& painting_identifier, 278 void ValidatePainting(const PaintingIdentifier& painting_identifier,
@@ -271,6 +296,22 @@ class Validator {
271 std::cout << "Painting " << painting_identifier.ShortDebugString() 296 std::cout << "Painting " << painting_identifier.ShortDebugString()
272 << " was defined multiple times." << std::endl; 297 << " was defined multiple times." << std::endl;
273 } 298 }
299
300 if (!painting_info.target_connections_referenced_by.empty()) {
301 for (const HumanPainting& painting : painting_info.definitions) {
302 if (painting.has_required_door()) {
303 std::cout << "Painting " << painting_identifier.ShortDebugString()
304 << " has a required door but is the target of a connection:"
305 << std::endl;
306
307 for (const HumanConnection& connection :
308 painting_info.target_connections_referenced_by) {
309 std::cout << " CONNECTION " << connection.ShortDebugString()
310 << std::endl;
311 }
312 }
313 }
314 }
274 } 315 }
275 316
276 void ValidatePanel(const PanelIdentifier& panel_identifier, 317 void ValidatePanel(const PanelIdentifier& panel_identifier,
@@ -332,6 +373,22 @@ class Validator {
332 std::cout << "Panel " << panel_identifier.ShortDebugString() 373 std::cout << "Panel " << panel_identifier.ShortDebugString()
333 << " is missing an AP ID." << std::endl; 374 << " is missing an AP ID." << std::endl;
334 } 375 }
376
377 if (!panel_info.target_connections_referenced_by.empty()) {
378 for (const HumanPanel& panel : panel_info.definitions) {
379 if (panel.has_required_door()) {
380 std::cout << "Panel " << panel_identifier.ShortDebugString()
381 << " has a required door but is the target of a connection:"
382 << std::endl;
383
384 for (const HumanConnection& connection :
385 panel_info.target_connections_referenced_by) {
386 std::cout << " CONNECTION " << connection.ShortDebugString()
387 << std::endl;
388 }
389 }
390 }
391 }
335 } 392 }
336 393
337 void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, 394 void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier,
@@ -460,6 +517,26 @@ class Validator {
460 } 517 }
461 } 518 }
462 519
520 void ValidateDoorGroup(const std::string& group_name,
521 const DoorGroupInfo& group_info) const {
522 if (group_info.definitions.empty()) {
523 std::cout << "Door group \"" << group_name
524 << "\" has no definition, but was referenced:" << std::endl;
525
526 if (group_info.has_id) {
527 std::cout << " An AP ID is present." << std::endl;
528 }
529 } else if (group_info.definitions.size() > 1) {
530 std::cout << "Door group \"" << group_name
531 << "\" has multiple definitions." << std::endl;
532 }
533
534 if (!group_info.has_id) {
535 std::cout << "Door group \"" << group_name << "\" is missing an AP ID."
536 << std::endl;
537 }
538 }
539
463 const CollectedInfo& info_; 540 const CollectedInfo& info_;
464}; 541};
465 542