diff --git a/communication/include/communication.h b/communication/include/communication.h index 5c05ab3..e8ccae6 100644 --- a/communication/include/communication.h +++ b/communication/include/communication.h @@ -22,10 +22,10 @@ namespace icsneo { class Communication { public: Communication( - std::shared_ptr com, + std::unique_ptr com, std::shared_ptr p, - std::shared_ptr e, - std::shared_ptr md) : packetizer(p), encoder(e), decoder(md), impl(com) {} + std::unique_ptr e, + std::unique_ptr md) : packetizer(p), encoder(std::move(e)), decoder(std::move(md)), impl(std::move(com)) {} virtual ~Communication() { close(); } bool open(); @@ -47,12 +47,12 @@ public: } std::shared_ptr waitForMessageSync(std::shared_ptr f, std::chrono::milliseconds timeout = std::chrono::milliseconds(50)); - std::shared_ptr packetizer; - std::shared_ptr encoder; - std::shared_ptr decoder; + std::shared_ptr packetizer; // Ownership is shared with the encoder + std::unique_ptr encoder; + std::unique_ptr decoder; protected: - std::shared_ptr impl; + std::unique_ptr impl; static int messageCallbackIDCounter; std::map messageCallbacks; std::atomic closing{false}; diff --git a/communication/include/multichannelcommunication.h b/communication/include/multichannelcommunication.h index e3a9e04..fc3ebe5 100644 --- a/communication/include/multichannelcommunication.h +++ b/communication/include/multichannelcommunication.h @@ -11,10 +11,10 @@ namespace icsneo { class MultiChannelCommunication : public Communication { public: MultiChannelCommunication( - std::shared_ptr com, + std::unique_ptr com, std::shared_ptr p, - std::shared_ptr e, - std::shared_ptr md) : Communication(com, p, e, md) {} + std::unique_ptr e, + std::unique_ptr md) : Communication(std::move(com), p, std::move(e), std::move(md)) {} void spawnThreads() override; void joinThreads() override; bool sendPacket(std::vector& bytes) override; diff --git a/device/neovifire2/include/neovifire2eth.h b/device/neovifire2/include/neovifire2eth.h index 0720d95..17556fb 100644 --- a/device/neovifire2/include/neovifire2eth.h +++ b/device/neovifire2/include/neovifire2eth.h @@ -12,11 +12,11 @@ class NeoVIFIRE2ETH : public NeoVIFIRE2 { public: static constexpr const uint16_t PRODUCT_ID = 0x0004; NeoVIFIRE2ETH(neodevice_t neodevice) : NeoVIFIRE2(neodevice) { - auto transport = std::make_shared(getWritableNeoDevice()); + auto transport = std::unique_ptr(new PCAP(getWritableNeoDevice())); auto packetizer = std::make_shared(); - auto encoder = std::make_shared(packetizer); - auto decoder = std::make_shared(); - com = std::make_shared(transport, packetizer, encoder, decoder); + auto encoder = std::unique_ptr(new Encoder(packetizer)); + auto decoder = std::unique_ptr(new Decoder()); + com = std::make_shared(std::move(transport), packetizer, std::move(encoder), std::move(decoder)); settings = std::make_shared(com); productId = PRODUCT_ID; } diff --git a/device/neovifire2/include/neovifire2usb.h b/device/neovifire2/include/neovifire2usb.h index 7224666..ad78c01 100644 --- a/device/neovifire2/include/neovifire2usb.h +++ b/device/neovifire2/include/neovifire2usb.h @@ -11,11 +11,11 @@ class NeoVIFIRE2USB : public NeoVIFIRE2 { public: static constexpr const uint16_t PRODUCT_ID = 0x1000; NeoVIFIRE2USB(neodevice_t neodevice) : NeoVIFIRE2(neodevice) { - auto transport = std::make_shared(getWritableNeoDevice()); + auto transport = std::unique_ptr(new FTDI(getWritableNeoDevice())); auto packetizer = std::make_shared(); - auto encoder = std::make_shared(packetizer); - auto decoder = std::make_shared(); - com = std::make_shared(transport, packetizer, encoder, decoder); + auto encoder = std::unique_ptr(new Encoder(packetizer)); + auto decoder = std::unique_ptr(new Decoder()); + com = std::make_shared(std::move(transport), packetizer, std::move(encoder), std::move(decoder)); settings = std::make_shared(com); productId = PRODUCT_ID; }