]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/ModelAPI_Document.h
Salome HOME
Define guards are corrected according to the code style
[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_H_
6 #define ModelAPI_Document_H_
7
8 #include <ModelAPI.h>
9 #include <string>
10 #include <boost/shared_ptr.hpp>
11 #include <vector>
12
13 class ModelAPI_Feature;
14 class ModelAPI_Object;
15 class ModelAPI_Result;
16 class ModelAPI_ResultConstruction;
17 class ModelAPI_ResultBody;
18 class ModelAPI_ResultPart;
19 class ModelAPI_Data;
20
21 /**\class Model_Document
22  * \ingroup DataModel
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.
26  */
27 class ModelAPI_Document
28 {
29 public:
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;
35
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;
40
41   //! Removes document data
42   virtual void close() = 0;
43
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;
54
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;
63
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;
67
68   //! Removes the feature from the document
69   virtual void removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
70
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;
74
75   ///! Returns the id of the document
76   virtual const std::string& id() const = 0;
77
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;
84
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;
88
89   /// To virtually destroy the fields of successors
90   virtual ~ModelAPI_Document() {}
91
92   /// Creates a construction cresults
93   virtual boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction(
94     const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
95   /// Creates a body results
96   virtual boost::shared_ptr<ModelAPI_ResultBody> createBody(
97     const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
98   /// Creates a part results
99   virtual boost::shared_ptr<ModelAPI_ResultPart> createPart(
100     const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
101
102   //! Returns a feature by result (owner of result)
103   virtual boost::shared_ptr<ModelAPI_Feature> feature(
104     const boost::shared_ptr<ModelAPI_Result>& theResult) = 0;
105
106 protected:
107   /// Only for SWIG wrapping it is here
108   MODELAPI_EXPORT ModelAPI_Document()
109   {}
110 };
111
112
113 //! Pointer on document object
114 typedef boost::shared_ptr<ModelAPI_Document> DocumentPtr;
115
116
117 #endif