scc  2022.4.0
SystemC components library
lwtr4tlm2_extension_registry.h
1 /*******************************************************************************
2  * Copyright 2022 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_SCC_LWTR_LWTR4TLM2_EXTENSION__REGISTRY_H
18 #define _TLM_SCC_LWTR_LWTR4TLM2_EXTENSION__REGISTRY_H
19 
20 #include "lwtr4tlm2.h"
21 
23 namespace tlm {
25 namespace scc {
27 namespace lwtr {
34 template <typename TYPES = tlm::tlm_base_protocol_types> class lwtr4tlm2_extension_registry_if {
35 public:
40  virtual void recordBeginTx(::lwtr::tx_handle& handle, typename TYPES::tlm_payload_type& trans) = 0;
41 
46  virtual void recordEndTx(::lwtr::tx_handle& handle, typename TYPES::tlm_payload_type& trans) = 0;
47 
48  virtual ~lwtr4tlm2_extension_registry_if() = default;
49 };
50 
57 template <typename TYPES = tlm::tlm_base_protocol_types> class lwtr4tlm2_extension_registry {
58 public:
59  static lwtr4tlm2_extension_registry& inst() {
61  return reg;
62  }
63 
64  void register_ext_rec(size_t id, lwtr4tlm2_extension_registry_if<TYPES>* ext) {
65  if(id == 0)
66  return;
67  if(id >= ext_rec.size())
68  ext_rec.resize(id + 1);
69  if(ext_rec[id])
70  delete ext_rec[id];
71  ext_rec[id] = ext;
72  }
73 
74  const std::vector<lwtr4tlm2_extension_registry_if<TYPES>*>& get() { return ext_rec; }
75 
76  inline void recordBeginTx(size_t id, ::lwtr::tx_handle& handle, typename TYPES::tlm_payload_type& trans) {
77  if(ext_rec.size() > id && ext_rec[id])
78  ext_rec[id]->recordBeginTx(handle, trans);
79  }
80 
85  inline void recordEndTx(size_t id, ::lwtr::tx_handle& handle, typename TYPES::tlm_payload_type& trans) {
86  if(ext_rec.size() > id && ext_rec[id])
87  ext_rec[id]->recordEndTx(handle, trans);
88  }
89 
90 private:
91  lwtr4tlm2_extension_registry() = default;
93  for(auto& ext : ext_rec)
94  delete(ext);
95  }
96  std::vector<lwtr4tlm2_extension_registry_if<TYPES>*> ext_rec{};
97 };
98 
99 } // namespace lwtr
100 } // namespace scc
101 } // namespace tlm
102 #endif /* _TLM_SCC_LWTR_LWTR4TLM2_EXTENSION__REGISTRY_H */
The TLM transaction extensions recorder interface.
virtual void recordEndTx(::lwtr::tx_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(::lwtr::tx_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
The TLM transaction extensions recorder registry.
void recordEndTx(size_t id, ::lwtr::tx_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
SCC SystemC utilities.
SystemC TLM.