From aeb5066cbab18532ae9d08677faea8efcd56099f Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Sun, 27 Feb 2022 23:13:09 -0500 Subject: [PATCH] add callbacks for device (un)loading --- MMCore/MMCore.cpp | 14 ++++++++++++++ MMCore/MMEventCallback.h | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/MMCore/MMCore.cpp b/MMCore/MMCore.cpp index f4f68f23e..91a150075 100644 --- a/MMCore/MMCore.cpp +++ b/MMCore/MMCore.cpp @@ -721,6 +721,11 @@ void CMMCore::loadDevice(const char* label, const char* moduleName, const char* LOG_INFO(coreLogger_) << "Did load device " << deviceName << " from " << moduleName << "; label = " << label; + + if (externalCallback_ != 0) + { + externalCallback_->onDeviceLoaded(label); + } } void CMMCore::assignDefaultRole(boost::shared_ptr pDevice) @@ -783,6 +788,11 @@ void CMMCore::unloadDevice(const char* label///< the name of the device to unloa { boost::shared_ptr pDevice = deviceManager_->GetDevice(label); + if (externalCallback_ != 0) + { + externalCallback_->onDeviceWillBeUnloaded(label); + } + try { mm::DeviceModuleLockGuard guard(pDevice); LOG_DEBUG(coreLogger_) << "Will unload device " << label; @@ -819,6 +829,10 @@ void CMMCore::unloadAllDevices() throw (CMMError) } LOG_DEBUG(coreLogger_) << "Will unload all devices"; + if (externalCallback_ != 0) + { + externalCallback_->onAllDevicesWillBeUnloaded(); + } deviceManager_->UnloadAllDevices(); LOG_INFO(coreLogger_) << "Did unload all devices"; diff --git a/MMCore/MMEventCallback.h b/MMCore/MMEventCallback.h index 638508808..4b05ef7d3 100644 --- a/MMCore/MMEventCallback.h +++ b/MMCore/MMEventCallback.h @@ -89,4 +89,18 @@ class MMEventCallback std::cout << "onSLMExposureChanged()" << name << " " << newExposure << "\n"; } + virtual void onDeviceLoaded(const char* name) + { + std::cout << "onDeviceLoaded " << name; + } + + virtual void onDeviceWillBeUnloaded(const char* name) + { + std::cout << "onDeviceWillBeUnloaded " << name; + } + + virtual void onAllDevicesWillBeUnloaded() + { + std::cout << "onAllDevicesWillBeUnloaded "; + } };