Salome HOME
Lot 2: change bathy associated to natural object propagated to all cases without...
[modules/hydro.git] / src / HYDROData / HYDROData_Application.cxx
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include <HYDROData_Application.h>
20
21 #include <TColStd_SequenceOfExtendedString.hxx>
22
23 #define _STUDYID_ 1
24
25 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Application,TDocStd_Application)
26
27 static HYDROData_Application* TheApplication = new HYDROData_Application;
28
29 //=======================================================================
30 //function : getApplication
31 //purpose  : 
32 //=======================================================================
33 HYDROData_Application* HYDROData_Application::GetApplication() 
34 {
35   return TheApplication;
36 }
37
38 //=======================================================================
39 //function : GetDocument
40 //purpose  : 
41 //=======================================================================
42 Handle(HYDROData_Document) HYDROData_Application::GetDocument() const
43 {
44   if (myDocuments.IsBound(_STUDYID_)) {
45     return myDocuments.Find(_STUDYID_);
46   }
47   // document not found => create the new one
48   return Handle(HYDROData_Document)();
49 }
50
51 //=======================================================================
52 //function : OCAFApp_Application
53 //purpose  : 
54 //=======================================================================
55 HYDROData_Application::HYDROData_Application ()
56 {
57   // store handle to the application to avoid nullification
58   static Handle(HYDROData_Application) TheKeepHandle;
59   TheKeepHandle = this;
60 }
61
62 //=======================================================================
63 //function : addDocument
64 //purpose  : 
65 //=======================================================================
66 void HYDROData_Application::AddDocument(const Handle(HYDROData_Document)& theDocument)
67 {
68   myDocuments.Bind(_STUDYID_, theDocument);
69 }
70
71 //=======================================================================
72 //function : removeDocument
73 //purpose  : 
74 //=======================================================================
75 void HYDROData_Application::RemoveDocument(const Handle(HYDROData_Document)& theDocument)
76 {
77   DataMapOfStudyIDDocument::Iterator anIter(myDocuments);
78   for(; anIter.More(); anIter.Next())
79     if (anIter.Value() == theDocument) {
80       myDocuments.UnBind(anIter.Key());
81       break;
82     }
83 }
84
85 //=======================================================================
86 //function : Formats
87 //purpose  : 
88 //=======================================================================
89 void HYDROData_Application::Formats(TColStd_SequenceOfExtendedString& theFormats) 
90 {
91   theFormats.Append(TCollection_ExtendedString ("BinOcaf")); // standard binary schema
92 }
93
94 //=======================================================================
95 //function : ResourcesName
96 //purpose  : 
97 //=======================================================================
98 Standard_CString HYDROData_Application::ResourcesName()
99 {
100   return Standard_CString("Standard");
101 }