+//=======================================================================
+bool Model_Application::hasRoot()
+{
+ return !myDocs.empty();
+}
+
+//=======================================================================
+std::shared_ptr<Model_Document> Model_Application::rootDocument()
+{
+ return myDocs[0];
+}
+
+//=======================================================================
+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)
+{
+ myLoadedByDemand.insert(theID);
+}
+
+//=======================================================================
+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<int, 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();
+ myDocs.erase(aDoc);
+ aDoc = myDocs.begin();
+ } else {
+ aDoc++;
+ }
+ }
+}
+
+int Model_Application::generateDocumentId()
+{
+ int aResult = int(myDocs.size());
+ for(; myDocs.find(aResult) != myDocs.end(); aResult++); // count until the result id is unique
+ return aResult;
+}
+