ADTF  3.18.2
map_transformation.h
Go to the documentation of this file.
1 
15 #ifndef HEADER_MAP_TRANSFORMATION_H
16 #define HEADER_MAP_TRANSFORMATION_H
17 
18 #include <a_util/result.h>
19 #include <a_util/strings.h>
20 #include <a_util/xml.h>
21 
22 namespace ddl {
23 namespace mapping {
24 
25 class MapConfiguration;
26 
31 public:
37  MapTransformationBase(MapConfiguration* config, const std::string& name);
38 
43 
47  const std::string& getName() const;
48 
52  bool isValid() const;
53 
57  virtual bool isEqual(const MapTransformationBase& other) const = 0;
58 
62  virtual MapTransformationBase* clone() const = 0;
63 
68  virtual double evaluate(double value) const = 0;
69 
70 private:
80  const a_util::xml::DOMElement& dom_element,
81  MapTransformationBase*& destination);
82 
93  const std::string& name,
94  const std::string& type,
95  MapTransformationBase*& destination);
96 
104 
111 
112 protected:
114  friend class MapConfiguration;
115  MapConfiguration* _config;
116  std::string _name;
117  bool _is_valid;
119 };
120 
124 public:
130  MapPolynomTransformation(MapConfiguration* config, const std::string& name);
131 
135  double getA() const;
136 
140  double getB() const;
141 
145  double getC() const;
146 
150  double getD() const;
151 
155  double getE() const;
156 
163  a_util::result::Result setCoefficients(const std::string coefs[5]);
164 
168  bool isEqual(const MapTransformationBase& other) const;
169 
173  double evaluate(double value) const;
174 
177 
178 private:
186 
194 
195 private:
197  friend class MapTransformationBase;
198  double _a, _b, _c, _d, _e;
200 };
201 
204 public: // types
205 #if defined(__GNUC__) && ((__GNUC__ == 5) && (__GNUC_MINOR__ == 2))
206 #pragma GCC diagnostic push
207 #pragma GCC diagnostic ignored "-Wattributes"
208 #endif // defined(__GNUC__) && ((__GNUC__ == 5) && (__GNUC_MINOR__ == 2))
209 
211  using ConversionMap = std::map<int64_t, int64_t>;
212 
213 #if defined(__GNUC__) && ((__GNUC__ == 5) && (__GNUC_MINOR__ == 2))
214 #pragma GCC diagnostic pop
215 #endif // defined(__GNUC__) && ((__GNUC__ == 5) && (__GNUC_MINOR__ == 2))
216 
217 public:
223  MapEnumTableTransformation(MapConfiguration* config, const std::string& name);
224 
228  const std::string& getEnumFrom() const;
229 
233  const std::string& getEnumTo() const;
234 
242  a_util::result::Result setEnums(const std::string& enum_from, const std::string& enum_to);
243 
247  int64_t getDefault() const;
248 
252  std::string getDefaultStr() const;
253 
259  a_util::result::Result setDefault(const std::string& default_value);
260 
265 
269  const std::map<std::string, std::string>& getConversionsStr() const;
270 
277  a_util::result::Result addConversion(const std::string& from, const std::string& to);
278 
284  a_util::result::Result removeConversion(const std::string& from);
285 
289  bool isEqual(const MapTransformationBase& other) const;
290 
294  double evaluate(double value) const;
295 
298 
299 private:
307 
315 
325 
332  a_util::result::Result setEnumsStr(const std::string& enum_from, const std::string& enum_to);
333 
339  a_util::result::Result setDefaultStr(const std::string& default_value);
340 
347  a_util::result::Result addConversionStr(const std::string& from, const std::string& to);
348 
349 private:
350  friend class MapTransformationBase;
351  std::string _enum_from;
352  std::string _enum_to;
353  std::string _default_value;
354  typedef std::map<std::string, std::string> MapStrConversionList;
355  MapStrConversionList _conversions;
356  int64_t _default_int;
357  ConversionMap _conversions_int;
358 };
359 
361 typedef std::vector<MapTransformationBase*> MapTransformationList;
362 
363 } // namespace mapping
364 } // namespace ddl
365 
366 #endif // HEADER_MAP_TRANSFORMATION_H
A common result class usable as return value throughout.
MapConfiguration is the central class of the mapping::dd namespace.
MapEnumTableTransformation represents a transformation between to enumerations.
const std::string & getEnumFrom() const
Returns the name of the source enumeration.
const ConversionMap & getConversions() const
Returns conversion list.
double evaluate(double value) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
a_util::result::Result setDefault(const std::string &default_value)
Set default value as string.
bool isEqual(const MapTransformationBase &other) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
a_util::result::Result convertValuesWithDDL()
Convert string values to integer values.
const std::string & getEnumTo() const
Returns the name of the target enumeration.
int64_t getDefault() const
Returns default value.
a_util::result::Result addConversion(const std::string &from, const std::string &to)
Add a conversion as string.
MapTransformationBase * clone() const
nodoc
std::string getDefaultStr() const
Returns default value as string.
a_util::result::Result setEnumsStr(const std::string &enum_from, const std::string &enum_to)
Set the name of the target and source enumerations.
MapEnumTableTransformation(MapConfiguration *config, const std::string &name)
CTOR.
std::map< int64_t, int64_t > ConversionMap
Alias for the conversion map.
a_util::result::Result loadFromDom(const a_util::xml::DOMElement &dom_element)
Initializes the transformation from a target-dom element.
a_util::result::Result setDefaultStr(const std::string &default_value)
Set default value as string.
a_util::result::Result setEnums(const std::string &enum_from, const std::string &enum_to)
Set the name of the target and source enumerations.
const std::map< std::string, std::string > & getConversionsStr() const
Returns conversion list as string.
a_util::result::Result addConversionStr(const std::string &from, const std::string &to)
Add a conversion as string.
a_util::result::Result writeToDOM(a_util::xml::DOMElement &dom_element) const
Export transformation to a XML dom element.
a_util::result::Result removeConversion(const std::string &from)
Remove a conversion as string.
MapPolynomTransformation represents a polynom transformation in the configuration api as well as the ...
double evaluate(double value) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEqual(const MapTransformationBase &other) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
a_util::result::Result setCoefficients(const std::string coefs[5])
Set Polynom coefficients.
double getD() const
Returns parameter A of the polynomial.
double getC() const
Returns parameter A of the polynomial.
MapTransformationBase * clone() const
nodoc
double getA() const
Returns parameter A of the polynomial.
MapPolynomTransformation(MapConfiguration *config, const std::string &name)
CTOR.
a_util::result::Result loadFromDom(const a_util::xml::DOMElement &dom_element)
Initializes the transformation from a target-dom element.
double getB() const
Returns parameter A of the polynomial.
double getE() const
Returns parameter A of the polynomial.
a_util::result::Result writeToDOM(a_util::xml::DOMElement &dom_element) const
Export transformation to a XML dom element.
cMapTransformation forms a base class for a single transformation
static a_util::result::Result create(MapConfiguration *config, const std::string &name, const std::string &type, MapTransformationBase *&destination)
creates a polymorphic transformation instance from a dom element
bool isValid() const
Returns the validity for the current description.
MapTransformationBase(MapConfiguration *config, const std::string &name)
CTOR.
virtual bool isEqual(const MapTransformationBase &other) const =0
Polymorphic comparison method.
virtual MapTransformationBase * clone() const =0
Polymorphic clone method.
const std::string & getName() const
Returns the name of the transformation.
a_util::result::Result setTypeFromDDL()
Set Float values from Enumeration definition in DataDefinition-File.
virtual double evaluate(double value) const =0
Polymorphic evaluation template method.
static a_util::result::Result createFromDOM(MapConfiguration *config, const a_util::xml::DOMElement &dom_element, MapTransformationBase *&destination)
creates a polymorphic transformation instance from a dom element
a_util::result::Result writeToDOM(a_util::xml::DOMElement &dom_element) const
Export transformation to a XML dom element.
std::vector< MapTransformationBase * > MapTransformationList
Public composite types used in the mapping::dd namespace.
Common include for component a_util::strings.
Common include for component a_util::result.
Common include for component a_util::xml.