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.
22 * Application supports the formats and document management. It is uses OCAF-lke
23 * architecture and just implements specific features of the module.
25 class Model_Application : public TDocStd_Application
28 // useful methods inside of the module
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);
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();
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);
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);
66 //! Use method GetInstance() method to obtain
67 //! the static instance of the object (or derive your own application)
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
75 /// Path for the loaded by demand documents
76 std::set<std::string> myLoadedByDemand;