Summary Files Commits Branches @commit @diff @stats
path: root / src / message.h
blob: 764cf696d25644691f4a9aef45326a8f72a60d9f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef ISO_TP_MESSAGE
#define ISO_TP_MESSAGE

#include <ostream>
#include "frame.h"

class Message {
	unsigned int can_id;
	unsigned int size;
	unsigned int received;
	unsigned char latest_index;
	unsigned char* msg;

	void free();
	void copyFrom(const Message& other);

public:
	Message(unsigned int can_id, const Frame& first_frame);

	/* Rule of 4 */
	Message() = default;
	~Message();
	Message(const Message& other);
	Message& operator=(const Message& other);

	/* Logic */
	void receive_frame(const Frame& f);
	bool expects_more_frames() const;

	/* IO */
	friend std::ostream& operator<<(std::ostream& os, const Message& m);
};

std::ostream& operator<<(std::ostream& os, const Message& m);

#endif /* ISO_TP_MESSAGE */