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

Last change on this file since 1797 was 1797, checked in by Peter, 15 years ago

updating copyright statements

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