source: trunk/yat/utility/TypeInfo.cc @ 1679

Last change on this file since 1679 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: 1.8 KB
Line 
1// $Id: TypeInfo.cc 1487 2008-09-10 08:41:36Z jari $
2
3/*
4  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
5
6  This file is part of the yat library, http://dev.thep.lu.se/yat
7
8  The yat library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 3 of the
11  License, or (at your option) any later version.
12
13  The yat library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with yat. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "TypeInfo.h"
23
24#include <string>
25#include <typeinfo>
26#include <cassert>
27
28namespace theplu {
29namespace yat {
30namespace utility {
31
32
33  TypeInfo::TypeInfo(void)
34  {}
35
36  TypeInfo::TypeInfo(const std::type_info& info)
37    : info_(&info)
38  {
39    assert(info_);
40  }
41
42 
43  const std::type_info& TypeInfo::get(void) const
44  {
45    assert(info_);
46    return *info_;
47  }
48
49  std::string TypeInfo::name(void) const
50  {
51    assert(info_);
52    return info_->name();
53  }
54
55
56  bool operator==(const TypeInfo& lhs, const TypeInfo& rhs)
57  {
58    return lhs.get()==rhs.get();
59  }
60
61
62  bool operator!=(const TypeInfo& lhs, const TypeInfo& rhs)
63  {
64    return !(lhs.get()==rhs.get());
65  }
66
67  bool operator<(const TypeInfo& lhs, const TypeInfo& rhs)
68  {
69    return lhs.get().before(rhs.get());
70  }
71
72
73  bool operator<=(const TypeInfo& lhs, const TypeInfo& rhs)
74  {
75    return !(lhs>rhs);
76  }
77
78
79  bool operator>(const TypeInfo& lhs, const TypeInfo& rhs)
80  {
81    return rhs<lhs;
82  }
83
84
85  bool operator>=(const TypeInfo& lhs, const TypeInfo& rhs)
86  {
87    return rhs<=lhs;
88  }
89
90}}} // of namespace utility, yat, and theplu
Note: See TracBrowser for help on using the repository browser.