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/*
2 © 2020 Intel Corporation
3
4 This software and the related documents are Intel copyrighted materials, and
5 your use of them is governed by the express license under which they were
6 provided to you ("License"). Unless the License provides otherwise, you may
7 not use, modify, copy, publish, distribute, disclose or transmit this software
8 or the related documents without Intel's prior written permission.
9
10 This software and the related documents are provided as is, with no express or
11 implied warranties, other than those that are expressly stated in the License.
12*/
13
14#ifndef SIMICS_SYSTEMC_SIMICS2TLM_GASKET_ADAPTER_H
15#define SIMICS_SYSTEMC_SIMICS2TLM_GASKET_ADAPTER_H
16
21
22#include <set>
23#include <string>
24#include <vector>
25
26#define GASKET_ADAPTER_PORT_CLASS(name, gasket_adapter) \
27class name \
28 : public simics::systemc::simics2tlm::gasket_adapter, \
29 public simics::systemc::simics2tlm::GasketAdapter<name> { \
30 public: \
31 using gasket_adapter::gasket_adapter; \
32 virtual ~name() = default; \
33 simics::systemc::simics2tlm::GasketOwner *gasket_owner() const override {\
34 return gasket_adapter::gasket_owner(); \
35 } \
36};
37
38namespace simics {
39namespace systemc {
40namespace simics2tlm {
41
42template<typename TBase>
43class GasketAdapter : public DescriptionInterface<TBase> {
44 public:
45 virtual ~GasketAdapter() {}
46
47 std::vector<std::string> description(DescriptionType type) override {
49 return {};
50
51 GasketOwner *owner = gasket_owner();
52 auto *multi_owner = dynamic_cast<MultiGasketOwner *>(owner);
53 if (multi_owner) {
54 std::set<int> keys = multi_owner->keys();
55 if (keys.empty())
56 return description(owner->gasket());
57
58 std::vector<std::string> result;
59 for (auto i = keys.begin(); i != keys.end(); ++i) {
60 std::vector<std::string> r =
61 description(multi_owner->findGasket(*i));
62 if (r.empty())
63 continue;
64
65 result.push_back(r[0]);
66 result.push_back(r[1]);
67 }
68
69 return result;
70 }
71
72 if (!owner)
73 return {};
74
75 return description(owner->gasket());
76 }
78
79 protected:
80 void append(std::string *result, std::string s) {
81 if (result->empty()) {
82 *result = s;
83 } else {
84 *result += ';';
85 *result += s;
86 }
87 }
88 std::vector<std::string> description(GasketInterface::Ptr gasket_ptr) {
89 if (!gasket_ptr)
90 return {};
91
92 return {gasket_ptr->gasket_name(),
93 gasket_ptr->get_target_socket()->name()};
94 }
95};
96
97} // namespace simics2tlm
98} // namespace systemc
99} // namespace simics
100
101#endif
Definition: description_interface.h:32
Definition: gasket_adapter.h:43
virtual simics2tlm::GasketOwner * gasket_owner() const =0
void append(std::string *result, std::string s)
Definition: gasket_adapter.h:80
std::vector< std::string > description(DescriptionType type) override
Definition: gasket_adapter.h:47
virtual ~GasketAdapter()
Definition: gasket_adapter.h:45
std::vector< std::string > description(GasketInterface::Ptr gasket_ptr)
Definition: gasket_adapter.h:88
std::shared_ptr< GasketInterface > Ptr
Definition: gasket_interface.h:35
Base class, responsible for handling a gasket.
Definition: gasket_owner.h:30
GasketInterface::Ptr gasket() const
Definition: gasket_owner.h:47
Container class for multiple GasketOwners, each given a unique ID.
Definition: multi_gasket_owner.h:38
std::set< int > keys() const
Definition: multi_gasket_owner.h:73
DescriptionType
Definition: description_interface.h:23
@ DESCRIPTION_TYPE_SIMICS2TLM
Definition: description_interface.h:24
Definition: adapter.h:79