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