Debian Codegraph @

plugins/dm.objectives/ObjectiveKeyExtractor.h

raw
1 #pragma once
2
3 #include "Objective.h"
4 #include "Specifier.h"
5
6 #include "ientity.h"
7
8 namespace objectives
9 {
10
11 /**
12 * Entity Visitor which extracts objective keyvalues (of the form "obj<n>_blah")
13 * and populates the given ObjectiveMap with the parsed objective objects.
14 */
15 class ObjectiveKeyExtractor
16 {
17 // Map of number->Objective objects
18 ObjectiveMap& _objMap;
19
20 public:
21
22 /**
23 * Constructor. Sets the map to populate.
24 */
25 ObjectiveKeyExtractor(ObjectiveMap& map)
26 : _objMap(map)
27 {
28 assert(_objMap.empty());
29 }
30
31 /**
32 * Entity keyvalue visit function.
33 */
34 void operator()(const std::string& key, const std::string& value);
35
36 private:
37 /**
38 * Sanity-checks and converts the given integer specifier [1..N] number
39 * to the enum range [FIRST_SPECIFIER..MAX_SPECIFIERS).
40 *
41 * @returns: MAX_SPECIFIERS if the given integer is invalid, the valid enum otherwise
42 */
43 Specifier::SpecifierNumber getSpecifierNumber(int specNum);
44 };
45
46 }