SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
export_spy_factory.h
Go to the documentation of this file.
1/*
2 © 2015 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_AWARENESS_EXPORT_SPY_FACTORY_H
15#define SIMICS_SYSTEMC_AWARENESS_EXPORT_SPY_FACTORY_H
16
17#if INTC_EXT
18
20
21#include <sysc/intc/communication/sc_export_spy.h>
22#include <tlm>
23
24#include <map>
25#include <vector>
26
27namespace simics {
28namespace systemc {
29namespace awareness {
30
31template <typename IF, typename HANDLER>
32class ExportSpyFactory : public simics::systemc::TraverserInterface {
33 public:
34 typedef typename std::vector<HANDLER *>::iterator handler_iterator;
35 typedef typename std::map<IF*, intc::sc_export_spy<IF> *>::iterator
36 spy_iterator;
37 ExportSpyFactory() {}
38 ExportSpyFactory(const ExportSpyFactory &f) {}
39 ExportSpyFactory &operator = (const ExportSpyFactory &f) {}
40 virtual ~ExportSpyFactory() {
41 for (auto *handler : handlers_)
42 delete handler;
43 for (auto &spy : spies_)
44 delete spy.second;
45 }
46 void applyOn(sc_core::sc_object *sc_object) override {
47 if (sc_core::sc_export<IF> *if_
48 = dynamic_cast<sc_core::sc_export<IF> *>(sc_object)) {
49 intc::sc_export_spy<IF> *spy = new intc::sc_export_spy<IF>(if_);
50 HANDLER *handler = new HANDLER(spy);
51 handlers_.push_back(handler);
52 spy->set_spy_interface(handler);
53 spies_[spy->get_interface()] = spy;
54 }
55 }
56 void done() override {}
57 std::map<IF*, intc::sc_export_spy<IF> *> *get_spies() {
58 return &spies_;
59 }
60
61 private:
62 std::vector<HANDLER *> handlers_;
63 std::map<IF*, intc::sc_export_spy<IF> *> spies_;
64};
65
66} // namespace awareness
67} // namespace systemc
68} // namespace simics
69
70#endif // INTC_EXT
71#endif
Definition: traverser_interface.h:24
Definition: adapter.h:79