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

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

trac moved to new location.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1// $Id: TypeInfo.cc 1000 2007-12-23 20:09:15Z jari $
2
3/*
4  Copyright (C) 2007 Peter Johansson
5
6  This file is part of the yat library, http://trac.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 2 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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#include "TypeInfo.h"
25
26#include <string>
27#include <typeinfo>
28#include <cassert>
29
30namespace theplu {
31namespace yat {
32namespace utility {
33
34
35  TypeInfo::TypeInfo(void)
36  {}
37
38  TypeInfo::TypeInfo(const std::type_info& info)
39    : info_(&info)
40  {
41    assert(info_);
42  }
43
44 
45  const std::type_info& TypeInfo::get(void) const
46  {
47    assert(info_);
48    return *info_;
49  }
50
51  std::string TypeInfo::name(void) const
52  {
53    assert(info_);
54    return info_->name();
55  }
56
57
58  bool operator==(const TypeInfo& lhs, const TypeInfo& rhs)
59  {
60    return lhs.get()==rhs.get();
61  }
62
63
64  bool operator!=(const TypeInfo& lhs, const TypeInfo& rhs)
65  {
66    return !(lhs.get()==rhs.get());
67  }
68
69  bool operator<(const TypeInfo& lhs, const TypeInfo& rhs)
70  {
71    return lhs.get().before(rhs.get());
72  }
73
74
75  bool operator<=(const TypeInfo& lhs, const TypeInfo& rhs)
76  {
77    return !(lhs>rhs);
78  }
79
80
81  bool operator>(const TypeInfo& lhs, const TypeInfo& rhs)
82  {
83    return rhs<lhs;
84  }
85
86
87  bool operator>=(const TypeInfo& lhs, const TypeInfo& rhs)
88  {
89    return rhs<=lhs;
90  }
91
92}}} // of namespace utility, yat, and theplu
Note: See TracBrowser for help on using the repository browser.