mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-16 10:40:13 +02:00
More compile fixes
This commit is contained in:
parent
ac89571a79
commit
ac9e3b0326
4 changed files with 28 additions and 13 deletions
|
@ -11,13 +11,17 @@
|
|||
|
||||
#include "PacketList.h"
|
||||
|
||||
PacketList::PacketList(PacketType::Value packetType) :
|
||||
#include <QDebug>
|
||||
|
||||
#include "NLPacket.h"
|
||||
|
||||
template <class T> PacketList<T>::PacketList(PacketType::Value packetType) :
|
||||
_packetType(packetType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PacketList::createPacketWithExtendedHeader() {
|
||||
template <class T> std::unique_ptr<NLPacket> PacketList<T>::createPacketWithExtendedHeader() {
|
||||
// use the static create method to create a new packet
|
||||
auto packet = T::create(_packetType);
|
||||
|
||||
|
@ -28,7 +32,7 @@ void PacketList::createPacketWithExtendedHeader() {
|
|||
}
|
||||
}
|
||||
|
||||
qint64 writeData(const char* data, qint64 maxSize) {
|
||||
template <class T> qint64 PacketList<T>::writeData(const char* data, qint64 maxSize) {
|
||||
if (!_currentPacket) {
|
||||
// we don't have a current packet, time to set one up
|
||||
_currentPacket = createPacketWithExtendedHeader();
|
||||
|
@ -63,13 +67,13 @@ qint64 writeData(const char* data, qint64 maxSize) {
|
|||
}
|
||||
|
||||
// copy from currentPacket where the segment started to the beginning of the newPacket
|
||||
newPacket.write(currentPacket->getPayload() + _segmentStartIndex, numBytesToEnd);
|
||||
newPacket.write(_currentPacket->getPayload() + _segmentStartIndex, numBytesToEnd);
|
||||
|
||||
// the current segment now starts at the beginning of the new packet
|
||||
_segmentStartIndex = 0;
|
||||
|
||||
// shrink the current payload to the actual size of the packet
|
||||
currentPacket.setSizeUsed(_segmentStartIndex);
|
||||
_currentPacket.setSizeUsed(_segmentStartIndex);
|
||||
}
|
||||
|
||||
// move the current packet to our list of packets
|
||||
|
@ -99,7 +103,7 @@ qint64 writeData(const char* data, qint64 maxSize) {
|
|||
}
|
||||
}
|
||||
|
||||
void PacketList::closeCurrentPacket() {
|
||||
template <class T> void PacketList<T>::closeCurrentPacket() {
|
||||
// move the current packet to our list of packets
|
||||
_packets.insert(std::move(_currentPacket));
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#include "PacketHeaders.h"
|
||||
|
||||
class NLPacket;
|
||||
|
||||
template <class T> class PacketList : public QIODevice {
|
||||
public:
|
||||
PacketList(PacketType::Value packetType);
|
||||
|
@ -37,7 +39,7 @@ private:
|
|||
std::unique_ptr<NLPacket> createPacketWithExtendedHeader();
|
||||
|
||||
PacketType::Value _packetType;
|
||||
bool isOrdered = false;
|
||||
bool _isOrdered = false;
|
||||
|
||||
std::unique_ptr<T> _currentPacket;
|
||||
std::list<std::unique_ptr<T>> _packets;
|
||||
|
|
|
@ -8,10 +8,14 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <limits>
|
||||
#include "NetworkLogging.h"
|
||||
#include "SentPacketHistory.h"
|
||||
#include <qdebug.h>
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "NetworkLogging.h"
|
||||
#include "NLPacket.h"
|
||||
|
||||
SentPacketHistory::SentPacketHistory(int size)
|
||||
: _sentPackets(size),
|
||||
|
@ -30,10 +34,13 @@ void SentPacketHistory::packetSent(uint16_t sequenceNumber, const NLPacket& pack
|
|||
<< "Expected:" << expectedSequenceNumber << "Actual:" << sequenceNumber;
|
||||
}
|
||||
_newestSequenceNumber = sequenceNumber;
|
||||
_sentPackets.insert(NLPacket::createCopy(packet));
|
||||
|
||||
auto temp = std::unique_ptr<NLPacket>(const_cast<NLPacket*>(&packet));
|
||||
_sentPackets.insert(NLPacket::createCopy(temp));
|
||||
temp.release();
|
||||
}
|
||||
|
||||
const QByteArray* SentPacketHistory::getPacket(uint16_t sequenceNumber) const {
|
||||
const std::unique_ptr<NLPacket>& SentPacketHistory::getPacket(uint16_t sequenceNumber) const {
|
||||
|
||||
const int UINT16_RANGE = std::numeric_limits<uint16_t>::max() + 1;
|
||||
|
||||
|
@ -44,5 +51,5 @@ const QByteArray* SentPacketHistory::getPacket(uint16_t sequenceNumber) const {
|
|||
seqDiff += UINT16_RANGE;
|
||||
}
|
||||
|
||||
return _sentPackets.get(seqDiff);
|
||||
return *_sentPackets.get(seqDiff);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include "SequenceNumberStats.h"
|
||||
|
||||
class NLPacket;
|
||||
|
||||
class SentPacketHistory {
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue