Checker.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00028 #ifndef KEYVALUE_KEY_CHECKER_H_
00029 #define KEYVALUE_KEY_CHECKER_H_
00030
00031 #include "keyvalue/value/Single.h"
00032 #include "keyvalue/value/Vector.h"
00033
00034 namespace keyvalue {
00035 namespace key {
00036
00065 #if DOXYGEN
00066 template <typename ConverterType,
00067 typename InputType = typename ConverterType::InputType_>
00068 class Checker {};
00069 #endif
00070
00071 template <typename ConverterType,
00072 typename InputType = typename ConverterType::InputType_>
00073 class Checker;
00074
00081 template <typename ConverterType>
00082 class Checker<ConverterType, value::Single> {
00083
00084 public:
00085
00086 typedef typename ConverterType::OutputType_ OutputType_;
00087
00093 void
00094 checkInput(const value::Single& input) const;
00095
00105 void
00106 checkSoFar(const ConverterType& container) const;
00107
00113 void
00114 checkOutput(const OutputType_& output) const;
00115
00116 private :
00117
00123 virtual string
00124 getName() const = 0;
00125
00126 };
00127
00128
00129
00130
00131
00132 template <typename ConverterType>
00133 void
00134 Checker<ConverterType, value::Single>::checkInput(const value::Single&
00135 ) const {
00136 }
00137
00138
00139
00140
00141
00142 template <typename ConverterType>
00143 void
00144 Checker<ConverterType, value::Single>::checkSoFar(const ConverterType&
00145 ) const {
00146 }
00147
00148
00149
00150
00151
00152 template <typename ConverterType>
00153 void
00154 Checker<ConverterType, value::Single>::checkOutput(const OutputType_&
00155 ) const {
00156 }
00157
00164 template <typename ConverterType>
00165 class Checker<ConverterType, value::Vector> {
00166
00167 public:
00168
00169 typedef typename ConverterType::OutputType_ OutputType_;
00170
00178 void
00179 checkInput(const value::Vector& input) const;
00180
00186 void
00187 checkSoFar(const ConverterType& container) const;
00188
00194 void
00195 checkOutput(const OutputType_& output) const;
00196
00197 private:
00198
00204 virtual string
00205 getName() const = 0;
00206
00212 virtual void
00213 checkSize(size_t size) const;
00214
00215 };
00216
00217
00218
00219
00220
00221 template <typename ConverterType>
00222 void
00223 Checker<ConverterType, value::Vector>::checkInput(const value::Vector&
00224 input) const {
00225 this->checkSize(input.getSize());
00226 }
00227
00228
00229
00230
00231
00232 template <typename ConverterType>
00233 void
00234 Checker<ConverterType, value::Vector>::checkSoFar(const ConverterType&
00235 ) const {
00236 }
00237
00238
00239
00240
00241
00242 template <typename ConverterType>
00243 void
00244 Checker<ConverterType, value::Vector>::checkOutput(const OutputType_&
00245 ) const {
00246 }
00247
00248
00249
00250
00251
00252 template <typename ConverterType>
00253 void
00254 Checker<ConverterType, value::Vector>::checkSize(const size_t )
00255 const {
00256 }
00257
00264 template <typename ConverterType>
00265 class Checker<ConverterType, value::Matrix> {
00266
00267 public:
00268
00269 typedef typename ConverterType::OutputType_ OutputType_;
00270
00278 void
00279 checkInput(const value::Matrix& input) const;
00280
00286 void
00287 checkSoFar(const ConverterType& container) const;
00288
00294 void
00295 checkOutput(const OutputType_& output) const;
00296
00297 private:
00298
00304 virtual string
00305 getName() const = 0;
00306
00313 virtual void
00314 checkSize(size_t nRows, size_t nCols) const;
00315
00316 };
00317
00318
00319
00320
00321
00322 template <typename ConverterType>
00323 void
00324 Checker<ConverterType, value::Matrix>::checkInput(const value::Matrix&
00325 input) const {
00326 this->checkSize(input.getNRows(), input.getNCols());
00327 }
00328
00329
00330
00331
00332
00333 template <typename ConverterType>
00334 void
00335 Checker<ConverterType, value::Matrix>::checkSoFar(const ConverterType&
00336 ) const {
00337 }
00338
00339
00340
00341
00342
00343 template <typename ConverterType>
00344 void
00345 Checker<ConverterType, value::Matrix>::checkOutput(const OutputType_&
00346 ) const {
00347 }
00348
00349
00350
00351
00352
00353 template <typename ConverterType>
00354 void
00355 Checker<ConverterType, value::Matrix>::checkSize(const size_t ,
00356 const size_t ) const {
00357 }
00358
00359 }
00360 }
00361
00362 #endif // KEYVALUE_KEY_CHECKER_H_