1 // File: ModelAPI_Document.cxx
2 // Created: 28 Feb 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef ModelAPI_Document_H_
6 #define ModelAPI_Document_H_
10 #include <boost/shared_ptr.hpp>
13 class ModelAPI_Feature;
14 class ModelAPI_Object;
15 class ModelAPI_Result;
16 class ModelAPI_ResultConstruction;
17 class ModelAPI_ResultBody;
18 class ModelAPI_ResultPart;
21 /**\class Model_Document
23 * \brief Document for internal data structure of any object storage.
24 * Document contains all data that must be stored/retrived in the file.
25 * Also it provides acces to this data: open/save, transactions management etc.
27 class ModelAPI_Document
30 //! Loads the OCAF document from the file.
31 //! \param theFileName full name of the file to load
32 //! \param theStudyID identifier of the SALOME study to associate with loaded file
33 //! \returns true if file was loaded successfully
34 virtual bool load(const char* theFileName) = 0;
36 //! Saves the OCAF document to the file.
37 //! \param theFileName full name of the file to store
38 //! \returns true if file was stored successfully
39 virtual bool save(const char* theFileName) = 0;
41 //! Removes document data
42 virtual void close() = 0;
44 //! Starts a new operation (opens a tansaction)
45 virtual void startOperation() = 0;
46 //! Finishes the previously started operation (closes the transaction)
47 virtual void finishOperation() = 0;
48 //! Aborts the operation
49 virtual void abortOperation() = 0;
50 //! Returns true if operation has been started, but not yet finished or aborted
51 virtual bool isOperation() = 0;
52 //! Returns true if document was modified (since creation/opening)
53 virtual bool isModified() = 0;
55 //! Returns True if there are available Undos
56 virtual bool canUndo() = 0;
57 //! Undoes last operation
58 virtual void undo() = 0;
59 //! Returns True if there are available Redos
60 virtual bool canRedo() = 0;
61 //! Redoes last operation
62 virtual void redo() = 0;
64 //! Adds to the document the new feature of the given feature id
65 //! \param creates feature and puts it in the document (if it is not action)
66 virtual boost::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
68 //! Removes the feature from the document
69 virtual void removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
71 ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
72 virtual boost::shared_ptr<ModelAPI_Document>
73 subDocument(std::string theDocID) = 0;
75 ///! Returns the id of the document
76 virtual const std::string& id() const = 0;
78 //! Returns the object in the group by the index (started from zero)
79 //! \param theGroupID group that contains an object
80 //! \param theIndex zero-based index of feature in the group
81 //! \param theHidden if it is true, it counts also the features that are not in tree
82 virtual boost::shared_ptr<ModelAPI_Object>
83 object(const std::string& theGroupID, const int theIndex, const bool theHidden = false) = 0;
85 //! Returns the number of objects in the group of objects
86 //! If theHidden is true, it counts also the features that are not in tree
87 virtual int size(const std::string& theGroupID, const bool theHidden = false) = 0;
89 /// To virtually destroy the fields of successors
90 virtual ~ModelAPI_Document()
94 /// Creates a construction cresults
95 virtual boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction(
96 const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
97 /// Creates a body results
98 virtual boost::shared_ptr<ModelAPI_ResultBody> createBody(
99 const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
100 /// Creates a part results
101 virtual boost::shared_ptr<ModelAPI_ResultPart> createPart(
102 const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
104 //! Returns a feature by result (owner of result)
105 virtual boost::shared_ptr<ModelAPI_Feature> feature(
106 const boost::shared_ptr<ModelAPI_Result>& theResult) = 0;
109 /// Only for SWIG wrapping it is here
110 MODELAPI_EXPORT ModelAPI_Document()
115 //! Pointer on document object
116 typedef boost::shared_ptr<ModelAPI_Document> DocumentPtr;