SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
tlm_spy_factory_registry.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_TLM_SPY_FACTORY_REGISTRY_H
17#define SIMICS_SYSTEMC_AWARENESS_TLM_SPY_FACTORY_REGISTRY_H
18#if INTC_EXT
19
20#include <tlm>
21
24
25#include <vector>
26
27namespace simics {
28namespace systemc {
29namespace awareness {
30
31class TlmSpyFactoryRegistry : public MultiTraverser {
32 public:
33 TlmSpyFactoryRegistry() {
34 }
35 TlmSpyFactoryRegistry(const TlmSpyFactoryRegistry &r) {
36 deepCopy(r);
37 }
38 TlmSpyFactoryRegistry &operator=(const TlmSpyFactoryRegistry &r) {
39 // coverity[assign_indirectly_returning_star_this]
40 return deepCopy(r);
41 }
42 virtual ~TlmSpyFactoryRegistry() {
43 std::vector<TraverserInterface *>::iterator i;
44 for (i = traversers_.begin(); i != traversers_.end(); ++i)
45 delete *i;
46 }
47 template <typename TYPES>
48 void createSpyFactory() {
49 TlmSpyFactory<TYPES> *factory = NULL;
50 std::vector<TraverserInterface *>::iterator i;
51 for (i = traversers_.begin(); i != traversers_.end(); ++i) {
52 factory = dynamic_cast<TlmSpyFactory<TYPES> *>(*i);
53 if (factory)
54 return;
55 }
56
57 add(new TlmSpyFactory<TYPES>());
58 }
59
60 private:
61 TlmSpyFactoryRegistry &deepCopy(const TlmSpyFactoryRegistry &r) {
62 if (&r == this)
63 return *this;
64
65 std::vector<TraverserInterface *>::const_iterator i;
66 for (i = r.traversers_.begin(); i != r.traversers_.end(); ++i) {
67 TlmSpyFactoryInterface *f =
68 dynamic_cast<TlmSpyFactoryInterface *>(*i);
69 if (f)
70 add(f->create()->traverser());
71 }
72
73 return *this;
74 }
75};
76
77} // namespace awareness
78} // namespace systemc
79} // namespace simics
80
81#endif // INTC_EXT
82#endif
Definition: pci_bus_interface.h:24