git-svn-id: svn://db.shs.com.ru/pip@633 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2018-09-27 20:58:09 +00:00
parent 08592aae9a
commit ffe5b1d691
6 changed files with 515 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
/*! \file pistreampacker.h
* \brief Simple packet wrap aroud any PIIODevice
*/
/*
PIP - Platform Independent Primitives
Simple packet wrap aroud any PIIODevice
Copyright (C) 2018 Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PISTREAMPACKER_H
#define PISTREAMPACKER_H
#include "piobject.h"
#include "piethutilbase.h"
class PIIODevice;
class PIStreamPacker: public PIObject, public PIEthUtilBase {
PIOBJECT(PIStreamPacker)
public:
PIStreamPacker(PIIODevice * dev = 0);
int maxPacketSize() {return max_packet_size;}
void setMaxPacketSize(int max_size) {max_packet_size = max_size;}
ushort packetSign() {return packet_sign;}
void setPacketSign(ushort sign_) {packet_sign = sign_;}
void send(const PIByteArray & data);
void received(const PIByteArray & data);
EVENT_HANDLER2(void, received, uchar * , readed, int, size) {received(PIByteArray(readed, size));}
void assignDevice(PIIODevice * dev);
EVENT1(packetReceiveEvent, PIByteArray, data)
EVENT1(sendRequest, PIByteArray, data)
protected:
PIByteArray stream, packet;
int packet_size;
ushort packet_sign;
int max_packet_size;
};
#endif // PISTREAMPACKER_H