MCPcopy Create free account
hub / github.com/MITK/MITK / Load

Method Load

Modules/Persistence/src/mitkPersistenceService.cpp:190–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188}
189
190bool mitk::PersistenceService::Load(const std::string &fileName, bool enforceReload)
191{
192 this->Initialize();
193 bool load = false;
194
195 std::string theFile = fileName;
196 if (theFile.empty())
197 theFile = PersistenceService::GetDefaultPersistenceFile();
198
199 MITK_DEBUG << "Load persistence data from file: " << theFile;
200
201 if (!itksys::SystemTools::FileExists(theFile.c_str()))
202 return false;
203
204 bool xmlFile = false;
205 if (itksys::SystemTools::GetFilenameLastExtension(theFile.c_str()) == ".xml")
206 xmlFile = true;
207
208 if (enforceReload == false)
209 {
210 bool loadTheFile = true;
211 auto it = m_FileNamesToModifiedTimes.find(theFile);
212
213 long int currentModifiedTime = itksys::SystemTools::ModifiedTime(theFile.c_str());
214 if (it != m_FileNamesToModifiedTimes.end())
215 {
216 long int knownModifiedTime = (*it).second;
217 if (knownModifiedTime >= currentModifiedTime)
218 {
219 loadTheFile = false;
220 }
221 }
222 if (loadTheFile)
223 m_FileNamesToModifiedTimes[theFile] = currentModifiedTime;
224 else
225 return true;
226 }
227
228 if (xmlFile)
229 {
230 load = m_PropertyListsXmlFileReaderAndWriter->ReadLists(theFile, m_PropertyLists);
231 }
232 else
233 {
234 if (m_SceneIO.IsNull())
235 {
236 m_SceneIO = mitk::SceneIO::New();
237 }
238 DataStorage::Pointer ds = m_SceneIO->LoadScene(theFile);
239 load = (m_SceneIO->GetFailedNodes() == nullptr || m_SceneIO->GetFailedNodes()->size() == 0) &&
240 (m_SceneIO->GetFailedNodes() == nullptr || m_SceneIO->GetFailedProperties()->IsEmpty());
241 if (load)
242 {
243 this->RestorePropertyListsFromPersistentDataNodes(ds);
244 }
245 }
246 if (!load)
247 {

Callers 2

InitializeMethod · 0.95
PersistenceTestMethod · 0.45

Calls 13

InitializeMethod · 0.95
ReadListsMethod · 0.80
GetFailedNodesMethod · 0.80
NewFunction · 0.50
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
IsNullMethod · 0.45
LoadSceneMethod · 0.45
sizeMethod · 0.45
IsEmptyMethod · 0.45

Tested by 1

PersistenceTestMethod · 0.36