diff --git a/libraries/networking/src/NLPacket.cpp b/libraries/networking/src/NLPacket.cpp index 524983a8ff..4f12b761d1 100644 --- a/libraries/networking/src/NLPacket.cpp +++ b/libraries/networking/src/NLPacket.cpp @@ -37,9 +37,17 @@ std::unique_ptr NLPacket::create(PacketType::Value type, int64_t size) return std::unique_ptr(new NLPacket(type, size)); } +std::unique_ptr NLPacket::createCopy(const std::unique_ptr& other) { + Q_ASSERT(other); + return std::unique_ptr(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(); diff --git a/libraries/networking/src/NLPacket.h b/libraries/networking/src/NLPacket.h index 7f625fb60c..9105418492 100644 --- a/libraries/networking/src/NLPacket.h +++ b/libraries/networking/src/NLPacket.h @@ -17,6 +17,8 @@ class NLPacket : public Packet { public: static std::unique_ptr create(PacketType::Value type, int64_t size = -1); + // Provided for convenience, try to limit use + static std::unique_ptr createCopy(const std::unique_ptr& 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); diff --git a/libraries/networking/src/Packet.cpp b/libraries/networking/src/Packet.cpp index 65d0899a94..b11564428f 100644 --- a/libraries/networking/src/Packet.cpp +++ b/libraries/networking/src/Packet.cpp @@ -38,7 +38,6 @@ std::unique_ptr Packet::create(PacketType::Value type, qint64 size) { return std::unique_ptr(new Packet(type, size)); } - std::unique_ptr Packet::createCopy(const std::unique_ptr& other) { Q_ASSERT(other); return std::unique_ptr(new Packet(*other)); diff --git a/libraries/networking/src/Packet.h b/libraries/networking/src/Packet.h index 9d58d1e2e1..471237b212 100644 --- a/libraries/networking/src/Packet.h +++ b/libraries/networking/src/Packet.h @@ -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 \ No newline at end of file