]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/ModelAPI_Document.h
Salome HOME
Initial version of redesign of working with results
[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 <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
18 /// Common groups identifiers
19 /// Group of parameters
20 static const std::string PARAMETERS_GROUP = "Parameters";
21 /// Group of constructions
22 static const std::string CONSTRUCTIONS_GROUP = "Construction";
23 /// Group of parts
24 static const std::string PARTS_GROUP = "Parts";
25 /// Group of bodies
26 static const std::string BODIES_GROUP = "Bodies";
27 /// All created fetaures of the document (a history)
28 static const std::string FEATURES_GROUP = "Features";
29
30 /**\class Model_Document
31  * \ingroup DataModel
32  * \brief Document for internal data structure of any object storage.
33  * Document contains all data that must be stored/retrived in the file.
34  * Also it provides acces to this data: open/save, transactions management etc.
35  */
36 class ModelAPI_Document
37 {
38 public:
39   //! Loads the OCAF document from the file.
40   //! \param theFileName full name of the file to load
41   //! \param theStudyID identifier of the SALOME study to associate with loaded file
42   //! \returns true if file was loaded successfully
43   virtual bool load(const char* theFileName) = 0;
44
45   //! Saves the OCAF document to the file.
46   //! \param theFileName full name of the file to store
47   //! \returns true if file was stored successfully
48   virtual bool save(const char* theFileName) = 0;
49
50   //! Removes document data
51   virtual void close() = 0;
52
53   //! Starts a new operation (opens a tansaction)
54   virtual void startOperation() = 0;
55   //! Finishes the previously started operation (closes the transaction)
56   virtual void finishOperation() = 0;
57   //! Aborts the operation 
58   virtual void abortOperation() = 0;
59   //! Returns true if operation has been started, but not yet finished or aborted
60   virtual bool isOperation() = 0;
61   //! Returns true if document was modified (since creation/opening)
62   virtual bool isModified() = 0;
63
64   //! Returns True if there are available Undos
65   virtual bool canUndo() = 0;
66   //! Undoes last operation
67   virtual void undo() = 0;
68   //! Returns True if there are available Redos
69   virtual bool canRedo() = 0;
70   //! Redoes last operation
71   virtual void redo() = 0;
72
73   //! Adds to the document the new feature of the given feature id
74   //! \param creates feature and puts it in the document (if it is not action)
75   virtual boost::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
76
77   //! Removes the feature from the document
78   virtual void removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
79
80   ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
81   virtual boost::shared_ptr<ModelAPI_Document> 
82     subDocument(std::string theDocID) = 0;
83
84   ///! Returns the id of the document
85   virtual const std::string& id() const = 0;
86
87   //! Returns the object in the group by the index (started from zero)
88   //! \param theGroupID group that contains an object
89   //! \param theIndex zero-based index of feature in the group
90   virtual boost::shared_ptr<ModelAPI_Object> 
91     object(const std::string& theGroupID, const int theIndex) = 0;
92
93   //! Returns the number of objects in the group of objects
94   virtual int size(const std::string& theGroupID) = 0;
95
96   /// To virtually destroy the fields of successors
97   virtual ~ModelAPI_Document() {}
98
99   /// Creates a construction cresults
100   virtual boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction() = 0;
101
102 protected:
103   /// Only for SWIG wrapping it is here
104   MODELAPI_EXPORT ModelAPI_Document()
105   {}
106 };
107
108
109 //! Pointer on document object
110 typedef boost::shared_ptr<ModelAPI_Document> DocumentPtr;
111
112
113 #endif