source: branches/0.4-stable/yat/utility/TypeInfo.h @ 1322

Last change on this file since 1322 was 1322, checked in by Peter, 13 years ago

corrected docs

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