Salome HOME
Migration to VC9 and boost::shared_ptr with connection to SALOME
[modules/shaper.git] / src / Model / Model_Application.cxx
1 // File:        Model_Application.cxx
2 // Created:     Fri Sep 2 2011
3 // Author:      Mikhail PONIKAROV
4
5 #include <Model_Application.h>
6 #include <Model_Document.h>
7
8 IMPLEMENT_STANDARD_HANDLE(Model_Application, TDocStd_Application)
9 IMPLEMENT_STANDARD_RTTIEXT(Model_Application, TDocStd_Application)
10
11 using namespace std;
12
13 static Handle_Model_Application TheApplication = new Model_Application;
14
15 //=======================================================================
16 Handle(Model_Application) Model_Application::getApplication()
17 {
18   return TheApplication;
19 }
20
21 //=======================================================================
22 const boost::shared_ptr<Model_Document>& Model_Application::getDocument(string theDocID)
23 {
24   if (myDocs.find(theDocID) != myDocs.end())
25     return myDocs[theDocID];
26
27   boost::shared_ptr<Model_Document> aNew(new Model_Document(theDocID));
28   myDocs[theDocID] = aNew;
29   return myDocs[theDocID];
30 }
31
32 void Model_Application::deleteDocument(string theDocID)
33 {
34   myDocs.erase(theDocID);
35 }
36
37 //=======================================================================
38 bool Model_Application::hasDocument(std::string theDocID)
39 {
40   return myDocs.find(theDocID) != myDocs.end();
41 }
42
43 //=======================================================================
44 Model_Application::Model_Application()
45 {
46   // store handle to the application to avoid nullification
47   static Handle(Model_Application) TheKeepHandle;
48   TheKeepHandle = this;
49 }
50
51 //=======================================================================
52 void Model_Application::Formats(TColStd_SequenceOfExtendedString& theFormats)
53 {
54   theFormats.Append(TCollection_ExtendedString("BinOcaf")); // standard binary schema
55 }
56
57 //=======================================================================
58 Standard_CString Model_Application::ResourcesName()
59 {
60   return Standard_CString("Standard");
61 }