Frame Frame startStopByte 0xFF headerLength data NULL Frame Frame dele

 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
Frame::Frame() {
startStopByte = 0xFF;
headerLength = 3;
data = NULL;
}
Frame::~Frame() {
delete [] data;
}
Frame::Frame(const Frame& frame) {
this->startStopByte = frame.startStopByte;
this->frameLength = frame.frameLength;
this->dataLength = frame.dataLength;
this->headerLength = frame.headerLength;
this->data = new unsigned char[this->dataLength];
memcpy(this->data, frame.data, this->dataLength);
}
Frame& Frame::operator = (const Frame& frame) {
if (this != &frame) {
if (this->data)
delete this->data;
this->startStopByte = frame.startStopByte;
this->frameLength = frame.frameLength;
this->dataLength = frame.dataLength;
this->headerLength = frame.headerLength;
this->data = new unsigned char[this->dataLength];
memcpy(this->data, frame.data, this->dataLength);
}
return *this;
}