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/*
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_TLM_SPY_FACTORY_REGISTRY_H
15#define SIMICS_SYSTEMC_AWARENESS_TLM_SPY_FACTORY_REGISTRY_H
16#if INTC_EXT
17
18#include <tlm>
19
22
23#include <vector>
24
25namespace simics {
26namespace systemc {
27namespace awareness {
28
29class TlmSpyFactoryRegistry : public MultiTraverser {
30 public:
31 TlmSpyFactoryRegistry() {
32 }
33 TlmSpyFactoryRegistry(const TlmSpyFactoryRegistry &r) {
34 deepCopy(r);
35 }
36 TlmSpyFactoryRegistry &operator=(const TlmSpyFactoryRegistry &r) {
37 // coverity[assign_indirectly_returning_star_this]
38 return deepCopy(r);
39 }
40 virtual ~TlmSpyFactoryRegistry() {
41 for (auto *traverser : traversers_)
42 delete traverser;
43 }
44 template <typename TYPES>
45 void createSpyFactory() {
46 for (auto *traverser : traversers_) {
47 if (dynamic_cast<TlmSpyFactory<TYPES> *>(traverser))
48 return;
49 }
50
51 add(new TlmSpyFactory<TYPES>());
52 }
53
54 private:
55 TlmSpyFactoryRegistry &deepCopy(const TlmSpyFactoryRegistry &r) {
56 if (&r == this)
57 return *this;
58
59 for (auto *traverser : r.traversers_) {
60 TlmSpyFactoryInterface *f =
61 dynamic_cast<TlmSpyFactoryInterface *>(traverser);
62 if (f)
63 add(f->create()->traverser());
64 }
65
66 return *this;
67 }
68};
69
70} // namespace awareness
71} // namespace systemc
72} // namespace simics
73
74#endif // INTC_EXT
75#endif
Definition: adapter.h:79