SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_typeindex.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements. See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied. See the License for the specific language governing
16  permissions and limitations under the License.
17 
18  *****************************************************************************/
19 
20 /*****************************************************************************
21 
22  sc_typeindex.h -- Wrapper around std::typeinfo to allow usage in containers
23 */
35 #ifndef SYSC_UTILS_SC_TYPEINDEX_H_INCLUDED_
36 #define SYSC_UTILS_SC_TYPEINDEX_H_INCLUDED_
37 
38 #include "sysc/kernel/sc_cmnhdr.h" // SC_CPLUSPLUS
39 
40 #include <typeinfo>
41 
42 #if SC_CPLUSPLUS >= 201103L
43 #include <typeindex> // C++11 has std::typeindex to serve our needs
44 
45 namespace sc_core {
46 typedef std::type_index sc_type_index;
47 } // namespace sc_core
48 
49 #else // C++03 implementation
50 
51 namespace sc_core {
52 
54 {
55 public:
56  sc_type_index(const std::type_info& ti)
57  : info_(&ti)
58  {}
59 
60  bool operator==( const sc_type_index& rhs ) const
61  { return *info_ == *rhs.info_; }
62 
63  bool operator!=( const sc_type_index& rhs ) const
64  { return *info_ != *rhs.info_; }
65 
66  bool operator< ( const sc_type_index& rhs ) const
67  { return info_->before( *rhs.info_ ); }
68 
69  bool operator<=( const sc_type_index& rhs ) const
70  { return !(*this > rhs); }
71 
72  bool operator> ( const sc_type_index& rhs ) const
73  { return rhs.info_->before( *info_ ); }
74 
75  bool operator>=( const sc_type_index& rhs ) const
76  { return !(*this < rhs); }
77 
78  const char* name() const
79  { return info_->name(); }
80 
81 private:
82  std::type_info const* info_;
83 
84 }; // class sc_type_index
85 
86 } // namespace sc_core
87 
88 #endif // SC_CPLUSPLUS < 201103L
89 #endif // SYSC_UTILS_SC_TYPEINDEX_H_INCLUDED_
90 // Taf!
bool operator!=(const sc_type_index &rhs) const
Definition: sc_typeindex.h:63
bool operator<=(const sc_type_index &rhs) const
Definition: sc_typeindex.h:69
bool operator==(const sc_type_index &rhs) const
Definition: sc_typeindex.h:60
bool operator>=(const sc_type_index &rhs) const
Definition: sc_typeindex.h:75
bool operator<(const sc_type_index &rhs) const
Definition: sc_typeindex.h:66
const char * name() const
Definition: sc_typeindex.h:78
sc_type_index(const std::type_info &ti)
Definition: sc_typeindex.h:56
bool operator>(const sc_type_index &rhs) const
Definition: sc_typeindex.h:72