Salome HOME
Small fix of ImportNaming.
[modules/shaper.git] / src / Model / Model_Application.cpp
index d53dc665c679dcd14f69eca5b2881a10655b910b..204cafe1418d99d1e690eb87fe5b6242cc46003a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:       Model_Application.cxx
 // Created:    Fri Sep 2 2011
 // Author:     Mikhail PONIKAROV
@@ -19,14 +21,14 @@ Handle(Model_Application) Model_Application::getApplication()
 }
 
 //=======================================================================
-const boost::shared_ptr<Model_Document>& Model_Application::getDocument(string theDocID)
+const std::shared_ptr<Model_Document>& Model_Application::getDocument(string theDocID)
 {
   if (myDocs.find(theDocID) != myDocs.end())
     return myDocs[theDocID];
 
   static const std::string thePartSetKind("PartSet");
   static const std::string thePartKind("Part");
-  boost::shared_ptr<Model_Document> aNew(
+  std::shared_ptr<Model_Document> aNew(
     new Model_Document(theDocID, theDocID == "root" ? thePartSetKind : thePartKind));
   myDocs[theDocID] = aNew;
   // load it if it must be loaded by demand
@@ -65,6 +67,12 @@ void Model_Application::setLoadPath(std::string thePath)
   myPath = thePath;
 }
 
+//=======================================================================
+const std::string& Model_Application::loadPath() const
+{
+  return myPath;
+}
+
 //=======================================================================
 void Model_Application::setLoadByDemand(std::string theID)
 {
@@ -77,6 +85,26 @@ bool Model_Application::isLoadByDemand(std::string theID)
   return myLoadedByDemand.find(theID) != myLoadedByDemand.end();
 }
 
+//=======================================================================
+void Model_Application::removeUselessDocuments(
+  std::list<std::shared_ptr<ModelAPI_Document> > theUsedDocs)
+{
+  std::map<std::string, std::shared_ptr<Model_Document> >::iterator aDoc = myDocs.begin();
+  while(aDoc != myDocs.end()) {
+    bool aFound = false;
+    std::list<std::shared_ptr<ModelAPI_Document> >::iterator aUsed = theUsedDocs.begin();
+    for(; !aFound && aUsed != theUsedDocs.end(); aUsed++) {
+      aFound = aDoc->second == *aUsed;
+    }
+    if (!aFound) { // remove the useless
+      aDoc->second->close();
+      aDoc = myDocs.erase(aDoc);
+    } else {
+      aDoc++;
+    }
+  }
+}
+
 //=======================================================================
 Model_Application::Model_Application()
 {