diff --git a/commonLibs/livoxProto1/core.cpp b/commonLibs/livoxProto1/core.cpp index f131612..c439623 100644 --- a/commonLibs/livoxProto1/core.cpp +++ b/commonLibs/livoxProto1/core.cpp @@ -72,7 +72,7 @@ std::optional> DeviceManager::getDevice( // GetOrCreateDeviceReq nested class implementation class DeviceManager::GetOrCreateDeviceReq -: public AsynchronousContinuation +: public smo::AsynchronousContinuation { public: DeviceManager& deviceManager; @@ -84,7 +84,8 @@ public: DeviceManager& mgr, std::shared_ptr device, livoxProto1_getOrCreateDeviceReqCbFn cb) - : AsynchronousContinuation(std::move(cb)), + : smo::AsynchronousContinuation< + livoxProto1_getOrCreateDeviceReqCbFn>(std::move(cb)), deviceManager(mgr), pendingDevice(device) {} @@ -175,9 +176,9 @@ void DeviceManager::getOrCreateDeviceReq( } class DeviceManager::DestroyDeviceReq -: public AsynchronousContinuation +: public smo::AsynchronousContinuation { - public: +public: DeviceManager& deviceManager; std::shared_ptr pendingDevice; @@ -186,7 +187,8 @@ public: DeviceManager& mgr, std::shared_ptr device, livoxProto1_destroyDeviceReqCbFn cb) - : AsynchronousContinuation(std::move(cb)), + : smo::AsynchronousContinuation< + livoxProto1_destroyDeviceReqCbFn>(std::move(cb)), deviceManager(mgr), pendingDevice(device) {} diff --git a/commonLibs/livoxProto1/device.cpp b/commonLibs/livoxProto1/device.cpp index 57eefd8..bbcca0e 100644 --- a/commonLibs/livoxProto1/device.cpp +++ b/commonLibs/livoxProto1/device.cpp @@ -120,7 +120,7 @@ Device::~Device() * This class manages the overall device connection process including handshake and heartbeat setup */ class Device::ConnectReq -: public AsynchronousContinuation +: public smo::AsynchronousContinuation { private: Device& device; @@ -128,7 +128,9 @@ private: public: ConnectReq(Device& dev, Device::connectReqCbFn cb) - : AsynchronousContinuation(std::move(cb)), device(dev) {} + : smo::AsynchronousContinuation( + std::move(cb)), device(dev) + {} /** FIXME: * WE need to assign the ipAddr to the Device being connected up. @@ -259,7 +261,7 @@ void Device::connectReq(Device::connectReqCbFn callback) } class Device::ConnectToKnownDeviceReq -: public AsynchronousContinuation +: public smo::AsynchronousContinuation { public: Device& device; @@ -267,7 +269,8 @@ public: std::shared_ptr deviceInfo; ConnectToKnownDeviceReq(Device& dev, Device::connectToKnownDeviceReqCbFn cb) - : AsynchronousContinuation(std::move(cb)), device(dev) + : smo::AsynchronousContinuation( + std::move(cb)), device(dev) {} // Public accessor for the original callback @@ -360,7 +363,8 @@ void Device::connectToKnownDeviceReq( } class Device::ConnectByDeviceIdentifierReq -: public AsynchronousContinuation +: public smo::AsynchronousContinuation< + Device::connectByDeviceIdentifierReqCbFn> { public: Device& device; @@ -368,7 +372,8 @@ public: ConnectByDeviceIdentifierReq( Device& dev, Device::connectByDeviceIdentifierReqCbFn cb) - : AsynchronousContinuation(std::move(cb)), device(dev) + : smo::AsynchronousContinuation( + std::move(cb)), device(dev) {} // Public accessor for the original callback @@ -440,7 +445,7 @@ void Device::connectByDeviceIdentifierReq( } class Device::ExecuteHandshakeReq -: public AsynchronousContinuation +: public smo::AsynchronousContinuation { public: friend void Device::executeHandshakeReq( @@ -477,7 +482,8 @@ public: ExecuteHandshakeReq( Device& dev, const std::string& deviceIP, Device::executeHandshakeReqCbFn cb) - : AsynchronousContinuation(std::move(cb)), + : smo::AsynchronousContinuation( + std::move(cb)), device(dev), deviceIP(deviceIP), handshakeFdDesc(device.componentThread->getIoService()), timeoutTimer(device.componentThread->getIoService()) diff --git a/include/asynchronousContinuation.h b/include/asynchronousContinuation.h index c9a2860..3259390 100644 --- a/include/asynchronousContinuation.h +++ b/include/asynchronousContinuation.h @@ -3,6 +3,9 @@ #include #include +#include + +namespace smo { /** * AsynchronousContinuation - Template base class for async sequence management @@ -47,4 +50,31 @@ protected: OriginalCbFnT originalCbFn; }; +class ContinuationTarget +{ +public: + ContinuationTarget( + const std::shared_ptr &caller) + : caller(caller) + {} + +public: + const std::shared_ptr caller; +}; + +template +class TargetedAsynchronousContinuation +: public AsynchronousContinuation, public ContinuationTarget +{ +public: + TargetedAsynchronousContinuation( + const std::shared_ptr &caller, + OriginalCbFnT originalCbFn) + : AsynchronousContinuation(originalCbFn), + ContinuationTarget(caller) + {} +}; + +} // namespace smo + #endif // ASYNCHRONOUS_CONTINUATION_H