Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 namespace elm {
25 
26 // Id adapter
27 template <class T>
28 class IdAdapter {
29 public:
30  typedef T key_t;
31  typedef T val_t;
32  typedef T data_t;
33  static inline const T& key(const data_t& v) { return v; }
34  static inline const T& value(const data_t& v) { return v; }
35  static inline T& ref(data_t& v) { return v; }
36 };
37 
38 
39 // Pair adapter
40 template <class K, class T>
41 class PairAdapter {
42 public:
43  typedef K key_t;
44  typedef T val_t;
45  typedef Pair<K, T> data_t;
46  static inline const key_t& key(const data_t& v) { return v.fst; }
47  static inline const val_t& value(const data_t& v) { return v.snd; }
48  static inline val_t& ref(data_t& v) { return v.snd; }
49 };
50 
51 } // elm
52 
53 #endif /* ELM_ADAPTER_H_ */
static const T & value(const data_t &v)
Definition: adapter.h:34
static const val_t & value(const data_t &v)
Definition: adapter.h:47
Pair< K, T > data_t
Definition: adapter.h:45
static const T & key(const data_t &v)
Definition: adapter.h:33
K key_t
Definition: adapter.h:43
static T & ref(data_t &v)
Definition: adapter.h:35
T1 fst
Definition: Pair.h:18
static const key_t & key(const data_t &v)
Definition: adapter.h:46
Definition: adapter.h:28
T key_t
Definition: adapter.h:30
Definition: adapter.h:41
T2 snd
Definition: Pair.h:19
T val_t
Definition: adapter.h:44
Definition: Pair.h:16
T val_t
Definition: adapter.h:31
T data_t
Definition: adapter.h:32
static val_t & ref(data_t &v)
Definition: adapter.h:48