• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Directories
  • File List
  • File Members

multi_type_map.hpp

Go to the documentation of this file.
00001 /*
00002   CLAW - a C++ Library Absolutely Wonderful
00003 
00004   CLAW is a free library without any particular aim but being useful to 
00005   anyone.
00006 
00007   Copyright (C) 2005-2010 Julien Jorge
00008 
00009   This library is free software; you can redistribute it and/or
00010   modify it under the terms of the GNU Lesser General Public
00011   License as published by the Free Software Foundation; either
00012   version 2.1 of the License, or (at your option) any later version.
00013 
00014   This library is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017   Lesser General Public License for more details.
00018 
00019   You should have received a copy of the GNU Lesser General Public
00020   License along with this library; if not, write to the Free Software
00021   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023   contact: julien_jorge@yahoo.fr
00024 */
00030 #ifndef __CLAW_MULTI_TYPE_MAP_HPP__
00031 #define __CLAW_MULTI_TYPE_MAP_HPP__
00032 
00033 #include <claw/meta/no_type.hpp>
00034 #include <claw/meta/type_list.hpp>
00035 #include <map>
00036 
00037 namespace claw
00038 {
00059   template<typename ValueType, typename Map>
00060   class multi_type_map_wrapper;
00061 
00081   template<typename Key, typename TypeList>
00082   class multi_type_map;
00083 
00087   template<typename Key>
00088   class multi_type_map<Key, meta::no_type>
00089   {
00090 
00091   }; // class multi_type_map
00092 
00093   /*
00094    * Here is the interface of multi_type_map
00095    */
00096   template<typename Key, typename Head, typename Tail>
00097   class multi_type_map< Key, meta::type_list<Head, Tail> >:
00098     public multi_type_map<Key, Tail>
00099   {
00100   public:
00101     typedef Key key_type;
00102     typedef Head value_type;
00103     typedef meta::type_list<Head, Tail> value_type_list;
00104     typedef multi_type_map< Key, meta::type_list<Head, Tail> > self_type;
00105     typedef std::map<key_type, value_type> container_type;
00106     typedef multi_type_map<Key, Tail> super;
00107 
00108     friend struct multi_type_map_wrapper<value_type, self_type>;
00109 
00112     template<typename ValueType>
00113     struct iterator
00114     {
00116       typedef typename std::map<key_type, ValueType>::iterator type;
00117 
00119       typedef
00120       typename std::map<key_type, ValueType>::const_iterator const_type;
00121     }; // struct iterator
00122 
00123   private:
00124     typedef typename iterator<value_type>::type iterator_type;
00125     typedef typename iterator<value_type>::const_type const_iterator_type;
00126 
00127   public:
00128     template<typename ValueType>
00129     const ValueType& get( const key_type& k ) const;
00130 
00131     template<typename ValueType>
00132     void set( const key_type& k, const ValueType& v );
00133 
00134     template<typename ValueType>
00135     bool exists( const key_type& k ) const;
00136 
00137     template<typename ValueType>
00138     typename iterator<ValueType>::type begin();
00139 
00140     template<typename ValueType>
00141     typename iterator<ValueType>::type end();
00142 
00143     template<typename ValueType>
00144     typename iterator<ValueType>::const_type begin() const;
00145 
00146     template<typename ValueType>
00147     typename iterator<ValueType>::const_type end() const;
00148 
00149   private:
00151     container_type m_data;
00152 
00153   }; // class multi_type_map
00154 
00155 } // namespace claw
00156 
00157 #include <claw/impl/multi_type_map.tpp>
00158 
00159 #endif // __CLAW_MULTI_TYPE_MAP_HPP__

Generated on Fri Dec 24 2010 13:18:32 for CLAW Library (a C++ Library Absolutely Wonderful) by  doxygen 1.7.2