From db6384c470fe5660bf474aa49f46b00b893c4b3e Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 3 Jul 2025 15:10:02 +0300 Subject: chore(frame): Implement rule of 4 and move implementations from header to source --- src/frame.h | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'src/frame.h') diff --git a/src/frame.h b/src/frame.h index 92b9c8f..989ee38 100644 --- a/src/frame.h +++ b/src/frame.h @@ -15,31 +15,25 @@ class Frame { void parse_frame_str(const unsigned char* iso_tp_frame); -public: - Frame(const char* iso_tp_frame) { - this->parse_frame_str((const unsigned char*)iso_tp_frame); - } - - ~Frame() { - delete[] this->data; - } + void free(); + void copyFrom(const Frame& other); - FrameType get_type() const { - return this->type; - } - - unsigned int get_size() const { - return this->size; - } +public: + Frame(const char* iso_tp_frame); - unsigned int get_data_size() const { - return this->data_size; - } + /* Rule of 4 */ + Frame() = default; + ~Frame(); + Frame(const Frame& other); + Frame& operator=(const Frame& other); - const unsigned char* get_data() const { - return this->data; - } + /* Getters */ + FrameType get_type() const; + unsigned int get_size() const; + unsigned int get_data_size() const; + const unsigned char* get_data() const; + /* IO */ friend std::ostream& operator<<(std::ostream& os, const Frame& f); }; -- cgit v1.3.1-26-gb76a