1 | #ifndef _theplu_yat_utility_type_info_ |
---|
2 | #define _theplu_yat_utility_type_info_ |
---|
3 | |
---|
4 | // $Id: TypeInfo.h 1887 2009-03-31 17:38:16Z peter $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson |
---|
8 | Copyright (C) 2009 Peter Johansson |
---|
9 | |
---|
10 | This file is part of the yat library, http://dev.thep.lu.se/yat |
---|
11 | |
---|
12 | The yat library is free software; you can redistribute it and/or |
---|
13 | modify it under the terms of the GNU General Public License as |
---|
14 | published by the Free Software Foundation; either version 3 of the |
---|
15 | License, or (at your option) any later version. |
---|
16 | |
---|
17 | The yat library is distributed in the hope that it will be useful, |
---|
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
20 | General Public License for more details. |
---|
21 | |
---|
22 | You should have received a copy of the GNU General Public License |
---|
23 | along with yat. If not, see <http://www.gnu.org/licenses/>. |
---|
24 | */ |
---|
25 | |
---|
26 | #include <string> |
---|
27 | #include <typeinfo> |
---|
28 | |
---|
29 | namespace theplu { |
---|
30 | namespace yat { |
---|
31 | namespace utility { |
---|
32 | |
---|
33 | /** |
---|
34 | @brief Wrapper class for storing std::type_info |
---|
35 | */ |
---|
36 | class TypeInfo |
---|
37 | { |
---|
38 | public: |
---|
39 | /** |
---|
40 | @brief Constructor |
---|
41 | */ |
---|
42 | // For STL container usage |
---|
43 | TypeInfo(void); |
---|
44 | |
---|
45 | /** |
---|
46 | @brief Constructor |
---|
47 | */ |
---|
48 | // For convenience we allow implicit conversion from type_info to |
---|
49 | // TypeInfo. |
---|
50 | TypeInfo(const std::type_info&); |
---|
51 | |
---|
52 | /** |
---|
53 | \return stored type_info |
---|
54 | */ |
---|
55 | const std::type_info& get(void) const; |
---|
56 | |
---|
57 | /** |
---|
58 | \return name of type |
---|
59 | */ |
---|
60 | std::string name(void) const; |
---|
61 | |
---|
62 | /** |
---|
63 | @brief assignment operator |
---|
64 | */ |
---|
65 | TypeInfo& operator=(const TypeInfo&); |
---|
66 | |
---|
67 | private: |
---|
68 | // Using compiler generated copy constructor |
---|
69 | // TypeInfo(const TypeInfo&); |
---|
70 | // Using compiler generated assignment operator |
---|
71 | // TypeInfo(const TypeInfo&); |
---|
72 | |
---|
73 | const std::type_info* info_; |
---|
74 | }; |
---|
75 | |
---|
76 | /** |
---|
77 | \brief Equality comparison |
---|
78 | \return true iff underlying std::type_info are equal |
---|
79 | |
---|
80 | \relates TypeInfo |
---|
81 | */ |
---|
82 | bool operator==(const TypeInfo&, const TypeInfo&); |
---|
83 | |
---|
84 | /** |
---|
85 | \brief Based on operator== |
---|
86 | |
---|
87 | \relates TypeInfo |
---|
88 | */ |
---|
89 | bool operator!=(const TypeInfo&, const TypeInfo&); |
---|
90 | |
---|
91 | /** |
---|
92 | \brief Ordering relation |
---|
93 | \return true iff underlying lhs.get()<rhs.get() |
---|
94 | |
---|
95 | \relates TypeInfo |
---|
96 | */ |
---|
97 | bool operator<(const TypeInfo& lhs, const TypeInfo& rhs); |
---|
98 | |
---|
99 | /** |
---|
100 | \brief Based on operators == and < |
---|
101 | |
---|
102 | \relates TypeInfo |
---|
103 | */ |
---|
104 | bool operator<=(const TypeInfo&, const TypeInfo&); |
---|
105 | |
---|
106 | /** |
---|
107 | \brief Based on operator < |
---|
108 | |
---|
109 | \relates TypeInfo |
---|
110 | */ |
---|
111 | bool operator>(const TypeInfo&, const TypeInfo&); |
---|
112 | |
---|
113 | /** |
---|
114 | \brief Based on operator <= |
---|
115 | |
---|
116 | \relates TypeInfo |
---|
117 | */ |
---|
118 | bool operator>=(const TypeInfo&, const TypeInfo&); |
---|
119 | |
---|
120 | }}} // of namespace utility, yat, and theplu |
---|
121 | |
---|
122 | #endif |
---|