Claw  1.7.3
multi_type_map_visitor.tpp
Go to the documentation of this file.
1 /*
2  CLAW - a C++ Library Absolutely Wonderful
3 
4  CLAW is a free library without any particular aim but being useful to
5  anyone.
6 
7  Copyright (C) 2005-2011 Julien Jorge
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 
23  contact: julien.jorge@gamned.org
24 */
31 namespace claw
32 {
38  template<typename Type>
40  {
41  public:
42  template<typename Key, typename TailType, typename Function>
43  void execute
45  Function f )
46  {
47  typedef claw::meta::type_list<Type, TailType> type_list_type;
48  typedef multi_type_map<Key, type_list_type> map_type;
49  typedef typename map_type::template iterator<Type>::type iterator_type;
50 
51  iterator_type it( m.template begin<Type>() );
52  const iterator_type eit( m.template end<Type>() );
53 
54  while ( it!=eit )
55  {
56  iterator_type current(it);
57  ++it;
58  f(current->first, current->second);
59  }
60  } // execute()
61 
62  }; // class multi_type_map_visitor_process
63 
69  template<typename Key, typename TypeList>
71 
76  template<typename Key>
78  {
79  public:
80  template<typename Function>
81  void execute( multi_type_map<Key, claw::meta::no_type>& vars, Function f )
82  {
83  // nothing to do.
84  } // execute()
85 
86  }; // class multi_type_map_visitor
87 
93  template<typename KeyType, typename HeadType, typename TailType>
95  < KeyType, claw::meta::type_list<HeadType, TailType> >
96  {
97  public:
98  template<typename Function>
99  void execute
101  Function f )
102  {
105 
106  process.execute( m, f );
107  rec_call.execute( m, f );
108  } // execute()
109 
110  }; // class multi_type_map_visitor_rec
111 
112 } // namespce claw
113 
114 /*----------------------------------------------------------------------------*/
120 template<typename Key, typename TypeList, typename Function>
122 ( multi_type_map<Key, TypeList>& m, Function f ) const
123 {
125  rec_call.execute( m, f );
126 } // multi_type_map_visitor::run()
This class can associate values of different types to a key.
void run(multi_type_map< Key, TypeList > &m, Function f) const
Execute the visitor.
Use this class to make a list of types.
Definition: type_list.hpp:59
This class goes through all entries of a given type in a multi_type_map and apply a function to them...
This class goes through all entries in a multi_type_map and apply a function to them.
Empty type.
Definition: no_type.hpp:40