SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
class_type.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2016 Intel Corporation
5
6 This software and the related documents are Intel copyrighted materials, and
7 your use of them is governed by the express license under which they were
8 provided to you ("License"). Unless the License provides otherwise, you may
9 not use, modify, copy, publish, distribute, disclose or transmit this software
10 or the related documents without Intel's prior written permission.
11
12 This software and the related documents are provided as is, with no express or
13 implied warranties, other than those that are expressly stated in the License.
14*/
15
16#ifndef SIMICS_SYSTEMC_CLASS_TYPE_H
17#define SIMICS_SYSTEMC_CLASS_TYPE_H
18
19#include <string>
20#include <typeinfo>
21
22namespace simics {
23namespace systemc {
24
25class ClassType {
26 public:
27 ClassType() { implementor_ = this; }
28 std::string type() const {
29 return type_;
30 }
31 bool operator ==(const ClassType &type) const {
32 return type_ == type.type_;
33 }
34 bool operator !=(const ClassType &type) const {
35 return type_ != type.type_;
36 }
37 bool operator <(const ClassType &type) const {
38 return type_ < type.type_;
39 }
40 template<class T>
42 return dynamic_cast<T *>(implementor_);
43 }
44 template<class T>
47 type.type_ = typeid(T).name();
48 return type;
49 }
50 virtual ~ClassType() {}
51
52 protected:
53 void set_type() {
54 type_ = typeid(*this).name();
55 }
56 std::string type_;
58};
59
60} // namespace systemc
61} // namespace simics
62
63#endif
Definition: class_type.h:25
ClassType()
Definition: class_type.h:27
static ClassType typeForClass()
Definition: class_type.h:45
bool operator!=(const ClassType &type) const
Definition: class_type.h:34
virtual ~ClassType()
Definition: class_type.h:50
std::string type_
Definition: class_type.h:56
bool operator<(const ClassType &type) const
Definition: class_type.h:37
void set_type()
Definition: class_type.h:53
T * get_interface()
Definition: class_type.h:41
ClassType * implementor_
Definition: class_type.h:57
bool operator==(const ClassType &type) const
Definition: class_type.h:31
std::string type() const
Definition: class_type.h:28
Definition: pci_bus_interface.h:24