Salome HOME
Remove Boost shared_ptr, use std instead
[modules/shaper.git] / src / Model / Model_Document.h
1 // File:        Model_Document.cxx
2 // Created:     28 Feb 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef Model_Document_HeaderFile
6 #define Model_Document_HeaderFile
7
8 #include <Model.h>
9 #include <ModelAPI_Document.h>
10 #include <TDocStd_Document.hxx>
11
12 class Handle_Model_Document;
13
14 /**\class Model_Document
15  * \ingroup DataModel
16  * \brief Document for internal data structure of any object storage. Corresponds to the SALOME study.
17  * Document contains all data of te SALOME Study specific to this module
18  * that must be written into the HDF file.
19  * Also it provides acces to this data: open/save, transactions management etc.
20  * to provide access to all stored data.
21  */
22
23 class Model_Document: public ModelAPI_Document
24 {
25 public:
26
27   //! Creates new document with binary file format
28   Model_Document();
29   //! Deletes all high-level data, managed this document
30   ~Model_Document();
31
32   //! Loads the OCAF document from the file.
33   //! \param theFileName full name of the file to load
34   //! \param theStudyID identifier of the SALOME study to associate with loaded file
35   //! \returns true if file was loaded successfully
36   MODEL_EXPORT bool Load(const char* theFileName);
37
38   //! Saves the OCAF document to the file.
39   //! \param theFileName full name of the file to store
40   //! \returns true if file was stored successfully
41   MODEL_EXPORT bool Save(const char* theFileName);
42
43   //! Removes document data
44   MODEL_EXPORT void Close();
45
46   //! Starts a new operation (opens a tansaction)
47   MODEL_EXPORT void StartOperation();
48   //! Finishes the previously started operation (closes the transaction)
49   MODEL_EXPORT void FinishOperation();
50   //! Aborts the operation 
51   MODEL_EXPORT void AbortOperation();
52   //! Returns true if operation has been started, but not yet finished or aborted
53   MODEL_EXPORT bool IsOperation();
54   //! Returns true if document was modified (since creation/opening)
55   MODEL_EXPORT bool IsModified();
56
57   //! Returns True if there are available Undos
58   MODEL_EXPORT bool CanUndo();
59   //! Undoes last operation
60   MODEL_EXPORT void Undo();
61   //! Returns True if there are available Redos
62   MODEL_EXPORT bool CanRedo();
63   //! Redoes last operation
64   MODEL_EXPORT void Redo();
65
66   //! Adds to the document the new object of the given group id
67   //! \param theFeature a feature object that will be connected to the document in this method
68   //! \param theGroupID identifier of the groups of objects (must be greater than zero)
69   MODEL_EXPORT virtual void AddObject(std::shared_ptr<ModelAPI_Feature> theFeature,
70     const int theGroupID);
71
72 protected:
73
74 private:
75   Handle_TDocStd_Document myDoc; ///< OCAF document
76   int myTransactionsAfterSave; ///< number of transactions after the last "save" call, used for "IsModified" method
77 };
78
79 #endif