Salome HOME
Merge branch 'BR_HYDRO_IMPS_2016' of ssh://gitolite3@git.salome-platform.org/modules...
[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 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Application,TDocStd_Application)
24
25 static HYDROData_Application* TheApplication = new HYDROData_Application;
26
27 //=======================================================================
28 //function : getApplication
29 //purpose  : 
30 //=======================================================================
31 HYDROData_Application* HYDROData_Application::GetApplication() 
32 {
33   return TheApplication;
34 }
35
36 //=======================================================================
37 //function : GetDocument
38 //purpose  : 
39 //=======================================================================
40 bool HYDROData_Application::GetDocumentId(const Handle(HYDROData_Document)& theDocument,
41                                           int&                              theDocId) const
42 {
43   DataMapOfStudyIDDocument::Iterator aMapit( myDocuments );
44   for ( ; aMapit.More(); aMapit.Next() )
45   {
46     if ( aMapit.Value() != theDocument )
47       continue;
48
49     theDocId = aMapit.Key();
50     return true;
51   }
52
53   return false;
54 }
55
56 //=======================================================================
57 //function : GetDocument
58 //purpose  : 
59 //=======================================================================
60 Handle(HYDROData_Document) HYDROData_Application::GetDocument(int theStudyID) const
61 {
62   if (myDocuments.IsBound(theStudyID)) {
63     return myDocuments.Find(theStudyID);
64   }
65   // document not found => create the new one
66   return Handle(HYDROData_Document)();
67 }
68
69 //=======================================================================
70 //function : OCAFApp_Application
71 //purpose  : 
72 //=======================================================================
73 HYDROData_Application::HYDROData_Application ()
74 {
75   // store handle to the application to avoid nullification
76   static Handle(HYDROData_Application) TheKeepHandle;
77   TheKeepHandle = this;
78 }
79
80 //=======================================================================
81 //function : addDocument
82 //purpose  : 
83 //=======================================================================
84 void HYDROData_Application::AddDocument(int theStudyID, const Handle(HYDROData_Document)& theDocument)
85 {
86   myDocuments.Bind(theStudyID, theDocument);
87 }
88
89 //=======================================================================
90 //function : removeDocument
91 //purpose  : 
92 //=======================================================================
93 void HYDROData_Application::RemoveDocument(const Handle(HYDROData_Document)& theDocument)
94 {
95   DataMapOfStudyIDDocument::Iterator anIter(myDocuments);
96   for(; anIter.More(); anIter.Next())
97     if (anIter.Value() == theDocument) {
98       myDocuments.UnBind(anIter.Key());
99       break;
100     }
101 }
102
103 //=======================================================================
104 //function : Formats
105 //purpose  : 
106 //=======================================================================
107 void HYDROData_Application::Formats(TColStd_SequenceOfExtendedString& theFormats) 
108 {
109   theFormats.Append(TCollection_ExtendedString ("BinOcaf")); // standard binary schema
110 }
111
112 //=======================================================================
113 //function : ResourcesName
114 //purpose  : 
115 //=======================================================================
116 Standard_CString HYDROData_Application::ResourcesName()
117 {
118   return Standard_CString("Standard");
119 }