Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:43:50

0001 #ifndef PARAMETERS_H
0002 #define PARAMETERS_H
0003 
0004 /**
0005  * @file Parameters.h
0006  * @author Bryan BERTHOU (SPhN / CEA Saclay)
0007  * @date February 19, 2016
0008  * @version 1.0
0009  */
0010 
0011 #include <stddef.h>
0012 #include <map>
0013 #include <string>
0014 
0015 #include "Parameter.h"
0016 
0017 namespace ElemUtils {
0018 
0019 /**
0020  * @class Parameters
0021  *
0022  * @brief Object defining a list of pieces of data (of common Parameter type).
0023  * Each member of the list is uniquely identified by its name.
0024  */
0025 class Parameters {
0026 public:
0027     Parameters();
0028     Parameters(const std::string &key, const GenericType &value);
0029     Parameters(const Parameter &parameter);
0030     virtual ~Parameters();
0031 
0032     void add(const std::string &key, const GenericType &value);
0033     void add(const Parameter &parameter);
0034     void add(const Parameters &parameters);
0035 
0036     bool isAvailable(const std::string &parameterName) const;
0037 
0038     size_t size() const;
0039 
0040     void clear();
0041 
0042     Parameter operator()(const std::string &key) const;
0043 
0044     virtual std::string toString() const;
0045 
0046     bool update(const std::string &key, const GenericType &value);
0047     bool update(const std::string &key, const Parameter &parameter);
0048     bool remove(const std::string &key);
0049 
0050     const Parameter& get(const std::string &key) const;
0051     const Parameter& getLastAvailable() const; /// Care ! Use it after isAvailable() to ensure that the iterator is in the map range.
0052 
0053     std::string key(size_t index) const;
0054     std::string stringValue(size_t index) const;
0055 
0056 private:
0057     // <key, value>
0058     std::map<std::string, Parameter> m_parameters;
0059     // mutable keyword is use too indicate that member can be modify in const function. In this case useful with iterator m_it & isAvailable() function.
0060     mutable std::map<std::string, Parameter>::const_iterator m_it;
0061 };
0062 
0063 } // namespace ElemUtils
0064 
0065 #endif /* PARAMETERS_H */