1 // File: ModelAPI_Document.cxx
2 // Created: 28 Feb 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef ModelAPI_Document_HeaderFile
6 #define ModelAPI_Document_HeaderFile
10 #include <boost/shared_ptr.hpp>
13 class ModelAPI_Feature;
14 class ModelAPI_Object;
15 class ModelAPI_Result;
16 class ModelAPI_ResultConstruction;
18 /**\class Model_Document
20 * \brief Document for internal data structure of any object storage.
21 * Document contains all data that must be stored/retrived in the file.
22 * Also it provides acces to this data: open/save, transactions management etc.
24 class ModelAPI_Document
27 //! Loads the OCAF document from the file.
28 //! \param theFileName full name of the file to load
29 //! \param theStudyID identifier of the SALOME study to associate with loaded file
30 //! \returns true if file was loaded successfully
31 virtual bool load(const char* theFileName) = 0;
33 //! Saves the OCAF document to the file.
34 //! \param theFileName full name of the file to store
35 //! \returns true if file was stored successfully
36 virtual bool save(const char* theFileName) = 0;
38 //! Removes document data
39 virtual void close() = 0;
41 //! Starts a new operation (opens a tansaction)
42 virtual void startOperation() = 0;
43 //! Finishes the previously started operation (closes the transaction)
44 virtual void finishOperation() = 0;
45 //! Aborts the operation
46 virtual void abortOperation() = 0;
47 //! Returns true if operation has been started, but not yet finished or aborted
48 virtual bool isOperation() = 0;
49 //! Returns true if document was modified (since creation/opening)
50 virtual bool isModified() = 0;
52 //! Returns True if there are available Undos
53 virtual bool canUndo() = 0;
54 //! Undoes last operation
55 virtual void undo() = 0;
56 //! Returns True if there are available Redos
57 virtual bool canRedo() = 0;
58 //! Redoes last operation
59 virtual void redo() = 0;
61 //! Adds to the document the new feature of the given feature id
62 //! \param creates feature and puts it in the document (if it is not action)
63 virtual boost::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
65 //! Removes the feature from the document
66 virtual void removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
68 ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
69 virtual boost::shared_ptr<ModelAPI_Document>
70 subDocument(std::string theDocID) = 0;
72 ///! Returns the id of the document
73 virtual const std::string& id() const = 0;
75 //! Returns the object in the group by the index (started from zero)
76 //! \param theGroupID group that contains an object
77 //! \param theIndex zero-based index of feature in the group
78 virtual boost::shared_ptr<ModelAPI_Object>
79 object(const std::string& theGroupID, const int theIndex) = 0;
81 //! Returns the number of objects in the group of objects
82 virtual int size(const std::string& theGroupID) = 0;
84 /// To virtually destroy the fields of successors
85 virtual ~ModelAPI_Document() {}
87 /// Creates a construction cresults
88 virtual boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction() = 0;
91 /// Only for SWIG wrapping it is here
92 MODELAPI_EXPORT ModelAPI_Document()
97 //! Pointer on document object
98 typedef boost::shared_ptr<ModelAPI_Document> DocumentPtr;