MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkToFDeviceFactoryManager.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
14
15//Microservices
16#include <usGetModuleContext.h>
17
18
19namespace mitk
20{
22 {
23 ModuleContext* context = GetModuleContext();
24 m_RegisteredFactoryRefs = context->GetServiceReferences<IToFDeviceFactory>();
25 if (m_RegisteredFactoryRefs.empty())
26 {
27 MITK_ERROR << "No factories registered!";
28 }
29 }
30
34
36 {
37 ModuleContext* context = GetModuleContext();
38 // std::string filter("(" + mitk::ServiceConstants::OBJECTCLASS() + "=" + "org.mitk.services.IToFDeviceFactory)");
39 // std::list<ServiceReference> serviceRef = context->GetServiceReference<IToFDeviceFactory>(/*filter*/);
40 std::vector<us::ServiceReference<IToFDeviceFactory> > serviceRefs = context->GetServiceReferences<IToFDeviceFactory>(/*filter*/);
41 if (!serviceRefs.empty())
42 {
43 for(std::vector<us::ServiceReference<IToFDeviceFactory> >::iterator it = serviceRefs.begin(); it != serviceRefs.end(); ++it)
44 {
45 IToFDeviceFactory* service = context->GetService( *it );
46 if(service)
47 {
48 m_RegisteredFactoryNames.push_back(std::string(service->GetFactoryName()));
49 }
50 }
51 }
53 }
54
56 {
57 us::ModuleContext* context = us::GetModuleContext();
58 std::vector<std::string> result;
59 std::vector<us::ServiceReference<ToFCameraDevice> > serviceRefs = context->GetServiceReferences<ToFCameraDevice>();
60 if (!serviceRefs.empty())
61 {
62 for(std::empty<us::ServiceReference<ToFCameraDevice> >::iterator it = serviceRefs.begin(); it != serviceRefs.end(); ++it)
63 {
64 ToFCameraDevice* service = context->GetService( *it );
65 if(service)
66 {
67 result.push_back(std::string(service->GetNameOfClass()));
68 }
69 }
70 }
71 if(result.size() == 0)
72 {
73 MITK_ERROR << "No devices connected!";
74 }
75 return result;
76 }
77
79 {
80 us::ModuleContext* context = us::GetModuleContext();
81
82 std::vector<us::ServiceReference<IToFDeviceFactory> > serviceRefs = context->GetServiceReferences<IToFDeviceFactory>(/*filter*/);
83 if (!serviceRefs.empty())
84 {
85 int i = 0;
86 for(std::vector<us::ServiceReference<IToFDeviceFactory> >::iterator it = serviceRefs.begin(); it != serviceRefs.end(); ++it)
87 {
88 IToFDeviceFactory* service = context->GetService( *it );
89 if(service && (i == index))
90 {
91 return dynamic_cast<mitk::AbstractToFDeviceFactory*>(service)->ConnectToFDevice();
92 }
93 i++;
94 }
95 }
96 MITK_ERROR << "No device generated!";
97 return nullptr;
98 }
99}
Virtual interface and base class for all Time-of-Flight devices.
std::vector< std::string > m_RegisteredFactoryNames
std::vector< std::string > GetRegisteredDeviceFactories()
ToFCameraDevice * GetInstanceOfDevice(int index)
std::vector< us::ServiceReference< IToFDeviceFactory > > m_RegisteredFactoryRefs
std::vector< std::string > GetConnectedDevices()
IGT Exceptions.
Virtual interface and base class for all Time-of-Flight device factories. The basic interface is in t...
This is the base of class for all ToFDeviceFactories.
virtual std::string GetFactoryName()=0
GetFactoryName Get the human readable name of the factory.