00001 /*========================================================================= 00002 00003 Program: BlueBerry Platform 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision: 17020 $ 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 "mitkCoreExtActivator.h" 00019 00020 #include <mitkCoreExtObjectFactory.h> 00021 #include "mitkCoreExtConstants.h" 00022 00023 #include "mitkInputDeviceRegistry.h" 00024 00025 #include <berryIPreferencesService.h> 00026 00027 namespace mitk 00028 { 00029 void CoreExtActivator::Start(berry::IBundleContext::Pointer /*context*/) 00030 { 00031 RegisterCoreExtObjectFactory(); 00032 this->StartInputDeviceModules(); 00033 } 00034 00035 void mitk::CoreExtActivator::StartInputDeviceModules() 00036 { 00037 mitk::IInputDeviceRegistry::Pointer inputDeviceRegistry(new mitk::InputDeviceRegistry()); 00038 berry::Platform::GetServiceRegistry().RegisterService(mitk::CoreExtConstants::INPUTDEVICE_SERVICE,inputDeviceRegistry); 00039 00040 // Gets the last setting of the preferences; if a device was selected, it will still be activated after a restart 00041 berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry() 00042 .GetServiceById<berry::IPreferencesService>(berry::IPreferencesService::ID); 00043 berry::IPreferences::Pointer extPreferencesNode = prefService->GetSystemPreferences()->Node(CoreExtConstants::INPUTDEVICE_PREFERENCES); 00044 00045 // Initializes the modules 00046 std::vector<IInputDeviceDescriptor::Pointer> descriptors(inputDeviceRegistry->GetInputDevices()); 00047 for (std::vector<IInputDeviceDescriptor::Pointer>::const_iterator it = descriptors.begin(); it != descriptors.end(); ++it) 00048 { 00049 if (extPreferencesNode->GetBool((*it)->GetID(), false)) 00050 { 00051 IInputDevice::Pointer temp = (*it)->CreateInputDevice(); 00052 temp->RegisterInputDevice(); 00053 } 00054 } 00055 } // end method StartInputDeviceModules 00056 } // end namespace mitk