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

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

Addresses #436.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.5 KB
RevLine 
[861]1#ifndef _theplu_yat_utility_type_info_
2#define _theplu_yat_utility_type_info_
3
4// $Id: TypeInfo.h 1486 2008-09-09 21:17:19Z jari $
5
6/*
[1275]7  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
[1437]8  Copyright (C) 2008 Peter Johansson
[861]9
[1437]10  This file is part of the yat library, http://dev.thep.lu.se/yat
[861]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
[1486]14  published by the Free Software Foundation; either version 3 of the
[861]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
31namespace theplu {
32namespace yat {
33namespace 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    */
[966]50    // For convenience we allow implicit conversion from type_info to
51    // TypeInfo.
[861]52    TypeInfo(const std::type_info&);
53
54    /**
[966]55       \return stored type_info
[861]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
[872]78  /**
79     \brief Equality comparison
80     \return true iff underlying std::type_info are equal
81   */ 
[861]82  bool operator==(const TypeInfo&, const TypeInfo&);
[872]83
84  /**
85     \brief Based on operator==
86   */ 
[861]87  bool operator!=(const TypeInfo&, const TypeInfo&);
[872]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   */ 
[861]98  bool operator<=(const TypeInfo&, const TypeInfo&);
[872]99
100  /**
[1437]101     \brief Based on operator <
[872]102   */ 
[861]103  bool operator>(const TypeInfo&, const TypeInfo&);
[872]104
105  /**
[1437]106     \brief Based on operator <=
[872]107   */ 
[861]108  bool operator>=(const TypeInfo&, const TypeInfo&);
109
110}}} // of namespace utility, yat, and theplu
111
112#endif
Note: See TracBrowser for help on using the repository browser.