OpenAB  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
GenericParameters.hpp
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5  */
10 #ifndef GENERICPARAMETERS_H_
11 #define GENERICPARAMETERS_H_
12 #include <plugin/Plugin.hpp>
13 #include <helpers/Variant.hpp>
14 
18 namespace OpenAB_Plugin {
19 
26 {
27  public:
32 
37  GenericParameters(const std::string& json);
38 
42  virtual ~GenericParameters();
43 
48  std::string toJSON() const;
49 
56  bool fromJSON(const std::string& json);
57 
64  OpenAB::Variant getValue(const std::string& key) const;
65 
71  void setValue(const std::string& key, const OpenAB::Variant& value);
72 
77  void removeKey(const std::string& key);
78 
83  std::vector<std::string> getAllKeys() const;
84 
85  private:
86 
87  std::map<std::string, OpenAB::Variant> config;
88 };
89 
90 } // namespace OpenAB_Plugin
91 
92 #endif // GENERICPARAMETERS_H_
Definition: Plugin.hpp:176
OpenAB::Variant getValue(const std::string &key) const
Returns value assigned to given key.
Definition: GenericParameters.cpp:119
virtual ~GenericParameters()
Destructor, virtual by default.
Definition: GenericParameters.cpp:27
std::vector< std::string > getAllKeys() const
Returns list of all keys. list of all keys.
Definition: GenericParameters.cpp:135
void removeKey(const std::string &key)
Removes key and its assigned value.
Definition: GenericParameters.cpp:129
void setValue(const std::string &key, const OpenAB::Variant &value)
Assigns or updates value to/of given key.
Definition: GenericParameters.cpp:114
bool fromJSON(const std::string &json)
Deserializes parameters from JSON string.
Definition: GenericParameters.cpp:66
Variant class that can contains different types of data.
Definition: Variant.hpp:26
GenericParameters()
Default constructor.
Definition: GenericParameters.cpp:15
std::string toJSON() const
Serializes parameters to JSON string.
Definition: GenericParameters.cpp:32
Generic storage for plugin parameters. Allows to store map of parameters with different types (OpenAB...
Definition: GenericParameters.hpp:25