PartialMap.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_MAP_PARTIALMAP_H_
00029 #define KEYVALUE_KEY_MAP_PARTIALMAP_H_
00030 
00031 #include <boost/static_assert.hpp>
00032 #include <boost/type_traits/is_same.hpp>
00033 
00034 #include "keyvalue/extern/String.h"
00035 #include "keyvalue/extern/Ptime.h"
00036 #include "keyvalue/key/Key.h"
00037 
00038 namespace keyvalue {
00039 
00040 // Forward declaration
00041 
00042 namespace value {
00043 class Variant;
00044 }
00045 
00046 namespace key {
00047 
00074 template <typename OutputType>
00075 class PartialMap {
00076 
00077 public:
00078 
00079   typedef OutputType OutputType_;
00080 
00081   PartialMap();
00082 
00094   OutputType
00095   map(const value::Variant& variant) const;
00096 
00106   virtual OutputType
00107   get(const string& name) const = 0;
00108 
00109 private:
00110 
00116   virtual string
00117   getName() const = 0;
00118 
00119   typedef typename boost::is_same<OutputType, double>::type IsDouble_;
00120   typedef typename boost::is_same<OutputType, ptime>::type IsPtime_;
00121   typedef typename boost::is_same<OutputType, unsigned int>::type IsUInt_;
00122 
00123   /*
00124    ATTENTION: If you get a compiler error here about
00125 
00126    'boost::STATIC_ASSERTION_FAILURE<x>'
00127 
00128    this means that you are trying to instantiate PartialMap policy for an
00129    OutputType different of double, ptime and unsigned int.
00130    */
00131   BOOST_STATIC_ASSERT(IsDouble_::value || IsPtime_::value ||
00132     IsUInt_::value);
00133 
00134 }; // class PartialMap
00135 
00136 } // namespace key
00137 } // namespace keyvalue
00138 
00139 #endif // KEYVALUE_KEY_MAP_PARTIALMAP_H_

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