source: trunk/yat/utility/TypeInfo.h @ 1566

Last change on this file since 1566 was 1487, checked in by Jari Häkkinen, 13 years ago

Addresses #436. GPL license copy reference should also be updated.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1#ifndef _theplu_yat_utility_type_info_
2#define _theplu_yat_utility_type_info_
3
4// $Id: TypeInfo.h 1487 2008-09-10 08:41:36Z jari $
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://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
29namespace theplu {
30namespace yat {
31namespace 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  bool operator==(const TypeInfo&, const TypeInfo&);
81
82  /**
83     \brief Based on operator==
84   */ 
85  bool operator!=(const TypeInfo&, const TypeInfo&);
86
87  /**
88     \brief Ordering relation
89     \return true iff underlying lhs.get()<rhs.get()
90   */ 
91  bool operator<(const TypeInfo& lhs, const TypeInfo& rhs);
92
93  /**
94     \brief Based on operators == and <
95   */ 
96  bool operator<=(const TypeInfo&, const TypeInfo&);
97
98  /**
99     \brief Based on operator <
100   */ 
101  bool operator>(const TypeInfo&, const TypeInfo&);
102
103  /**
104     \brief Based on operator <=
105   */ 
106  bool operator>=(const TypeInfo&, const TypeInfo&);
107
108}}} // of namespace utility, yat, and theplu
109
110#endif
Note: See TracBrowser for help on using the repository browser.