Loading...
Searching...
No Matches
ValueHandler.h
1/*
2
3MIT License
4
5Copyright (c) 2026 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30*/
31
32#ifndef DRAIN_VALUE_HANDLER
33#define DRAIN_VALUE_HANDLER
34
35//#include <drain/image/CoordinatePolicy.h>
36#include <ostream>
37
38#include "drain/TypeUtils.h"
39
40//#include "drain/util/Frame.h"
41//#include "Geometry.h"
42
43//#include "ImageFrame.h"
44//#include "Direction.h" //~ "Position.h", experimental
45
46namespace drain {
47
48
49namespace image {
50
51
60
61public:
62
63 typedef unsigned int flag_t;
64
65 static const flag_t ACCEPT = 0;
66 static const flag_t REJECT = 1;
67 static const flag_t CHANGED = 2;
68
70 inline
72
73 inline virtual
74 ~ValueHandler(){};
75
77 /*
78 *
79 */
80 template <typename T>
81 flag_t handle(T & value) const ;
82
83 template <typename T>
84 inline
85 bool validate(T & value) const {
86 return (handle(value) & REJECT) == 0;
87 }
88
89
90
91 virtual inline
92 flag_t handleUChar(unsigned char & value) const {
93 return ACCEPT;
94 };
95
96 virtual inline
97 flag_t handleInt(int & value) const {
98 return ACCEPT;
99 };
100
101 virtual inline
102 flag_t handleDouble(double & value) const {
103 return ACCEPT;
104 };
105
106
107
108};
109
110template <>
111inline
112ValueHandler::flag_t ValueHandler::handle(unsigned char & value) const {
113 return handleUChar(value);
114}
115
116template <>
117inline
118ValueHandler::flag_t ValueHandler::handle(int & value) const {
119 return handleInt(value);
120}
121
122template <>
123inline
124ValueHandler::flag_t ValueHandler::handle(double & d) const {
125 return handleDouble(d);
126}
127
128// using namespace std;
129// std::ostream & operator<<(std::ostream & ostr, const CoordinatePolicy & policy);
130
131
132} // image
133
134//DRAIN_TYPENAME(image::ValueHandler);
135
136
137} // drain
138#endif
139
140// Drain
Definition ValueHandler.h:59
ValueHandler()
Constructor.
Definition ValueHandler.h:71
flag_t handle(T &value) const
Checks and appropriately, change the value.
Definition Data.h:1473