Salome HOME
Update mechanism is corrected (Bug #182).
[modules/hydro.git] / src / HYDROData / HYDROData_Application.h
1 #ifndef HYDROData_Application_HeaderFile
2 #define HYDROData_Application_HeaderFile
3
4 #include <HYDROData_Document.h> 
5 #include <TDocStd_Application.hxx>
6 #include <NCollection_DataMap.hxx>
7
8 typedef NCollection_DataMap<int, Handle(HYDROData_Document)> DataMapOfStudyIDDocument;
9
10 /**\class HYDROData_Application
11  *
12  * \brief Realization of Open CASCADE application abstraction. Class for 
13  *        internal use inside of a package only.
14  * 
15  * Application supports the formats and document management. It is uses OCAF-lke
16  * architecture and just implements specific features of the module.
17  */
18 class HYDROData_Application : public TDocStd_Application
19 {
20 public: // useful methods inside of the package
21
22   //! Retuns the application: one per process    
23   HYDRODATA_EXPORT static HYDROData_Application* GetApplication();   
24
25 public: // Redefined OCAF methods
26   //! Return name of resource (i.e. "Standard")
27   Standard_CString ResourcesName();
28   //! Return format (i.e "MDTV-Standard")
29   //! \param theFormats sequence of allowed formats for input/output
30   virtual void Formats(TColStd_SequenceOfExtendedString& theFormats);    
31   //! Constructor
32   //! Use method GetInstance() method to obtain 
33   //! the static instance of the object (or derive your own application)
34   HYDROData_Application();
35
36   // CASCADE RTTI
37   DEFINE_STANDARD_RTTI(HYDROData_Application)
38
39 private:
40   //! Returns document by its study ID, if document doesn't exists return null
41   Handle(HYDROData_Document) GetDocument(int theStudyID) const;
42
43   //! Get study id by document instance, if document doesn't exists return false
44   bool GetDocumentId(const Handle(HYDROData_Document)& theDocument,
45                      int&                              theDocId) const;
46
47   //! Appends document to the application
48   void AddDocument(int theStudyID, const Handle(HYDROData_Document)& theDocument);
49
50   //! Removes document from the application
51   void RemoveDocument( const Handle(HYDROData_Document)& theDocument );
52
53   //! map from SALOME study ID to the document
54   DataMapOfStudyIDDocument myDocuments;
55
56   friend class HYDROData_Document; // to manipulate documents of application
57 };
58
59 // Define handle class 
60 DEFINE_STANDARD_HANDLE(HYDROData_Application,TDocStd_Application)
61
62 #endif