Browse Source

add generic data_buffer extension which can be used for copies of tlm_generic_payload objects

master
parent
commit
01458535fa
1 changed files with 15 additions and 0 deletions
  1. +15
    -0
      incl/tlm/tlm_extensions.h

+ 15
- 0
incl/tlm/tlm_extensions.h View File

@@ -86,5 +86,20 @@ protected:
private:
bool is_pooled{false};
};

struct data_buffer: public tlm::tlm_extension<data_buffer> {

tlm_extension_base* clone() const override {
data_buffer* ext = new data_buffer;
return ext;
}
void copy_from(tlm_extension_base const& from) override { buffer_ = static_cast<data_buffer const&>(from).buffer_; }

void set_size(uint8_t size){ buffer_.resize(size); }
unsigned char * get_buf_ptr() {return buffer_.data();}
private:
std::vector<unsigned char> buffer_;
};

} // namespace tlm
#endif /* SC_COMPONENTS_INCL_TLM_TLM_EXTENSIONS_H_ */

Loading…
Cancel
Save