35 lines
664 B
C++
35 lines
664 B
C++
#ifndef CODEC_H
|
|
#define CODEC_H
|
|
|
|
#include "QObject"
|
|
#include "base/base.h"
|
|
|
|
class Codec : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
Codec()
|
|
{
|
|
fullFrame = false;
|
|
}
|
|
virtual ~Codec() {}
|
|
virtual myarray encode(int srcAddr, int dstAddr, int cmd, myarray data) = 0;
|
|
virtual myarray decode(int &srcAddr, int &dstAddr, int &cmd, myarray data) = 0;
|
|
virtual myarray decode(int &srcAddr, int &dstAddr, int &cmd)
|
|
{
|
|
if (fullFrame == true)
|
|
{
|
|
fullFrame = false;
|
|
return decode(srcAddr, dstAddr, cmd, data);
|
|
}
|
|
return myarray();
|
|
}
|
|
virtual bool recvByte(int byte) = 0;
|
|
|
|
protected:
|
|
bool fullFrame;
|
|
myarray data;
|
|
};
|
|
|
|
#endif // CODEC_H
|