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