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;
15 /// Common groups identifiers
16 /// Group of parameters
17 static const std::string PARAMETERS_GROUP = "Parameters";
18 /// Group of constructions
19 static const std::string CONSTRUCTIONS_GROUP = "Construction";
21 static const std::string PARTS_GROUP = "Parts";
22 /// All created fetaures of the document (a history)
23 static const std::string FEATURES_GROUP = "Features";
25 /**\class Model_Document
27 * \brief Document for internal data structure of any object storage.
28 * Document contains all data that must be stored/retrived in the file.
29 * Also it provides acces to this data: open/save, transactions management etc.
31 class ModelAPI_Document
34 //! Loads the OCAF document from the file.
35 //! \param theFileName full name of the file to load
36 //! \param theStudyID identifier of the SALOME study to associate with loaded file
37 //! \returns true if file was loaded successfully
38 MODELAPI_EXPORT virtual bool load(const char* theFileName) = 0;
40 //! Saves the OCAF document to the file.
41 //! \param theFileName full name of the file to store
42 //! \returns true if file was stored successfully
43 MODELAPI_EXPORT virtual bool save(const char* theFileName) = 0;
45 //! Removes document data
46 MODELAPI_EXPORT virtual void close() = 0;
48 //! Starts a new operation (opens a tansaction)
49 MODELAPI_EXPORT virtual void startOperation() = 0;
50 //! Finishes the previously started operation (closes the transaction)
51 MODELAPI_EXPORT virtual void finishOperation() = 0;
52 //! Aborts the operation
53 MODELAPI_EXPORT virtual void abortOperation() = 0;
54 //! Returns true if operation has been started, but not yet finished or aborted
55 MODELAPI_EXPORT virtual bool isOperation() = 0;
56 //! Returns true if document was modified (since creation/opening)
57 MODELAPI_EXPORT virtual bool isModified() = 0;
59 //! Returns True if there are available Undos
60 MODELAPI_EXPORT virtual bool canUndo() = 0;
61 //! Undoes last operation
62 MODELAPI_EXPORT virtual void undo() = 0;
63 //! Returns True if there are available Redos
64 MODELAPI_EXPORT virtual bool canRedo() = 0;
65 //! Redoes last operation
66 MODELAPI_EXPORT virtual void redo() = 0;
68 //! Adds to the document the new feature of the given feature id
69 //! \param creates feature and puts it in the document
70 MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
72 //! Removes the feature from the document
73 MODELAPI_EXPORT virtual void removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
75 ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
76 MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document>
77 subDocument(std::string theDocID) = 0;
79 ///! Returns the id of hte document
80 MODELAPI_EXPORT virtual const std::string& id() const = 0;
82 //! Returns the feature in the group by the index (started from zero)
83 //! \param theGroupID group that contains a feature
84 //! \param theIndex zero-based index of feature in the group
85 //! \param isOperation if it is true, returns feature (not Object)
86 MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Feature>
87 feature(const std::string& theGroupID, const int theIndex, const bool isOperation = false) = 0;
89 //! Returns the number of features in the group
90 MODELAPI_EXPORT virtual int size(const std::string& theGroupID) = 0;
92 /// To virtually destroy the fields of successors
93 virtual ~ModelAPI_Document() {}
96 /// Only for SWIG wrapping it is here
97 MODELAPI_EXPORT ModelAPI_Document()
102 //! Pointer on document object
103 typedef boost::shared_ptr<ModelAPI_Document> DocumentPtr;