Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / ModelAPI / ModelAPI_Document.h
1 // File:        ModelAPI_Document.cxx
2 // Created:     28 Feb 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef ModelAPI_Document_HeaderFile
6 #define ModelAPI_Document_HeaderFile
7
8 #include <ModelAPI.h>
9 #include <string>
10 #include <memory>
11
12 class ModelAPI_Feature;
13 class ModelAPI_Iterator;
14
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";
20 /// Group of parts
21 static const std::string PARTS_GROUP = "Parts";
22
23 /**\class Model_Document
24  * \ingroup DataModel
25  * \brief Document for internal data structure of any object storage. Corresponds to the SALOME study.
26  * Document contains all data of te SALOME Study specific to this module
27  * that must be written into the HDF file.
28  * Also it provides acces to this data: open/save, transactions management etc.
29  * to provide access to all stored data.
30  */
31 class ModelAPI_Document
32 {
33 public:
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;
39
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;
44
45   //! Removes document data
46   MODELAPI_EXPORT virtual void close() = 0;
47
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;
58
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;
67
68   //! Adds to the document the new feature of the given group id
69   //! \param theFeature a feature object that will be connected to the document in this method
70   //! \param theGroupID identifier of the groups of object
71   MODELAPI_EXPORT virtual void addFeature(std::shared_ptr<ModelAPI_Feature> theFeature,
72     const std::string theGroupID) = 0;
73
74   ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
75   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID) = 0;
76
77   ///! Creates an iterator of the features by the specific groups
78   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Iterator> featuresIterator(
79     const std::string theGroup) = 0;
80
81   ///! Returns the id of hte document
82   MODELAPI_EXPORT virtual const std::string& id() const = 0;
83
84   //! Returns the feature in the group by the index (started from zero)
85   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Feature> 
86     feature(const std::string& theGroupID, const int theIndex) = 0;
87
88 protected:
89   /// Only for SWIG wrapping it is here
90   MODELAPI_EXPORT ModelAPI_Document()
91   {
92   }
93   ;
94 };
95
96 #endif