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