Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom.git into Dev_0.7.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  *
22  * Application supports the formats and document management. It is uses OCAF-lke
23  * architecture and just implements specific features of the module.
24  */
25 class Model_Application : public TDocStd_Application
26 {
27 public:
28   // useful methods inside of the module
29
30   // CASCADE RTTI
31   /// Definition of "Handles" usage
32   /// \param Model_Application is the class name that is covered by the OCCT Handle
33   DEFINE_STANDARD_RTTI(Model_Application);
34
35   //! Retuns the application: one per process    
36   MODEL_EXPORT static Handle_Model_Application getApplication();
37   //! Returns the main document (on first call creates it) by the string identifier
38   MODEL_EXPORT const std::shared_ptr<Model_Document>& getDocument(std::string theDocID);
39   //! Returns true if document has been created
40   MODEL_EXPORT bool hasDocument(std::string theDocID);
41   //! Deletes the document from the application
42   MODEL_EXPORT void deleteDocument(std::string theDocID);
43   //! Deletes all documents existing in the application
44   MODEL_EXPORT void deleteAllDocuments();
45
46   //! Set path for the loaded by demand documents
47   void setLoadPath(std::string thePath);
48   //! Returns the path for the loaded by demand documents
49   const std::string& loadPath() const;
50   //! Defines that specified document must be loaded by demand
51   void setLoadByDemand(std::string theID);
52   //! Returns true if specified document must be loaded by demand
53   bool isLoadByDemand(std::string theID);
54   //! Closes and removes the documents that are not loaded by demand and
55   //! not in the given list
56   void removeUselessDocuments(std::list<std::shared_ptr<ModelAPI_Document> > theUsedDocs);
57
58  public:
59   // Redefined OCAF methods
60   //! Return name of resource (i.e. "Standard")
61   Standard_CString ResourcesName();
62   //! Return format (i.e "MDTV-Standard")
63   //! \param theFormats sequence of allowed formats for input/output
64   virtual void Formats(TColStd_SequenceOfExtendedString& theFormats);
65   //! Constructor
66   //! Use method GetInstance() method to obtain 
67   //! the static instance of the object (or derive your own application)
68   Model_Application();
69
70  private:
71   /// Map from string identifiers to created documents of an application
72   std::map<std::string, std::shared_ptr<Model_Document> > myDocs;
73   /// Path for the loaded by demand documents
74   std::string myPath;
75   /// Path for the loaded by demand documents
76   std::set<std::string> myLoadedByDemand;
77 };
78
79 #endif