SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
gasket_adapter.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2020 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_SIMICS2TLM_GASKET_ADAPTER_H
17#define SIMICS_SYSTEMC_SIMICS2TLM_GASKET_ADAPTER_H
18
23
24#include <set>
25#include <string>
26#include <vector>
27
28#define GASKET_ADAPTER_PORT_CLASS(name, gasket_adapter) \
29class name \
30 : public simics::systemc::simics2tlm::gasket_adapter, \
31 public simics::systemc::simics2tlm::GasketAdapter<name> { \
32 public: \
33 using gasket_adapter::gasket_adapter; \
34 virtual ~name() = default; \
35 simics::systemc::simics2tlm::GasketOwner *gasket_owner() const override {\
36 return gasket_adapter::gasket_owner(); \
37 } \
38};
39
40namespace simics {
41namespace systemc {
42namespace simics2tlm {
43
44template<typename TBase>
45class GasketAdapter : public DescriptionInterface<TBase> {
46 public:
47 virtual ~GasketAdapter() {}
48
49 std::vector<std::string> description(DescriptionType type) override {
51 return {};
52
53 GasketOwner *owner = gasket_owner();
54 auto *multi_owner = dynamic_cast<MultiGasketOwner *>(owner);
55 if (multi_owner) {
56 std::set<int> keys = multi_owner->keys();
57 if (keys.empty())
58 return description(owner->gasket());
59
60 std::vector<std::string> result;
61 for (auto i = keys.begin(); i != keys.end(); ++i) {
62 std::vector<std::string> r =
63 description(multi_owner->findGasket(*i));
64 if (r.empty())
65 continue;
66
67 result.push_back(r[0]);
68 result.push_back(r[1]);
69 }
70
71 return result;
72 }
73
74 if (!owner)
75 return {};
76
77 return description(owner->gasket());
78 }
80
81 protected:
82 void append(std::string *result, std::string s) {
83 if (result->empty()) {
84 *result = s;
85 } else {
86 *result += ';';
87 *result += s;
88 }
89 }
90 std::vector<std::string> description(GasketInterface::Ptr gasket_ptr) {
91 if (!gasket_ptr)
92 return {};
93
94 return {gasket_ptr->gasket_name(),
95 gasket_ptr->get_target_socket()->name()};
96 }
97};
98
99} // namespace simics2tlm
100} // namespace systemc
101} // namespace simics
102
103#endif
Definition: description_interface.h:34
Definition: gasket_adapter.h:45
virtual simics2tlm::GasketOwner * gasket_owner() const =0
void append(std::string *result, std::string s)
Definition: gasket_adapter.h:82
std::vector< std::string > description(DescriptionType type) override
Definition: gasket_adapter.h:49
virtual ~GasketAdapter()
Definition: gasket_adapter.h:47
std::vector< std::string > description(GasketInterface::Ptr gasket_ptr)
Definition: gasket_adapter.h:90
std::shared_ptr< GasketInterface > Ptr
Definition: gasket_interface.h:37
Base class, responsible for handling a gasket.
Definition: gasket_owner.h:32
GasketInterface::Ptr gasket() const
Definition: gasket_owner.h:46
Container class for multiple GasketOwners, each given a unique ID.
Definition: multi_gasket_owner.h:39
std::set< int > keys() const
Definition: multi_gasket_owner.h:78
DescriptionType
Definition: description_interface.h:25
@ DESCRIPTION_TYPE_SIMICS2TLM
Definition: description_interface.h:26
Definition: pci_bus_interface.h:24