Salome HOME
Issue #273: Add copyright string
[modules/shaper.git] / src / ModelAPI / ModelAPI_Document.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_Document.cxx
4 // Created:     28 Feb 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef ModelAPI_Document_H_
8 #define ModelAPI_Document_H_
9
10 #include <ModelAPI.h>
11 #include <string>
12 #include <memory>
13 #include <vector>
14 #include <list>
15
16 class ModelAPI_Feature;
17 class ModelAPI_Object;
18 class ModelAPI_Result;
19 class ModelAPI_ResultConstruction;
20 class ModelAPI_ResultBody;
21 class ModelAPI_ResultPart;
22 class ModelAPI_ResultGroup;
23 class ModelAPI_Data;
24
25 /**\class Model_Document
26  * \ingroup DataModel
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.
30  */
31 class ModelAPI_Document
32 {
33 public:
34   //! Returns the kind of the document: "PartSet", "Part", or something else.
35   //! This kind is used for feature buttons enable/disable depending on active document
36   //! (it uses workbench "document" identifier in XML configuration file for this)
37   virtual const std::string& kind() const = 0;
38
39   //! Removes document data
40   //! \param theForever if it is false, document is just hiden (to keep possibility make it back on Undo/Redo)
41   virtual void close(const bool theForever = false) = 0;
42
43   //! Adds to the document the new feature of the given feature id
44   //! \param creates feature and puts it in the document (if it is not action)
45   virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
46
47   //! Removes the feature from the document
48   virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature,
49                              const bool theCheck = true) = 0;
50
51   ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
52   virtual std::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID) = 0;
53
54   ///! Returns the id of the document
55   virtual const std::string& id() const = 0;
56
57   //! Returns the object in the group by the index (started from zero)
58   //! \param theGroupID group that contains an object
59   //! \param theIndex zero-based index of feature in the group
60   //! \param theHidden if it is true, it counts also the features that are not in tree
61   virtual std::shared_ptr<ModelAPI_Object> object(const std::string& theGroupID,
62                                                     const int theIndex,
63                                                     const bool theHidden = false) = 0;
64
65   //! Returns the number of objects in the group of objects
66   //! If theHidden is true, it counts also the features that are not in tree
67   virtual int size(const std::string& theGroupID, const bool theHidden = false) = 0;
68
69   /// To virtually destroy the fields of successors
70   virtual ~ModelAPI_Document()
71   {
72   }
73
74   /// Creates a construction cresults
75   virtual std::shared_ptr<ModelAPI_ResultConstruction> createConstruction(
76       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
77   /// Creates a body results
78   virtual std::shared_ptr<ModelAPI_ResultBody> createBody(
79       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
80   /// Creates a part results
81   virtual std::shared_ptr<ModelAPI_ResultPart> createPart(
82       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
83   /// Creates a group results
84   virtual std::shared_ptr<ModelAPI_ResultGroup> createGroup(
85       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
86
87   //! Returns a feature by result (owner of result)
88   virtual std::shared_ptr<ModelAPI_Feature> feature(
89       const std::shared_ptr<ModelAPI_Result>& theResult) = 0;
90
91 protected:
92   /// Only for SWIG wrapping it is here
93   MODELAPI_EXPORT ModelAPI_Document()
94   {
95   }
96 };
97
98 //! Pointer on document object
99 typedef std::shared_ptr<ModelAPI_Document> DocumentPtr;
100
101 #endif