00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 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 "mitkDataStorageService.h" 00019 00020 #include "mitkDataStorageReference.h" 00021 #include "mitkStandaloneDataStorage.h" 00022 00023 namespace mitk { 00024 00025 DataStorageService::DataStorageService() 00026 { 00027 m_DefaultDataStorageRef = this->CreateDataStorage("Default DataStorage"); 00028 m_ActiveDataStorageRef = m_DefaultDataStorageRef; 00029 } 00030 00031 bool 00032 DataStorageService::IsA(const std::type_info& type) 00033 { 00034 std::string name(GetType().name()); 00035 return name == type.name() || Service::IsA(type); 00036 } 00037 00038 const std::type_info& 00039 DataStorageService::GetType() const 00040 { 00041 return typeid(IDataStorageService); 00042 } 00043 00044 IDataStorageReference::Pointer DataStorageService::CreateDataStorage(const std::string& label) 00045 { 00046 00047 StandaloneDataStorage::Pointer dataStorage = mitk::StandaloneDataStorage::New(); 00048 DataStorageReference::Pointer ref(new DataStorageReference(dataStorage.GetPointer())); 00049 ref->SetLabel(label); 00050 m_DataStorageReferences.push_back(ref); 00051 00052 return ref; 00053 } 00054 00055 00056 std::vector<IDataStorageReference::Pointer> DataStorageService::GetDataStorageReferences() const 00057 { 00058 return m_DataStorageReferences; 00059 } 00060 00061 IDataStorageReference::Pointer DataStorageService::GetDefaultDataStorage() const 00062 { 00063 return m_DefaultDataStorageRef; 00064 } 00065 00066 IDataStorageReference::Pointer DataStorageService::GetActiveDataStorage() const 00067 { 00068 return m_ActiveDataStorageRef; 00069 } 00070 00071 void DataStorageService::SetActiveDataStorage(IDataStorageReference::Pointer dataStorageRef) 00072 { 00073 if (dataStorageRef.IsNull()) m_ActiveDataStorageRef = m_DefaultDataStorageRef; 00074 else m_ActiveDataStorageRef = dataStorageRef; 00075 } 00076 00077 }