Skip to content

Commit fc2831c

Browse files
committed
add callbacks for device (un)loading
1 parent ab2fc60 commit fc2831c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

MMCore/MMCore.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,11 @@ void CMMCore::loadDevice(const char* label, const char* moduleName, const char*
721721

722722
LOG_INFO(coreLogger_) << "Did load device " << deviceName <<
723723
" from " << moduleName << "; label = " << label;
724+
725+
if (externalCallback_ != 0)
726+
{
727+
externalCallback_->onDeviceLoaded(label);
728+
}
724729
}
725730

726731
void CMMCore::assignDefaultRole(boost::shared_ptr<DeviceInstance> pDevice)
@@ -783,6 +788,11 @@ void CMMCore::unloadDevice(const char* label///< the name of the device to unloa
783788
{
784789
boost::shared_ptr<DeviceInstance> pDevice = deviceManager_->GetDevice(label);
785790

791+
if (externalCallback_ != 0)
792+
{
793+
externalCallback_->onDeviceWillBeUnloaded(label);
794+
}
795+
786796
try {
787797
mm::DeviceModuleLockGuard guard(pDevice);
788798
LOG_DEBUG(coreLogger_) << "Will unload device " << label;
@@ -819,6 +829,10 @@ void CMMCore::unloadAllDevices() throw (CMMError)
819829
}
820830

821831
LOG_DEBUG(coreLogger_) << "Will unload all devices";
832+
if (externalCallback_ != 0)
833+
{
834+
externalCallback_->onAllDevicesWillBeUnloaded();
835+
}
822836
deviceManager_->UnloadAllDevices();
823837
LOG_INFO(coreLogger_) << "Did unload all devices";
824838

MMCore/MMEventCallback.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,18 @@ class MMEventCallback
8989
std::cout << "onSLMExposureChanged()" << name << " " << newExposure << "\n";
9090
}
9191

92+
virtual void onDeviceLoaded(const char* name)
93+
{
94+
std::cout << "onDeviceLoaded " << name;
95+
}
96+
97+
virtual void onDeviceWillBeUnloaded(const char* name)
98+
{
99+
std::cout << "onDeviceWillBeUnloaded " << name;
100+
}
101+
102+
virtual void onAllDevicesWillBeUnloaded()
103+
{
104+
std::cout << "onAllDevicesWillBeUnloaded ";
105+
}
92106
};

0 commit comments

Comments
 (0)