Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
[modules/shaper.git] / src / Model / Model_Application.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_Application.hxx
4 // Created:     28 Dec 2011
5 // Author:      Mikhail PONIKAROV
6 // Copyright:   CEA 2011
7
8 #ifndef Model_Application_H_
9 #define Model_Application_H_
10
11 #include <Model_Document.h> 
12 #include <TDocStd_Application.hxx>
13 #include <map>
14
15 // Define handle class 
16 DEFINE_STANDARD_HANDLE(Model_Application, TDocStd_Application)
17
18 /**\class Model_Application
19  * \ingroup DataModel
20  * \brief Realization of Open CASCADE application abstraction. Class for internal use only.
21  * Application supports the formats and document management. It is uses OCAF-lke
22  * architecture and just implements specific features of the module.
23  */
24 class Model_Application : public TDocStd_Application
25 {
26  public:
27   // useful methods inside of the module
28
29   // CASCADE RTTI
30   DEFINE_STANDARD_RTTI(Model_Application)
31   ;
32
33   //! Retuns the application: one per process    
34   MODEL_EXPORT static Handle_Model_Application getApplication();
35   //! Returns the main document (on first call creates it) by the string identifier
36   MODEL_EXPORT const std::shared_ptr<Model_Document>& getDocument(std::string theDocID);
37   //! Returns true if document has been created
38   MODEL_EXPORT bool hasDocument(std::string theDocID);
39   //! Deletes the document from the application
40   MODEL_EXPORT void deleteDocument(std::string theDocID);
41   //! Deletes all documents existing in the application
42   MODEL_EXPORT void deleteAllDocuments();
43
44   //! Set path for the loaded by demand documents
45   void setLoadPath(std::string thePath);
46   //! Returns the path for the loaded by demand documents
47   const std::string& loadPath() const;
48   //! Defines that specified document must be loaded by demand
49   void setLoadByDemand(std::string theID);
50   //! Returns true if specified document must be loaded by demand
51   bool isLoadByDemand(std::string theID);
52   //! Closes and removes the documents that are not loaded by demand and
53   //! not in the given list
54   void removeUselessDocuments(std::list<std::shared_ptr<ModelAPI_Document> > theUsedDocs);
55
56  public:
57   // Redefined OCAF methods
58   //! Return name of resource (i.e. "Standard")
59   Standard_CString ResourcesName();
60   //! Return format (i.e "MDTV-Standard")
61   //! \param theFormats sequence of allowed formats for input/output
62   virtual void Formats(TColStd_SequenceOfExtendedString& theFormats);
63   //! Constructor
64   //! Use method GetInstance() method to obtain 
65   //! the static instance of the object (or derive your own application)
66   Model_Application();
67
68  private:
69   /// Map from string identifiers to created documents of an application
70   std::map<std::string, std::shared_ptr<Model_Document> > myDocs;
71   /// Path for the loaded by demand documents
72   std::string myPath;
73   /// Path for the loaded by demand documents
74   std::set<std::string> myLoadedByDemand;
75 };
76
77 #endif