17 #ifndef SC_COMPONENTS_INCL_TLM_TLM_EXTENSIONS_H_
18 #define SC_COMPONENTS_INCL_TLM_TLM_EXTENSIONS_H_
21 #include <tlm_h/tlm_generic_payload/tlm_gp.h>
23 #include <tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h>
34 tlm_extension_base* clone()
const override {
return new type(
static_cast<const T&
>(*
this)); }
36 void copy_from(tlm_extension_base
const& other)
override { this->operator=(
static_cast<const type&
>(other)); }
46 template <
typename... Args>
static type* allocate(Args&&... args) {
47 auto* ret =
new(pool::allocate()) type(std::forward<Args>(args)...);
48 ret->is_pooled =
true;
52 static type* allocate() {
53 auto* ret =
new(pool::allocate()) type();
54 ret->is_pooled =
true;
58 tlm_extension_base* clone()
const {
62 void copy_from(tlm_extension_base
const& other) { this->operator=(
static_cast<const type&
>(other)); }
67 pool::dealllocate(
this);
73 static void* allocate() {
74 if(free_list.size() > 0) {
75 auto ret = free_list.back();
79 return calloc(1,
sizeof(type));
82 static void dealllocate(
void* p) { free_list.push_back(p); }
85 static std::vector<void*> free_list;
94 bool is_pooled{
false};
99 tlm_extension_base* clone()
const override {
103 void copy_from(tlm_extension_base
const& from)
override { buffer_ =
static_cast<data_buffer const&
>(from).buffer_; }
105 void set_size(uint32_t size) { buffer_.resize(size); }
106 unsigned char* get_buf_ptr() {
return buffer_.data(); }
109 std::vector<unsigned char> buffer_;