• 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-2008 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.hpp>
00034 #include <map>
00035 
00036 namespace claw
00037 {
00038   template<typename ReturnType, typename Map>
00039   class multi_type_map_wrapper;
00040 
00060   template<typename Key, typename TypeList>
00061   class multi_type_map
00062     : public multi_type_map<Key, typename TypeList::queue_type>
00063   {
00064   public:
00065     typedef Key key_type;
00066     typedef typename TypeList::head_type value_type;
00067     typedef multi_type_map<Key, TypeList> self_type;
00068     typedef multi_type_map<Key, typename TypeList::queue_type> super;
00069     typedef std::map<key_type, value_type> container_type;
00070 
00071     friend
00072     struct multi_type_map_wrapper< value_type,
00073            multi_type_map<key_type,
00074               TypeList> >::last_call;
00075 
00076   public:
00077     template<typename ValueType>
00078     const ValueType& get( const key_type& k ) const;
00079 
00080     template<typename ValueType>
00081     void set( const key_type& k, const ValueType& v );
00082 
00083     template<typename ValueType>
00084     bool exists( const key_type& k ) const;
00085 
00086   private:
00088     container_type m_data;
00089 
00090   }; // class multi_type_map
00091 
00095   template<typename Key>
00096   class multi_type_map<Key, meta::no_type>
00097   {
00098     // empty class
00099   }; // class multi_type_map
00100 
00101 } // namespace claw
00102 
00103 #include <claw/impl/multi_type_map.tpp>
00104 
00105 #endif // __CLAW_MULTI_TYPE_MAP_HPP__

Generated on Sun Mar 20 2011 for CLAW Library (a C++ Library Absolutely Wonderful) by  doxygen 1.7.1