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// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2015 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_AWARENESS_EXPORT_SPY_FACTORY_H
17#define SIMICS_SYSTEMC_AWARENESS_EXPORT_SPY_FACTORY_H
18
19#if INTC_EXT
20
22
23#include <sysc/intc/communication/sc_export_spy.h>
24#include <tlm>
25
26#include <map>
27#include <vector>
28
29namespace simics {
30namespace systemc {
31namespace awareness {
32
33template <typename IF, typename HANDLER>
34class ExportSpyFactory : public simics::systemc::TraverserInterface {
35 public:
36 typedef typename std::vector<HANDLER *>::iterator handler_iterator;
37 typedef typename std::map<IF*, intc::sc_export_spy<IF> *>::iterator
38 spy_iterator;
39 ExportSpyFactory() {}
40 ExportSpyFactory(const ExportSpyFactory &f) {}
41 ExportSpyFactory &operator = (const ExportSpyFactory &f) {}
42 virtual ~ExportSpyFactory() {
43 for (handler_iterator i = handlers_.begin(); i != handlers_.end(); ++i)
44 delete *i;
45 for (spy_iterator i = spies_.begin(); i != spies_.end(); ++i)
46 delete i->second;
47 }
48 virtual void applyOn(sc_core::sc_object *sc_object) {
49 if (sc_core::sc_export<IF> *if_
50 = dynamic_cast<sc_core::sc_export<IF> *>(sc_object)) {
51 intc::sc_export_spy<IF> *spy = new intc::sc_export_spy<IF>(if_);
52 HANDLER *handler = new HANDLER(spy);
53 handlers_.push_back(handler);
54 spy->set_spy_interface(handler);
55 spies_[spy->get_interface()] = spy;
56 }
57 }
58 virtual void done() {}
59 std::map<IF*, intc::sc_export_spy<IF> *> *get_spies() {
60 return &spies_;
61 }
62
63 private:
64 std::vector<HANDLER *> handlers_;
65 std::map<IF*, intc::sc_export_spy<IF> *> spies_;
66};
67
68} // namespace awareness
69} // namespace systemc
70} // namespace simics
71
72#endif // INTC_EXT
73#endif
Definition: traverser_interface.h:26
Definition: pci_bus_interface.h:24