mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 22:09:02 +02:00
Added NLPacket::createCopy
This commit is contained in:
parent
e0119e8767
commit
fcd11461c2
4 changed files with 15 additions and 7 deletions
|
@ -37,9 +37,17 @@ std::unique_ptr<NLPacket> NLPacket::create(PacketType::Value type, int64_t size)
|
|||
return std::unique_ptr<NLPacket>(new NLPacket(type, size));
|
||||
}
|
||||
|
||||
std::unique_ptr<NLPacket> NLPacket::createCopy(const std::unique_ptr<NLPacket>& other) {
|
||||
Q_ASSERT(other);
|
||||
return std::unique_ptr<NLPacket>(new NLPacket(*other));
|
||||
}
|
||||
|
||||
NLPacket::NLPacket(PacketType::Value type, int64_t size) : Packet(type, localHeaderSize(type) + size) {
|
||||
}
|
||||
|
||||
NLPacket::NLPacket(NLPacket& other) : Packet(other) {
|
||||
}
|
||||
|
||||
void NLPacket::setSourceUuid(QUuid sourceUuid) {
|
||||
Q_ASSERT(!NON_SOURCED_PACKETS.contains(_type));
|
||||
auto offset = Packet::totalHeadersSize();
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
class NLPacket : public Packet {
|
||||
public:
|
||||
static std::unique_ptr<NLPacket> create(PacketType::Value type, int64_t size = -1);
|
||||
// Provided for convenience, try to limit use
|
||||
static std::unique_ptr<NLPacket> createCopy(const std::unique_ptr<NLPacket>& other);
|
||||
|
||||
static int64_t localHeaderSize(PacketType::Value type);
|
||||
static int64_t maxPayloadSize(PacketType::Value type);
|
||||
|
@ -26,6 +28,7 @@ public:
|
|||
|
||||
protected:
|
||||
NLPacket(PacketType::Value type, int64_t size);
|
||||
NLPacket(NLPacket& other);
|
||||
|
||||
void setSourceUuid(QUuid sourceUuid);
|
||||
void setConnectionUuid(QUuid connectionUuid);
|
||||
|
|
|
@ -38,7 +38,6 @@ std::unique_ptr<Packet> Packet::create(PacketType::Value type, qint64 size) {
|
|||
return std::unique_ptr<Packet>(new Packet(type, size));
|
||||
}
|
||||
|
||||
|
||||
std::unique_ptr<Packet> Packet::createCopy(const std::unique_ptr<Packet>& other) {
|
||||
Q_ASSERT(other);
|
||||
return std::unique_ptr<Packet>(new Packet(*other));
|
||||
|
|
|
@ -61,6 +61,10 @@ public:
|
|||
|
||||
protected:
|
||||
Packet(PacketType::Value type, int64_t size);
|
||||
Packet(const Packet& other);
|
||||
Packet& operator=(const Packet& other);
|
||||
Packet(Packet&& other);
|
||||
Packet& operator=(Packet&& other);
|
||||
|
||||
// QIODevice virtual functions
|
||||
virtual qint64 writeData(const char* data, qint64 maxSize);
|
||||
|
@ -79,12 +83,6 @@ protected:
|
|||
qint64 _capacity = 0; // Total capacity of the payload
|
||||
|
||||
qint64 _sizeUsed = 0; // How much of the payload is actually used
|
||||
|
||||
private:
|
||||
Packet(const Packet& other);
|
||||
Packet& operator=(const Packet& other);
|
||||
Packet(Packet&& other);
|
||||
Packet& operator=(Packet&& other);
|
||||
};
|
||||
|
||||
#endif // hifi_Packet_h
|
Loading…
Reference in a new issue