Checker.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *
00003  * Copyright (C) 2009-2010 Cassio Neri Moreira
00004  *
00005  * This file is part of the KeyValue library.
00006  *
00007  * The KeyValue library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as published
00009  * by the Free Software Foundation, either version 3 of the License, or (at
00010  * your option) any later version.
00011  *
00012  * The KeyValue library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
00015  * Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License along
00018  * with KeyValue. If not, see <http://www.gnu.org/licenses/>.
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  * checkInput()
00130  *------------------------------------------------------------------------*/
00131 
00132 template <typename ConverterType>
00133 void
00134 Checker<ConverterType, value::Single>::checkInput(const value::Single&
00135   /* input */) const {
00136 }
00137 
00138 /*--------------------------------------------------------------------------
00139  * checkSoFar()
00140  *------------------------------------------------------------------------*/
00141 
00142 template <typename ConverterType>
00143 void
00144 Checker<ConverterType, value::Single>::checkSoFar(const ConverterType&
00145   /* container */) const {
00146 }
00147 
00148 /*--------------------------------------------------------------------------
00149  * checkOutput()
00150  *------------------------------------------------------------------------*/
00151 
00152 template <typename ConverterType>
00153 void
00154 Checker<ConverterType, value::Single>::checkOutput(const OutputType_&
00155   /* output */) 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  * checkInput()
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  * checkSoFar()
00230  *------------------------------------------------------------------------*/
00231 
00232 template <typename ConverterType>
00233 void
00234 Checker<ConverterType, value::Vector>::checkSoFar(const ConverterType&
00235   /* ConverterType */) const {
00236 }
00237 
00238 /*--------------------------------------------------------------------------
00239  * checkOutput()
00240  *------------------------------------------------------------------------*/
00241 
00242 template <typename ConverterType>
00243 void
00244 Checker<ConverterType, value::Vector>::checkOutput(const OutputType_&
00245   /* output*/) const {
00246 }
00247 
00248 /*--------------------------------------------------------------------------
00249  * checkSize()
00250  *------------------------------------------------------------------------*/
00251 
00252 template <typename ConverterType>
00253 void
00254 Checker<ConverterType, value::Vector>::checkSize(const size_t /* size */)
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  * checkInput()
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  * checkSoFar()
00331  *------------------------------------------------------------------------*/
00332 
00333 template <typename ConverterType>
00334 void
00335 Checker<ConverterType, value::Matrix>::checkSoFar(const ConverterType&
00336   /* ConverterType */) const {
00337 }
00338 
00339 /*--------------------------------------------------------------------------
00340  * checkOutput()
00341  *------------------------------------------------------------------------*/
00342 
00343 template <typename ConverterType>
00344 void
00345 Checker<ConverterType, value::Matrix>::checkOutput(const OutputType_&
00346   /* output*/) const {
00347 }
00348 
00349 /*--------------------------------------------------------------------------
00350  * checkSize()
00351  *------------------------------------------------------------------------*/
00352 
00353 template <typename ConverterType>
00354 void
00355 Checker<ConverterType, value::Matrix>::checkSize(const size_t /* nRows */,
00356   const size_t /* nCols */) const {
00357 }
00358 
00359 } // namespace key
00360 } // namespace keyvalue
00361 
00362 #endif // KEYVALUE_KEY_CHECKER_H_

Generated on Sat Mar 20 15:08:29 2010 for KeyValue by  doxygen 1.6.1