scc  2022.4.0
SystemC components library
tlm_extension_recording_registry.h
1 /*******************************************************************************
2  * Copyright 2016, 2020 MINRES Technologies GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *******************************************************************************/
16 
17 #ifndef TLM_RECORDER_REGISTRY_H_
18 #define TLM_RECORDER_REGISTRY_H_
19 
20 #ifdef HAS_SCV
21 #include <scv.h>
22 #ifndef SCVNS
23 #define SCVNS
24 #endif
25 #else
26 #include <scv-tr.h>
27 #ifndef SCVNS
28 #define SCVNS ::scv_tr::
29 #endif
30 #endif
31 #include <tlm>
32 
34 namespace tlm {
36 namespace scc {
38 namespace scv {
45 template <typename TYPES = tlm::tlm_base_protocol_types> class tlm_extensions_recording_if {
46 public:
51  virtual void recordBeginTx(SCVNS scv_tr_handle& handle, typename TYPES::tlm_payload_type& trans) = 0;
52 
57  virtual void recordEndTx(SCVNS scv_tr_handle& handle, typename TYPES::tlm_payload_type& trans) = 0;
58 
59  virtual ~tlm_extensions_recording_if() = default;
60 };
61 
68 template <typename TYPES = tlm::tlm_base_protocol_types> class tlm_extension_recording_registry {
69 public:
70  static tlm_extension_recording_registry& inst() {
72  return reg;
73  }
74 
75  void register_ext_rec(size_t id, tlm_extensions_recording_if<TYPES>* ext) {
76  if(id == 0)
77  return;
78  if(id >= ext_rec.size())
79  ext_rec.resize(id + 1);
80  if(ext_rec[id])
81  delete ext_rec[id];
82  ext_rec[id] = ext;
83  }
84 
85  const std::vector<tlm_extensions_recording_if<TYPES>*>& get() { return ext_rec; }
86 
87  inline void recordBeginTx(size_t id, SCVNS scv_tr_handle& handle, typename TYPES::tlm_payload_type& trans) {
88  if(ext_rec.size() > id && ext_rec[id])
89  ext_rec[id]->recordBeginTx(handle, trans);
90  }
91 
96  inline void recordEndTx(size_t id, SCVNS scv_tr_handle& handle, typename TYPES::tlm_payload_type& trans) {
97  if(ext_rec.size() > id && ext_rec[id])
98  ext_rec[id]->recordEndTx(handle, trans);
99  }
100 
101 private:
104  for(auto& ext : ext_rec)
105  delete(ext);
106  }
107  std::vector<tlm_extensions_recording_if<TYPES>*> ext_rec{};
108 };
109 
110 } // namespace scv
111 } // namespace scc
112 } // namespace tlm
113 #endif /* TLM_RECORDER_REGISTRY_H_ */
The TLM transaction extensions recorder registry.
void recordEndTx(size_t id, SCVNS scv_tr_handle &handle, typename TYPES::tlm_payload_type &trans)
recording attributes in extensions at the end, it is intended to be overload as it does nothing
The TLM transaction extensions recorder interface.
virtual void recordEndTx(SCVNS scv_tr_handle &handle, typename TYPES::tlm_payload_type &trans)=0
recording attributes in extensions at the end, it is intended to be overload as it does nothing
virtual void recordBeginTx(SCVNS scv_tr_handle &handle, typename TYPES::tlm_payload_type &trans)=0
recording attributes in extensions at the beginning, it is intended to be overload as it does nothing
SCC SystemC utilities.
SystemC TLM.