#include <mitkInputDeviceRegistry.h>
Public Types | |
typedef IInputDeviceDescriptor::Pointer | InputDeviceDescriptorPtr |
Public Member Functions | |
bool | IsA (const std::type_info &type) |
const std::type_info & | GetType () const |
InputDeviceRegistry () | |
~InputDeviceRegistry () | |
InputDeviceDescriptorPtr | Find (const std::string &id) const |
std::vector < InputDeviceDescriptorPtr > | GetInputDevices () const |
Documentation in the interface.
Definition at line 36 of file mitkInputDeviceRegistry.h.
Definition at line 44 of file mitkInputDeviceRegistry.h.
mitk::InputDeviceRegistry::InputDeviceRegistry | ( | ) |
Definition at line 25 of file mitkInputDeviceRegistry.cpp.
References berry::Platform::GetExtensionPointService(), and mitk::CoreExtConstants::INPUTDEVICE_EXTENSION_NAME.
{ //initialize the registry by copying all available extension points into a local variable berry::IExtensionPointService::Pointer extensionPointService = berry::Platform::GetExtensionPointService(); std::vector<berry::IConfigurationElement::Pointer> allExtensionsInputDevices = extensionPointService->GetConfigurationElementsFor(mitk::CoreExtConstants::INPUTDEVICE_EXTENSION_NAME); for(std::vector<berry::IConfigurationElement::Pointer>::const_iterator it = allExtensionsInputDevices.begin(); it != allExtensionsInputDevices.end();++it) { InputDeviceDescriptorPtr temp(new mitk::InputDeviceDescriptor(*it)); // The equation with the end means, that if there is no such element and // the pointer will be at end (not the last element, actually after it) if(this->m_ListRegisteredDevices.find(temp->GetID()) == this->m_ListRegisteredDevices.end()) { m_ListRegisteredDevices.insert(std::make_pair<std::string, InputDeviceDescriptorPtr>(temp->GetID(),temp)); } else { throw std::runtime_error("The Input Device ID: "+temp->GetID()+" is already registered."); } } }
mitk::InputDeviceRegistry::~InputDeviceRegistry | ( | ) |
Definition at line 50 of file mitkInputDeviceRegistry.cpp.
{ }
mitk::InputDeviceRegistry::InputDeviceDescriptorPtr mitk::InputDeviceRegistry::Find | ( | const std::string & | id ) | const |
Definition at line 54 of file mitkInputDeviceRegistry.cpp.
{ Poco::HashMap<std::string,InputDeviceDescriptorPtr>::ConstIterator result = this->m_ListRegisteredDevices.find(id); // first = key, second = element or vice versa, if inserted different in the hash map if(result != this->m_ListRegisteredDevices.end()) return result->second; return InputDeviceDescriptorPtr(0); }
std::vector< mitk::InputDeviceRegistry::InputDeviceDescriptorPtr > mitk::InputDeviceRegistry::GetInputDevices | ( | ) | const [virtual] |
Implements mitk::IInputDeviceRegistry.
Definition at line 64 of file mitkInputDeviceRegistry.cpp.
{ std::vector<mitk::InputDeviceRegistry::InputDeviceDescriptorPtr> temp; for(Poco::HashMap<std::string, InputDeviceDescriptorPtr>::ConstIterator it = m_ListRegisteredDevices.begin(); it != m_ListRegisteredDevices.end();++it) { // first = key, second = element or vice versa, if inserted different in the hash map temp.push_back(it->second); } return temp; }
const std::type_info & mitk::InputDeviceRegistry::GetType | ( | ) | const [virtual] |
Reimplemented from berry::Service.
Definition at line 82 of file mitkInputDeviceRegistry.cpp.
{ return typeid(IInputDeviceRegistry); }
bool mitk::InputDeviceRegistry::IsA | ( | const std::type_info & | type ) |
Definition at line 76 of file mitkInputDeviceRegistry.cpp.
References berry::Service::IsA().
{ std::string name(GetType().name()); return name == type.name() || berry::Service::IsA(type); }