00001 /*========================================================================= 00002 00003 Program: BlueBerry Platform 00004 Language: C++ 00005 Date: $Date: 2010-01-16 19:57:43 +0100 (Sat, 16 Jan 2010) $ 00006 Version: $Revision: 21070 $ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "mitkInputDeviceDescriptor.h" 00019 #include "mitkCoreExtConstants.h" 00020 00021 00022 mitk::InputDeviceDescriptor::InputDeviceDescriptor(berry::IConfigurationElement::Pointer inputDeviceExtensionPoint) 00023 : IInputDeviceDescriptor(), m_InputDeviceExtensionPoint(inputDeviceExtensionPoint) 00024 { 00025 } 00026 00027 mitk::InputDeviceDescriptor::~InputDeviceDescriptor() 00028 { 00029 } 00030 00031 mitk::IInputDevice::Pointer mitk::InputDeviceDescriptor::CreateInputDevice() 00032 { 00033 if(this->m_InputDevice == 0) 00034 { 00035 // "class" refers to xml attribute in a xml tag 00036 this->m_InputDevice = this->m_InputDeviceExtensionPoint 00037 ->CreateExecutableExtension<mitk::IInputDevice>(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_CLASS); 00038 } 00039 return this->m_InputDevice; 00040 } 00041 00042 std::string mitk::InputDeviceDescriptor::GetID() const 00043 { 00044 std::string idOfExtensionPoint; 00045 this->m_InputDeviceExtensionPoint->GetAttribute(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_ID,idOfExtensionPoint); 00046 return idOfExtensionPoint; 00047 } 00048 00049 std::string mitk::InputDeviceDescriptor::GetDescription() const 00050 { 00051 std::vector<berry::IConfigurationElement::Pointer> 00052 descriptions(this->m_InputDeviceExtensionPoint->GetChildren(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_DESCRIPTION)); 00053 00054 if(!descriptions.empty()) 00055 { 00056 return descriptions[0]->GetValue(); 00057 } 00058 return ""; 00059 } 00060 00061 std::string mitk::InputDeviceDescriptor::GetName() const 00062 { 00063 std::string name; 00064 this->m_InputDeviceExtensionPoint->GetAttribute(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_NAME,name); 00065 return name; 00066 } 00067 00068 bool mitk::InputDeviceDescriptor::operator==(const Object* object) const 00069 { 00070 if (const InputDeviceDescriptor* other = dynamic_cast<const InputDeviceDescriptor*>(object)) 00071 { 00072 return this->GetID() == other->GetID(); 00073 } 00074 return false; 00075 } 00076