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
00022
00023
00024
00025
00026
00027
00034 #ifndef KEYVALUE_KEY_CHECKER_H_
00035 #define KEYVALUE_KEY_CHECKER_H_
00036
00037 #include "keyvalue/value/Single.h"
00038 #include "keyvalue/value/Vector.h"
00039 #include "keyvalue/value/Matrix.h"
00040
00041 namespace keyvalue {
00042 namespace key {
00043
00072 #if DOXYGEN
00073 template <typename ConverterType,
00074 typename InputType = typename ConverterType::InputType_>
00075 class Checker {};
00076 #endif
00077
00078 template <typename ConverterType,
00079 typename InputType = typename ConverterType::InputType_>
00080 class Checker;
00081
00088 template <typename ConverterType>
00089 class Checker<ConverterType, value::Single> {
00090
00091 public:
00092
00093 typedef typename ConverterType::OutputType_ OutputType_;
00094
00100 void
00101 checkInput(const value::Single& input) const;
00102
00112 void
00113 checkSoFar(const ConverterType& container) const;
00114
00120 void
00121 checkOutput(const OutputType_& output) const;
00122
00123 private :
00124
00130 virtual string
00131 getName() const = 0;
00132
00133 };
00134
00135
00136
00137
00138
00139 template <typename ConverterType>
00140 void
00141 Checker<ConverterType, value::Single>::checkInput(const value::Single&
00142 ) const {
00143 }
00144
00145
00146
00147
00148
00149 template <typename ConverterType>
00150 void
00151 Checker<ConverterType, value::Single>::checkSoFar(const ConverterType&
00152 ) const {
00153 }
00154
00155
00156
00157
00158
00159 template <typename ConverterType>
00160 void
00161 Checker<ConverterType, value::Single>::checkOutput(const OutputType_&
00162 ) const {
00163 }
00164
00171 template <typename ConverterType>
00172 class Checker<ConverterType, value::Vector> {
00173
00174 public:
00175
00176 typedef typename ConverterType::OutputType_ OutputType_;
00177
00185 void
00186 checkInput(const value::Vector& input) const;
00187
00193 void
00194 checkSoFar(const ConverterType& container) const;
00195
00201 void
00202 checkOutput(const OutputType_& output) const;
00203
00204 private:
00205
00211 virtual string
00212 getName() const = 0;
00213
00219 virtual void
00220 checkSize(size_t size) const;
00221
00222 };
00223
00224
00225
00226
00227
00228 template <typename ConverterType>
00229 void
00230 Checker<ConverterType, value::Vector>::checkInput(const value::Vector&
00231 input) const {
00232 this->checkSize(input.getSize());
00233 }
00234
00235
00236
00237
00238
00239 template <typename ConverterType>
00240 void
00241 Checker<ConverterType, value::Vector>::checkSoFar(const ConverterType&
00242 ) const {
00243 }
00244
00245
00246
00247
00248
00249 template <typename ConverterType>
00250 void
00251 Checker<ConverterType, value::Vector>::checkOutput(const OutputType_&
00252 ) const {
00253 }
00254
00255
00256
00257
00258
00259 template <typename ConverterType>
00260 void
00261 Checker<ConverterType, value::Vector>::checkSize(const size_t )
00262 const {
00263 }
00264
00271 template <typename ConverterType>
00272 class Checker<ConverterType, value::Matrix> {
00273
00274 public:
00275
00276 typedef typename ConverterType::OutputType_ OutputType_;
00277
00285 void
00286 checkInput(const value::Matrix& input) const;
00287
00293 void
00294 checkSoFar(const ConverterType& container) const;
00295
00301 void
00302 checkOutput(const OutputType_& output) const;
00303
00304 private:
00305
00311 virtual string
00312 getName() const = 0;
00313
00320 virtual void
00321 checkSize(size_t nRows, size_t nCols) const;
00322
00323 };
00324
00325
00326
00327
00328
00329 template <typename ConverterType>
00330 void
00331 Checker<ConverterType, value::Matrix>::checkInput(const value::Matrix&
00332 input) const {
00333 this->checkSize(input.getNRows(), input.getNCols());
00334 }
00335
00336
00337
00338
00339
00340 template <typename ConverterType>
00341 void
00342 Checker<ConverterType, value::Matrix>::checkSoFar(const ConverterType&
00343 ) const {
00344 }
00345
00346
00347
00348
00349
00350 template <typename ConverterType>
00351 void
00352 Checker<ConverterType, value::Matrix>::checkOutput(const OutputType_&
00353 ) const {
00354 }
00355
00356
00357
00358
00359
00360 template <typename ConverterType>
00361 void
00362 Checker<ConverterType, value::Matrix>::checkSize(const size_t ,
00363 const size_t ) const {
00364 }
00365
00366 }
00367 }
00368
00369 #endif // KEYVALUE_KEY_CHECKER_H_