Salome HOME
Merge branch 'BR_HYDRO_IMPS_2016' of ssh://gitolite3@git.salome-platform.org/modules...
[modules/hydro.git] / src / HYDROData / HYDROData_Application.h
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 #ifndef HYDROData_Application_HeaderFile
20 #define HYDROData_Application_HeaderFile
21
22 #include <HYDROData_Document.h> 
23 #include <TDocStd_Application.hxx>
24 #include <NCollection_DataMap.hxx>
25
26 typedef NCollection_DataMap<int, Handle(HYDROData_Document)> DataMapOfStudyIDDocument;
27
28 /**\class HYDROData_Application
29  *
30  * \brief Realization of Open CASCADE application abstraction. Class for 
31  *        internal use inside of a package only.
32  * 
33  * Application supports the formats and document management. It is uses OCAF-lke
34  * architecture and just implements specific features of the module.
35  */
36 class HYDROData_Application : public TDocStd_Application
37 {
38 public: // useful methods inside of the package
39
40   //! Retuns the application: one per process    
41   HYDRODATA_EXPORT static HYDROData_Application* GetApplication();   
42
43 public: // Redefined OCAF methods
44   //! Return name of resource (i.e. "Standard")
45   HYDRODATA_EXPORT Standard_CString ResourcesName();
46   //! Return format (i.e "MDTV-Standard")
47   //! \param theFormats sequence of allowed formats for input/output
48   HYDRODATA_EXPORT virtual void Formats(TColStd_SequenceOfExtendedString& theFormats);    
49   //! Constructor
50   //! Use method GetInstance() method to obtain 
51   //! the static instance of the object (or derive your own application)
52   HYDRODATA_EXPORT HYDROData_Application();
53
54   // CASCADE RTTI
55   DEFINE_STANDARD_RTTIEXT(HYDROData_Application, TDocStd_Application)
56
57 private:
58   //! Returns document by its study ID, if document doesn't exists return null
59   Handle(HYDROData_Document) GetDocument(int theStudyID) const;
60
61   //! Get study id by document instance, if document doesn't exists return false
62   bool GetDocumentId(const Handle(HYDROData_Document)& theDocument,
63                      int&                              theDocId) const;
64
65   //! Appends document to the application
66   void AddDocument(int theStudyID, const Handle(HYDROData_Document)& theDocument);
67
68   //! Removes document from the application
69   void RemoveDocument( const Handle(HYDROData_Document)& theDocument );
70
71   //! map from SALOME study ID to the document
72   DataMapOfStudyIDDocument myDocuments;
73
74   friend class HYDROData_Document; // to manipulate documents of application
75 };
76
77 #endif