1 // File: Model_Application.cxx
2 // Created: Fri Sep 2 2011
3 // Author: Mikhail PONIKAROV
5 #include <Model_Application.h>
6 #include <Model_Document.h>
8 IMPLEMENT_STANDARD_HANDLE(Model_Application, TDocStd_Application)
9 IMPLEMENT_STANDARD_RTTIEXT(Model_Application, TDocStd_Application)
13 static Handle_Model_Application TheApplication = new Model_Application;
15 //=======================================================================
16 Handle(Model_Application) Model_Application::getApplication()
18 return TheApplication;
21 //=======================================================================
22 const boost::shared_ptr<Model_Document>& Model_Application::getDocument(string theDocID)
24 if (myDocs.find(theDocID) != myDocs.end())
25 return myDocs[theDocID];
27 boost::shared_ptr<Model_Document> aNew(new Model_Document(theDocID));
28 myDocs[theDocID] = aNew;
29 // load it if it must be loaded by demand
30 if (myLoadedByDemand.find(theDocID) != myLoadedByDemand.end() && !myPath.empty()) {
31 aNew->load(myPath.c_str());
32 myLoadedByDemand.erase(theDocID); // done, don't do it anymore
35 return myDocs[theDocID];
38 void Model_Application::deleteDocument(string theDocID)
40 myDocs.erase(theDocID);
43 //=======================================================================
44 bool Model_Application::hasDocument(std::string theDocID)
46 return myDocs.find(theDocID) != myDocs.end();
49 //=======================================================================
50 void Model_Application::setLoadPath(std::string thePath)
55 //=======================================================================
56 void Model_Application::setLoadByDemand(std::string theID)
58 myLoadedByDemand.insert(theID);
61 //=======================================================================
62 Model_Application::Model_Application()
64 // store handle to the application to avoid nullification
65 static Handle(Model_Application) TheKeepHandle;
69 //=======================================================================
70 void Model_Application::Formats(TColStd_SequenceOfExtendedString& theFormats)
72 theFormats.Append(TCollection_ExtendedString("BinOcaf")); // standard binary schema
75 //=======================================================================
76 Standard_CString Model_Application::ResourcesName()
78 return Standard_CString("Standard");