diff --git a/Modules/ToFHardware/mitkAbstractToFDeviceFactory.cpp b/Modules/ToFHardware/mitkAbstractToFDeviceFactory.cpp index a3b970e88f..19367329da 100644 --- a/Modules/ToFHardware/mitkAbstractToFDeviceFactory.cpp +++ b/Modules/ToFHardware/mitkAbstractToFDeviceFactory.cpp @@ -1,16 +1,42 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkAbstractToFDeviceFactory.h" +#include +#include + +mitk::ToFCameraDevice::Pointer mitk::AbstractToFDeviceFactory::ConnectToFDevice() +{ + ToFCameraDevice::Pointer device = createToFCameraDevice(); + m_Devices.push_back(device); + + ModuleContext* context = mitk::GetModuleContext(); + ServiceProperties deviceProps; +//-------------Take a look at this part to change the name given to a device + deviceProps["ToFDeviceName"] = GetCurrentDeviceName(); + m_DeviceRegistrations.insert(std::make_pair(device.GetPointer(), context->RegisterService(device.GetPointer(),deviceProps))); + return device; +} + +void mitk::AbstractToFDeviceFactory::DisconnectToFDevice(const ToFCameraDevice::Pointer& device) +{ + std::map::iterator i = m_DeviceRegistrations.find(device.GetPointer()); + if (i == m_DeviceRegistrations.end()) return; + + i->second.Unregister(); + m_DeviceRegistrations.erase(i); + + m_Devices.erase(std::remove(m_Devices.begin(), m_Devices.end(), device), m_Devices.end()); +} diff --git a/Modules/ToFHardware/mitkAbstractToFDeviceFactory.h b/Modules/ToFHardware/mitkAbstractToFDeviceFactory.h index 84b2a6144e..3a589ff6a3 100644 --- a/Modules/ToFHardware/mitkAbstractToFDeviceFactory.h +++ b/Modules/ToFHardware/mitkAbstractToFDeviceFactory.h @@ -1,68 +1,46 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkAbstractToFDeviceFactory_h #define __mitkAbstractToFDeviceFactory_h #include "mitkToFHardwareExports.h" #include "mitkIToFDeviceFactory.h" // Microservices #include -#include -#include "mitkModuleContext.h" namespace mitk { /** * @brief Virtual interface and base class for all Time-of-Flight device factories * * @ingroup ToFHardware */ struct MITK_TOFHARDWARE_EXPORT AbstractToFDeviceFactory : public IToFDeviceFactory { public: - ToFCameraDevice::Pointer ConnectToFDevice() - { - ToFCameraDevice::Pointer device = createToFCameraDevice(); - m_Devices.push_back(device); + ToFCameraDevice::Pointer ConnectToFDevice(); - ModuleContext* context = GetModuleContext(); - ServiceProperties deviceProps; -//-------------Take a look at this part to change the name given to a device - deviceProps["ToFDeviceName"] = GetCurrentDeviceName(); - m_DeviceRegistrations.insert(std::make_pair(device.GetPointer(), context->RegisterService(device.GetPointer(),deviceProps))); - return device; - } - - void DisconnectToFDevice(const ToFCameraDevice::Pointer& device) - { - std::map::iterator i = m_DeviceRegistrations.find(device.GetPointer()); - if (i == m_DeviceRegistrations.end()) return; - - i->second.Unregister(); - m_DeviceRegistrations.erase(i); - - m_Devices.erase(std::remove(m_Devices.begin(), m_Devices.end(), device), m_Devices.end()); - } + void DisconnectToFDevice(const ToFCameraDevice::Pointer& device); private: std::vector m_Devices; std::map m_DeviceRegistrations; }; } #endif diff --git a/Modules/ToFHardware/mitkIToFDeviceFactory.h b/Modules/ToFHardware/mitkIToFDeviceFactory.h index 48ec41c1c9..8cb3735cbe 100644 --- a/Modules/ToFHardware/mitkIToFDeviceFactory.h +++ b/Modules/ToFHardware/mitkIToFDeviceFactory.h @@ -1,42 +1,43 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkIToFDeviceFactory_h #define __mitkIToFDeviceFactory_h #include "mitkToFCameraDevice.h" +#include "mitkToFHardwareExports.h" //for microservices #include namespace mitk { - struct IToFDeviceFactory { + struct MITK_TOFHARDWARE_EXPORT IToFDeviceFactory { virtual ~IToFDeviceFactory(); // leer in mitkIToFDeviceFactory.cpp implementieren //create a specialized device factory in the inherited class virtual std::string GetFactoryName() = 0; virtual std::string GetCurrentDeviceName() = 0; virtual ToFCameraDevice::Pointer createToFCameraDevice() = 0; //create a specialized device factory in the inherited class }; } US_DECLARE_SERVICE_INTERFACE(mitk::IToFDeviceFactory, "org.mitk.services.IToFDeviceFactory") #endif