Salome HOME
#refs 522 (very draft) //import only
[modules/hydro.git] / src / HYDROData / HYDROData_Application.h
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef HYDROData_Application_HeaderFile
24 #define HYDROData_Application_HeaderFile
25
26 #include <HYDROData_Document.h> 
27 #include <TDocStd_Application.hxx>
28 #include <NCollection_DataMap.hxx>
29
30 typedef NCollection_DataMap<int, Handle(HYDROData_Document)> DataMapOfStudyIDDocument;
31
32 /**\class HYDROData_Application
33  *
34  * \brief Realization of Open CASCADE application abstraction. Class for 
35  *        internal use inside of a package only.
36  * 
37  * Application supports the formats and document management. It is uses OCAF-lke
38  * architecture and just implements specific features of the module.
39  */
40 class HYDROData_Application : public TDocStd_Application
41 {
42 public: // useful methods inside of the package
43
44   //! Retuns the application: one per process    
45   HYDRODATA_EXPORT static HYDROData_Application* GetApplication();   
46
47 public: // Redefined OCAF methods
48   //! Return name of resource (i.e. "Standard")
49   HYDRODATA_EXPORT Standard_CString ResourcesName();
50   //! Return format (i.e "MDTV-Standard")
51   //! \param theFormats sequence of allowed formats for input/output
52   HYDRODATA_EXPORT virtual void Formats(TColStd_SequenceOfExtendedString& theFormats);    
53   //! Constructor
54   //! Use method GetInstance() method to obtain 
55   //! the static instance of the object (or derive your own application)
56   HYDRODATA_EXPORT HYDROData_Application();
57
58   // CASCADE RTTI
59   DEFINE_STANDARD_RTTI(HYDROData_Application)
60
61 private:
62   //! Returns document by its study ID, if document doesn't exists return null
63   Handle(HYDROData_Document) GetDocument(int theStudyID) const;
64
65   //! Get study id by document instance, if document doesn't exists return false
66   bool GetDocumentId(const Handle(HYDROData_Document)& theDocument,
67                      int&                              theDocId) const;
68
69   //! Appends document to the application
70   void AddDocument(int theStudyID, const Handle(HYDROData_Document)& theDocument);
71
72   //! Removes document from the application
73   void RemoveDocument( const Handle(HYDROData_Document)& theDocument );
74
75   //! map from SALOME study ID to the document
76   DataMapOfStudyIDDocument myDocuments;
77
78   friend class HYDROData_Document; // to manipulate documents of application
79 };
80
81 // Define handle class 
82 DEFINE_STANDARD_HANDLE(HYDROData_Application,TDocStd_Application)
83
84 #endif