SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
tool_controller.h
Go to the documentation of this file.
1/*
2 © 2016 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_INSTRUMENTATION_TOOL_CONTROLLER_H
15#define SIMICS_SYSTEMC_INSTRUMENTATION_TOOL_CONTROLLER_H
16
17#if defined(_MSC_VER)
18 /* The decorated name was longer than the compiler limit (4096),
19 and was truncated. */
20#pragma warning(disable:4503)
21#endif
22
23#include <simics/cc-api.h>
26#include <simics/simulator-iface/instrumentation-tool.h>
27
28#include <functional>
29#include <utility>
30#include <vector>
31
32// NOTE: this macro is internal and should not be directly invoked from outside
33// of this header
34#define internal_DISPATCH_TOOL_CHAIN_NONNULL(controller, iface_type, func, ...)\
35do { \
36 for (auto c : controller->get_connections()) { \
37 if (!c->enabled()) \
38 continue; \
39 auto iface = c->template get_interface<iface_type>(); \
40 if (!iface) \
41 continue; \
42 auto functions = c->functions(); \
43 if (!functions.empty()) { \
44 auto f = std::find(functions.begin(), functions.end(), #func); \
45 if (f == functions.end()) \
46 continue; \
47 } \
48 iface->func(__VA_ARGS__); \
49 } \
50} while (0)
51
52#define DISPATCH_TOOL_CHAIN(controller, iface_type, func, ...) \
53do { \
54 namespace ssi = simics::systemc::instrumentation; \
55 using state_t = ssi::ToolController::ConnectionListState; \
56 if (controller \
57 && controller->get_connections_state() != state_t::EMPTY) \
58 internal_DISPATCH_TOOL_CHAIN_NONNULL(controller, iface_type, \
59 func, ##__VA_ARGS__); \
60} while (0)
61
62#define DISPATCH_TOOL_CHAIN_THIS(iface_type, func, ...) \
63 internal_DISPATCH_TOOL_CHAIN_NONNULL(this, iface_type, func, \
64 ##__VA_ARGS__);
65
66namespace simics {
67namespace systemc {
68namespace instrumentation {
69
73 public:
75 EMPTY = 0,
78 };
79
81 public:
82 virtual void tool_controller_init(ToolController *controller) = 0;
84 virtual ~CallbackInterface() {}
85 };
86
88 explicit ToolController(CallbackInterface *callback);
89 bool insert(ToolConnectionInterface *connection, int pos) override;
90 void remove(ToolConnectionInterface *connection) override;
91 const std::vector<ToolConnectionInterface *> &get_connections() const {
92 return connections_;
93 }
95 return state_;
96 }
97
98 private:
99 std::vector<ToolConnectionInterface *> connections_;
100 bool init_done_;
101 CallbackInterface *callback_;
102 ConnectionListState state_;
103};
104
105} // namespace instrumentation
106} // namespace systemc
107} // namespace simics
108
109#endif
Definition: provider_controller_interface.h:30
Definition: tool_connection_interface.h:27
virtual void connection_list_updated(ConnectionListState state)=0
virtual ~CallbackInterface()
Definition: tool_controller.h:84
virtual void tool_controller_init(ToolController *controller)=0
Definition: tool_controller.h:72
ToolController(CallbackInterface *callback)
ConnectionListState get_connections_state() const
Definition: tool_controller.h:94
void remove(ToolConnectionInterface *connection) override
ConnectionListState
Definition: tool_controller.h:74
@ ONE_OR_MORE_ELEMENTS
Definition: tool_controller.h:77
@ EMPTY
Definition: tool_controller.h:75
@ FIRST_ELEMENT_ADDED
Definition: tool_controller.h:76
bool insert(ToolConnectionInterface *connection, int pos) override
const std::vector< ToolConnectionInterface * > & get_connections() const
Definition: tool_controller.h:91
Definition: adapter.h:79