1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_Application.hxx
4 // Created: 28 Dec 2011
5 // Author: Mikhail PONIKAROV
8 #ifndef Model_Application_H_
9 #define Model_Application_H_
11 #include <Model_Document.h>
12 #include <TDocStd_Application.hxx>
15 // Define handle class
16 DEFINE_STANDARD_HANDLE(Model_Application, TDocStd_Application)
18 /**\class Model_Application
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.
24 class Model_Application : public TDocStd_Application
27 // useful methods inside of the module
30 DEFINE_STANDARD_RTTI(Model_Application)
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();
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);
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);
64 //! Use method GetInstance() method to obtain
65 //! the static instance of the object (or derive your own application)
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
73 /// Path for the loaded by demand documents
74 std::set<std::string> myLoadedByDemand;