@@ -34,18 +34,7 @@ class Configuration {
3434 for (const auto & entry : otr.configMap_ ) {
3535 configMap_[entry.first ] = std::make_shared<Configuration>(*entry.second );
3636 }
37- // vecMap_.reserve(otr.vecMap_.size());
38- // for (const auto& entry : otr.vecMap_) {
39- // vecMap_[entry.first] = Magnum::Vector3{entry.second};
40- // }
41- // quatMap_.reserve(otr.quatMap_.size());
42- // for (const auto& entry : otr.quatMap_) {
43- // quatMap_[entry.first] = Magnum::Quaternion{entry.second};
44- // }
45- // radMap_.reserve(otr.radMap_.size());
46- // for (const auto& entry : otr.radMap_) {
47- // radMap_[entry.first] = Magnum::Rad{entry.second};
48- // }
37+
4938 numEntries = calcNumEntries ();
5039 }
5140
@@ -100,39 +89,40 @@ class Configuration {
10089 return getValFromMap (key, radMap_);
10190 }
10291
103- // ****************** Setters ******************
104- template <typename T>
105- void set (CORRADE_UNUSED const std::string& key,
106- CORRADE_UNUSED const T& value) {
107- ESP_ERROR () << " Unknown/unsupported type :" << typeid (T).name ()
108- << " for key :" << key;
109- }
110- void set (const std::string& key, const bool & value) {
111- addValToMap (key, value, boolMap_);
112- }
113- void set (const std::string& key, const int & value) {
114- addValToMap (key, value, intMap_);
115- }
116-
117- void set (const std::string& key, const double & value) {
118- addValToMap (key, value, doubleMap_);
119- }
120- void set (const std::string& key, const char * value) {
121- addValToMap (key, std::string (value), stringMap_);
122- }
123-
124- void set (const std::string& key, const std::string& value) {
125- addValToMap (key, value, stringMap_);
126- }
92+ /* *
93+ * @brief This method will look for the provided key, and return a string
94+ * holding the object, if it is found in one of this configuration's maps
95+ */
96+ std::string getAsString (const std::string& key) const {
97+ if (hasBool (key)) {
98+ return getBoolAsString (key);
99+ }
127100
128- void set (const std::string& key, const Magnum::Vector3& value) {
129- addValToMap (key, value, vecMap_);
130- }
131- void set (const std::string& key, const Magnum::Quaternion& value) {
132- addValToMap (key, value, quatMap_);
133- }
134- void set (const std::string& key, const Magnum::Rad& value) {
135- addValToMap (key, value, radMap_);
101+ if (hasDouble (key)) {
102+ return getDoubleAsString (key);
103+ }
104+ if (hasBool (key)) {
105+ return getBoolAsString (key);
106+ }
107+ if (hasInt (key)) {
108+ return getIntAsString (key);
109+ }
110+ if (hasString (key)) {
111+ return getString (key);
112+ }
113+ if (hasRad (key)) {
114+ return getRadAsString (key);
115+ }
116+ if (hasVec3 (key)) {
117+ return getVec3AsString (key);
118+ }
119+ if (hasQuat (key)) {
120+ return getQuatAsString (key);
121+ }
122+ std::string retVal = " Key " ;
123+ retVal.append (key).append (" not present in this configuration" );
124+ ESP_WARNING () << retVal;
125+ return retVal;
136126 }
137127
138128 // ****************** String Conversion ******************
@@ -198,7 +188,40 @@ class Configuration {
198188 std::vector<std::string> getRadKeys () const {
199189 return getKeysFromMap (radMap_);
200190 }
191+ // ****************** Setters ******************
192+ template <typename T>
193+ void set (CORRADE_UNUSED const std::string& key,
194+ CORRADE_UNUSED const T& value) {
195+ ESP_ERROR () << " Unknown/unsupported type :" << typeid (T).name ()
196+ << " for key :" << key;
197+ }
198+ void set (const std::string& key, const bool & value) {
199+ addValToMap (key, value, boolMap_);
200+ }
201+ void set (const std::string& key, const int & value) {
202+ addValToMap (key, value, intMap_);
203+ }
204+
205+ void set (const std::string& key, const double & value) {
206+ addValToMap (key, value, doubleMap_);
207+ }
208+ void set (const std::string& key, const char * value) {
209+ addValToMap (key, std::string (value), stringMap_);
210+ }
201211
212+ void set (const std::string& key, const std::string& value) {
213+ addValToMap (key, value, stringMap_);
214+ }
215+
216+ void set (const std::string& key, const Magnum::Vector3& value) {
217+ addValToMap (key, value, vecMap_);
218+ }
219+ void set (const std::string& key, const Magnum::Quaternion& value) {
220+ addValToMap (key, value, quatMap_);
221+ }
222+ void set (const std::string& key, const Magnum::Rad& value) {
223+ addValToMap (key, value, radMap_);
224+ }
202225 // ****************** Value removal ******************
203226 bool removeBool (const std::string& key) {
204227 return removeValFromMap (key, boolMap_);
@@ -235,8 +258,8 @@ class Configuration {
235258 * storage.
236259 *
237260 * @param name The name of the configuration to edit.
238- * @return A pointer to a copy of the configuration having the requested name,
239- * or a pointer to an empty configuration.
261+ * @return A pointer to a copy of the configuration having the requested
262+ * name, or a pointer to an empty configuration.
240263 */
241264
242265 std::shared_ptr<Configuration> getSubConfigCopy (
@@ -256,7 +279,8 @@ class Configuration {
256279 * Use this function when you wish to modify this configuration's
257280 * subgroup.
258281 * @param name The name of the configuration to edit.
259- * @return The actual pointer to the configuration having the requested name.
282+ * @return The actual pointer to the configuration having the requested
283+ * name.
260284 */
261285 std::shared_ptr<Configuration> editSubConfig (const std::string& name) {
262286 makeNewSubgroup (name);
@@ -299,8 +323,8 @@ class Configuration {
299323 bool hasValues () const { return getNumEntries () > 0 ; }
300324
301325 /* *
302- * @brief Checks if passed @p key is contained in this configuration. Returns
303- * the highest level where @p key was found, or 0 if not found
326+ * @brief Checks if passed @p key is contained in this configuration.
327+ * Returns the highest level where @p key was found, or 0 if not found
304328 * @param key The key to look for
305329 * @return The level @p key was found. 0 if not found (so can be treated as
306330 * bool)
@@ -324,8 +348,8 @@ class Configuration {
324348
325349 /* *
326350 * @brief Merges configuration pointed to by @p config into this
327- * configuration, including all subconfigs. Passed config overwrites existing
328- * data in this config.
351+ * configuration, including all subconfigs. Passed config overwrites
352+ * existing data in this config.
329353 * @param config The source of configuration data we wish to merge into this
330354 * configuration.
331355 */
0 commit comments