pitextstream starts
This commit is contained in:
59
libs/main/io_devices/piiostream.h
Normal file
59
libs/main/io_devices/piiostream.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*! \file piiostream.h
|
||||
* \ingroup IO
|
||||
* \~\brief
|
||||
* \~english PIBinaryStream functionality for PIIODevice
|
||||
* \~russian Функциональность PIBinaryStream для PIIODevice
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIBinaryStream functionality for PIIODevice
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIIOSTREAM_H
|
||||
#define PIIOSTREAM_H
|
||||
|
||||
#include "piiodevice.h"
|
||||
|
||||
|
||||
//! \ingroup IO
|
||||
//! \~\brief
|
||||
//! \~english PIBinaryStream functionality for PIIODevice.
|
||||
//! \~russian Функциональность PIBinaryStream для PIIODevice.
|
||||
class PIP_EXPORT PIIOBinaryStream: public PIBinaryStream<PIIOBinaryStream> {
|
||||
public:
|
||||
|
||||
//! \~english Contructs %PIIOBinaryStream for "device" device
|
||||
//! \~russian Создает %PIIOBinaryStream для устройства "device"
|
||||
PIIOBinaryStream(PIIODevice * device): dev(device) {}
|
||||
|
||||
bool binaryStreamAppendImp(const void * d, size_t s) {
|
||||
if (!dev) return false;
|
||||
return dev->write(d, s);
|
||||
}
|
||||
|
||||
bool binaryStreamTakeImp(void * d, size_t s) {
|
||||
if (!dev) return false;
|
||||
return dev->read(d, s);
|
||||
}
|
||||
|
||||
private:
|
||||
PIIODevice * dev;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // PIIOSTREAM_H
|
||||
@@ -573,7 +573,7 @@ bool PIPeer::mbcastRead(uchar * data, int size) {
|
||||
if (type <= 0 || type >= 4) return true;
|
||||
PeerInfo pi;
|
||||
ba >> pi.name;
|
||||
// piCoutObj << "received mb from" << pi.name << "packet" << type;
|
||||
//piCout << "received mb from" << pi.name << "packet" << type;
|
||||
if (pi.name == self_info.name) return true;
|
||||
PIMutexLocker locker(mc_mutex);
|
||||
diag_s.received(size);
|
||||
@@ -789,6 +789,7 @@ void PIPeer::sendPeerInfo(const PeerInfo & info) {
|
||||
|
||||
|
||||
void PIPeer::sendPeerRemove(const PIString & peer) {
|
||||
//piCout << name() << "sendPeerRemove" << peer;
|
||||
PIByteArray ba;
|
||||
ba << int(2) << peer;
|
||||
sendMBcast(ba);
|
||||
@@ -858,7 +859,7 @@ void PIPeer::syncPeers() {
|
||||
PeerInfo & cp(peers[i]);
|
||||
if (cp.sync > 3) {
|
||||
pn = cp.name;
|
||||
//piCoutObj << "sync: remove " << pn;
|
||||
//piCout << "sync: remove " << pn;
|
||||
cp.destroy();
|
||||
addToRemoved(cp);
|
||||
peers.remove(i);
|
||||
|
||||
Reference in New Issue
Block a user