1 | #ifndef _theplu_yat_utility_type_info_ |
---|
2 | #define _theplu_yat_utility_type_info_ |
---|
3 | |
---|
4 | // $Id: TypeInfo.h 1333 2008-05-31 21:46:02Z peter $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2007 Jari Häkkinen, Peter Johansson |
---|
8 | Copyright (C) 2008 Peter Johansson |
---|
9 | |
---|
10 | This file is part of the yat library, http://trac.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 2 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 this program; if not, write to the Free Software |
---|
24 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
25 | 02111-1307, USA. |
---|
26 | */ |
---|
27 | |
---|
28 | #include <string> |
---|
29 | #include <typeinfo> |
---|
30 | |
---|
31 | namespace theplu { |
---|
32 | namespace yat { |
---|
33 | namespace utility { |
---|
34 | |
---|
35 | /** |
---|
36 | @brief Wrapper class for storing std::type_info |
---|
37 | */ |
---|
38 | class TypeInfo |
---|
39 | { |
---|
40 | public: |
---|
41 | /** |
---|
42 | @brief Constructor |
---|
43 | */ |
---|
44 | // For STL container usage |
---|
45 | TypeInfo(void); |
---|
46 | |
---|
47 | /** |
---|
48 | @brief Constructor |
---|
49 | */ |
---|
50 | // For convenience we allow implicit conversion from type_info to |
---|
51 | // TypeInfo. |
---|
52 | TypeInfo(const std::type_info&); |
---|
53 | |
---|
54 | /** |
---|
55 | \return stored type_info |
---|
56 | */ |
---|
57 | const std::type_info& get(void) const; |
---|
58 | |
---|
59 | /** |
---|
60 | \return name of type |
---|
61 | */ |
---|
62 | std::string name(void) const; |
---|
63 | |
---|
64 | /** |
---|
65 | @brief assignment operator |
---|
66 | */ |
---|
67 | TypeInfo& operator=(const TypeInfo&); |
---|
68 | |
---|
69 | private: |
---|
70 | // Using compiler generated copy constructor |
---|
71 | // TypeInfo(const TypeInfo&); |
---|
72 | // Using compiler generated assignment operator |
---|
73 | // TypeInfo(const TypeInfo&); |
---|
74 | |
---|
75 | const std::type_info* info_; |
---|
76 | }; |
---|
77 | |
---|
78 | /** |
---|
79 | \brief Equality comparison |
---|
80 | \return true iff underlying std::type_info are equal |
---|
81 | */ |
---|
82 | bool operator==(const TypeInfo&, const TypeInfo&); |
---|
83 | |
---|
84 | /** |
---|
85 | \brief Based on operator== |
---|
86 | */ |
---|
87 | bool operator!=(const TypeInfo&, const TypeInfo&); |
---|
88 | |
---|
89 | /** |
---|
90 | \brief Ordering relation |
---|
91 | \return true iff underlying lhs.get()<rhs.get() |
---|
92 | */ |
---|
93 | bool operator<(const TypeInfo& lhs, const TypeInfo& rhs); |
---|
94 | |
---|
95 | /** |
---|
96 | \brief Based on operators == and < |
---|
97 | */ |
---|
98 | bool operator<=(const TypeInfo&, const TypeInfo&); |
---|
99 | |
---|
100 | /** |
---|
101 | \brief Based on operator < |
---|
102 | */ |
---|
103 | bool operator>(const TypeInfo&, const TypeInfo&); |
---|
104 | |
---|
105 | /** |
---|
106 | \brief Based on operator <= |
---|
107 | */ |
---|
108 | bool operator>=(const TypeInfo&, const TypeInfo&); |
---|
109 | |
---|
110 | }}} // of namespace utility, yat, and theplu |
---|
111 | |
---|
112 | #endif |
---|