-
Notifications
You must be signed in to change notification settings - Fork 0
/
RangeConverter.h
43 lines (34 loc) · 1.24 KB
/
RangeConverter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef RANGECONVERTER_H
#define RANGECONVERTER_H
#include "Range.h"
#include <EasySerDes.h>
namespace util {
class RangeConverter {
public:
RangeConverter(const RangeConverter& other) = default;
RangeConverter(RangeConverter&& other) = default;
RangeConverter(Range<double> from, Range<double> to);
RangeConverter& operator=(const RangeConverter& other) = default;
RangeConverter& operator=(RangeConverter&& other) = default;
double Convert(const double& value) const;
double ConvertAndClamp(const double& value) const;
const Range<double>& GetFrom() const { return from_; }
const Range<double>& GetTo() const { return to_; }
private:
Range<double> from_;
Range<double> to_;
};
} // end namespace util
template<>
class esd::Serialiser<util::RangeConverter> : public esd::ClassHelper<util::RangeConverter, util::Range<double>, util::Range<double>> {
public:
static void Configure()
{
using This = ClassHelper<util::RangeConverter, util::Range<double>, util::Range<double>>;
This::SetConstruction(
This::CreateParameter(&util::RangeConverter::GetFrom, "from"),
This::CreateParameter(&util::RangeConverter::GetTo, "to")
);
}
};
#endif // RANGECONVERTER_H