Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
adapter.h
1 /*
2  * adapter module interface
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2008, IRIT UPS.
6  *
7  * OTAWA is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * OTAWA is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OTAWA; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 #ifndef ELM_ADAPTER_H_
22 #define ELM_ADAPTER_H_
23 
24 #include <elm/util/Pair.h>
25 
26 namespace elm {
27 
28 // Id adapter
29 template <class T>
30 class IdAdapter {
31 public:
32  typedef T key_t;
33  typedef T val_t;
34  typedef T data_t;
35  static inline const T& key(const data_t& v) { return v; }
36  static inline const T& value(const data_t& v) { return v; }
37  static inline T& ref(data_t& v) { return v; }
38 };
39 
40 
41 // Pair adapter
42 template <class K, class T>
43 class PairAdapter {
44 public:
45  typedef K key_t;
46  typedef T val_t;
47  typedef Pair<K, T> data_t;
48  static inline const key_t& key(const data_t& v) { return v.fst; }
49  static inline const val_t& value(const data_t& v) { return v.snd; }
50  static inline val_t& ref(data_t& v) { return v.snd; }
51 };
52 
53 } // elm
54 
55 #endif /* ELM_ADAPTER_H_ */
elm::PairAdapter::data_t
Pair< K, T > data_t
Definition: adapter.h:47
elm::IdAdapter::key
static const T & key(const data_t &v)
Definition: adapter.h:35
elm::Pair::snd
T2 snd
Definition: Pair.h:36
elm::Pair< K, T >
elm::IdAdapter::data_t
T data_t
Definition: adapter.h:34
elm::PairAdapter::key
static const key_t & key(const data_t &v)
Definition: adapter.h:48
elm
Definition: adapter.h:26
elm::PairAdapter
Definition: adapter.h:43
elm::IdAdapter::val_t
T val_t
Definition: adapter.h:33
elm::PairAdapter::ref
static val_t & ref(data_t &v)
Definition: adapter.h:50
elm::IdAdapter
Definition: adapter.h:30
elm::IdAdapter::ref
static T & ref(data_t &v)
Definition: adapter.h:37
elm::IdAdapter::value
static const T & value(const data_t &v)
Definition: adapter.h:36
elm::IdAdapter::key_t
T key_t
Definition: adapter.h:32
elm::PairAdapter::key_t
K key_t
Definition: adapter.h:45
elm::PairAdapter::value
static const val_t & value(const data_t &v)
Definition: adapter.h:49
elm::Pair::fst
T1 fst
Definition: Pair.h:35
elm::PairAdapter::val_t
T val_t
Definition: adapter.h:46