Salome HOME
Test corrected according to changes in the API
[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 #include <list>
13
14 class ModelAPI_Feature;
15 class ModelAPI_Object;
16 class ModelAPI_Result;
17 class ModelAPI_ResultConstruction;
18 class ModelAPI_ResultBody;
19 class ModelAPI_ResultPart;
20 class ModelAPI_Data;
21
22 /**\class Model_Document
23  * \ingroup DataModel
24  * \brief Document for internal data structure of any object storage.
25  * Document contains all data that must be stored/retrived in the file.
26  * Also it provides acces to this data: open/save, transactions management etc.
27  */
28 class ModelAPI_Document
29 {
30 public:
31   //! Returns the kind of the document: "PartSet", "Part", or something else.
32   //! This kind is used for feature buttons enable/disable depending on active document
33   //! (it uses workbench "document" identifier in XML configuration file for this)
34   virtual const std::string& kind() const = 0;
35
36   //! Removes document data
37   virtual void close() = 0;
38
39   //! Adds to the document the new feature of the given feature id
40   //! \param creates feature and puts it in the document (if it is not action)
41   virtual boost::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
42
43   //! Removes the feature from the document
44   virtual void removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeature,
45                              const bool theCheck = true) = 0;
46
47   ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
48   virtual boost::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID) = 0;
49
50   ///! Returns the id of the document
51   virtual const std::string& id() const = 0;
52
53   //! Returns the object in the group by the index (started from zero)
54   //! \param theGroupID group that contains an object
55   //! \param theIndex zero-based index of feature in the group
56   //! \param theHidden if it is true, it counts also the features that are not in tree
57   virtual boost::shared_ptr<ModelAPI_Object> object(const std::string& theGroupID,
58                                                     const int theIndex,
59                                                     const bool theHidden = false) = 0;
60
61   //! Returns the number of objects in the group of objects
62   //! If theHidden is true, it counts also the features that are not in tree
63   virtual int size(const std::string& theGroupID, const bool theHidden = false) = 0;
64
65   /// To virtually destroy the fields of successors
66   virtual ~ModelAPI_Document()
67   {
68   }
69
70   /// Creates a construction cresults
71   virtual boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction(
72       const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
73   /// Creates a body results
74   virtual boost::shared_ptr<ModelAPI_ResultBody> createBody(
75       const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
76   /// Creates a part results
77   virtual boost::shared_ptr<ModelAPI_ResultPart> createPart(
78       const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
79
80   //! Returns a feature by result (owner of result)
81   virtual boost::shared_ptr<ModelAPI_Feature> feature(
82       const boost::shared_ptr<ModelAPI_Result>& theResult) = 0;
83
84   ///! Reutrns true is result was conecaled because of usage it by other object
85   virtual bool isConcealed(const boost::shared_ptr<ModelAPI_Object>& theResult) = 0;
86
87 protected:
88   /// Only for SWIG wrapping it is here
89   MODELAPI_EXPORT ModelAPI_Document()
90   {
91   }
92 };
93
94 //! Pointer on document object
95 typedef boost::shared_ptr<ModelAPI_Document> DocumentPtr;
96
97 #endif