multi_type_map.hpp
Go to the documentation of this file.
/*
CLAW - a C++ Library Absolutely Wonderful
CLAW is a free library without any particular aim but being useful to
anyone.
Copyright (C) 2005-2011 Julien Jorge
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
contact: julien.jorge@gamned.org
*/
#ifndef __CLAW_MULTI_TYPE_MAP_HPP__
#define __CLAW_MULTI_TYPE_MAP_HPP__
#include <claw/meta/no_type.hpp>
#include <claw/meta/type_list.hpp>
#include <map>
namespace claw
{
template<typename ValueType, typename Map>
class multi_type_map_wrapper;
template<typename Map>
class multi_type_map_helper;
template<typename Key, typename TypeList>
class multi_type_map;
template<typename Key>
class multi_type_map<Key, meta::no_type>
{
}; // class multi_type_map
template<typename Key, typename Head, typename Tail>
class multi_type_map< Key, meta::type_list<Head, Tail> >:
public multi_type_map<Key, Tail>
{
public:
typedef Key key_type;
typedef Head value_type;
typedef meta::type_list<Head, Tail> value_type_list;
typedef multi_type_map< Key, meta::type_list<Head, Tail> > self_type;
typedef std::map<key_type, value_type> container_type;
typedef multi_type_map<Key, Tail> super;
friend struct multi_type_map_wrapper<value_type, self_type>;
friend struct multi_type_map_helper<self_type>;
template<typename ValueType>
struct iterator
{
typedef typename std::map<key_type, ValueType>::iterator type;
typedef
typename std::map<key_type, ValueType>::const_iterator const_type;
}; // struct iterator
private:
typedef typename iterator<value_type>::type iterator_type;
typedef typename iterator<value_type>::const_type const_iterator_type;
public:
template<typename ValueType>
void erase( typename iterator<ValueType>::type it );
template<typename ValueType>
std::size_t erase( const key_type& k );
template<typename ValueType>
const ValueType& get( const key_type& k ) const;
template<typename ValueType>
ValueType& get( const key_type& k );
template<typename ValueType>
void set( const key_type& k, const ValueType& v );
void set( const self_type& m );
template<typename ValueType>
bool exists( const key_type& k ) const;
std::size_t size() const;
template<typename ValueType>
typename iterator<ValueType>::type begin();
template<typename ValueType>
typename iterator<ValueType>::type end();
template<typename ValueType>
typename iterator<ValueType>::const_type begin() const;
template<typename ValueType>
typename iterator<ValueType>::const_type end() const;
private:
container_type m_data;
}; // class multi_type_map
} // namespace claw
#include <claw/impl/multi_type_map.tpp>
#endif // __CLAW_MULTI_TYPE_MAP_HPP__
claw::multi_type_map_helper
This class provides types and methods to allow the call of methods recursively along the inherintance...
Definition multi_type_map.hpp:68
claw::multi_type_map_wrapper
This class provides types and methods to allow the call of methods for a given type in the inheritanc...
Definition multi_type_map.hpp:60
claw::multi_type_map
This class can associate values of different types to a key.
Definition multi_type_map.hpp:90
claw::meta
Structures for meta-programmation.
Definition claw.hpp:81
claw
This is the main namespace.
Definition algorithm.hpp:34
no_type.hpp
An empty class not considered as a effective type.
claw::meta::type_list
Use this class to make a list of types.
Definition type_list.hpp:60
claw::multi_type_map< Key, meta::type_list< Head, Tail > >::iterator
This structure is used to create an iterator on the values of a given type.
Definition multi_type_map.hpp:124
claw::multi_type_map< Key, meta::type_list< Head, Tail > >::iterator::const_type
std::map< key_type, ValueType >::const_iterator const_type
The type of the const_iterator.
Definition multi_type_map.hpp:130
claw::multi_type_map< Key, meta::type_list< Head, Tail > >::iterator::type
std::map< key_type, ValueType >::iterator type
The type of the iterator.
Definition multi_type_map.hpp:126
type_list.hpp
Template classes for lists of types.