31 m_storageLocked(false)
33 this->
SetName(
"ToolStorage (no name given)");
45 m_props[ US_PROPKEY_STORAGE_NAME ] = m_Name;
50 if (m_ServiceRegistration) {m_ServiceRegistration.SetProperties(m_props);}
58 for(std::vector<mitk::NavigationTool::Pointer>::iterator it = m_ToolCollection.begin(); it != m_ToolCollection.end(); it++)
66 if ( sourceID.empty() )
mitkThrow() <<
"Empty or null string passed to NavigationToolStorage::registerAsMicroservice().";
72 m_props[ US_PROPKEY_SOURCE_ID ] = sourceID;
73 m_ServiceRegistration = context->RegisterService(
this, m_props);
78 if ( ! m_ServiceRegistration )
81 <<
"Cannot unregister microservice as it wasn't registered before.";
85 m_ServiceRegistration.Unregister();
86 m_ServiceRegistration = 0;
94 MITK_WARN <<
"Storage is locked, cannot modify it!";
98 else if ((
unsigned int)number > m_ToolCollection.size())
100 MITK_WARN <<
"Tool no " << number <<
"doesn't exist, can't delete it!";
103 std::vector<mitk::NavigationTool::Pointer>::iterator it = m_ToolCollection.begin() + number;
106 m_ToolCollection.erase(it);
115 MITK_WARN <<
"Storage is locked, cannot modify it!";
119 while(m_ToolCollection.size() > 0)
if (!DeleteTool(0))
return false;
127 MITK_WARN <<
"Storage is locked, cannot modify it!";
130 else if (GetTool(tool->GetIdentifier()).IsNotNull())
132 MITK_WARN <<
"Tool ID already exists in storage, can't add!";
137 m_ToolCollection.push_back(tool);
149 return m_ToolCollection.at(number);
154 for (
int i=0; i<GetToolCount(); i++)
if ((GetTool(i)->GetIdentifier())==identifier)
return GetTool(i);
160 for (
int i=0; i<GetToolCount(); i++)
if ((GetTool(i)->GetToolName())==name)
return GetTool(i);
166 return m_ToolCollection.size();
171 return m_ToolCollection.empty();
176 m_storageLocked =
true;
181 m_storageLocked =
false;
186 return m_storageLocked;
191 if (this->GetTool(identifier1).IsNull())
193 MITK_WARN <<
"Identifier does not exist, cannot assign new number";
197 if ((number2 >= m_ToolCollection.size()) || (number2 < 0))
199 MITK_WARN <<
"Invalid number, cannot assign new number";
207 for(
int i = 0; i<m_ToolCollection.size(); i++)
209 if (m_ToolCollection.at(i)->GetIdentifier() == identifier1) {number1=i;}
212 m_ToolCollection[number2] = m_ToolCollection.at(number1);
214 m_ToolCollection[number1] = tool2;
216 MITK_DEBUG <<
"Swapped tool " << number2 <<
" with tool " << number1;
itk::SmartPointer< Self > Pointer
DataCollection - Class to facilitate loading/accessing structured data.
mitk::DataStorage::Pointer m_DataStorage
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.