1 // File: ModelAPI_Document.cxx
2 // Created: 28 Feb 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef ModelAPI_Document_H_
6 #define ModelAPI_Document_H_
10 #include <boost/shared_ptr.hpp>
14 class ModelAPI_Feature;
15 class ModelAPI_Object;
16 class ModelAPI_Result;
17 class ModelAPI_ResultConstruction;
18 class ModelAPI_ResultBody;
19 class ModelAPI_ResultPart;
22 /**\class Model_Document
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.
28 class ModelAPI_Document
31 //! Removes document data
32 virtual void close() = 0;
34 //! Adds to the document the new feature of the given feature id
35 //! \param creates feature and puts it in the document (if it is not action)
36 virtual boost::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
38 //! Removes the feature from the document
39 virtual void removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
41 ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
42 virtual boost::shared_ptr<ModelAPI_Document>
43 subDocument(std::string theDocID) = 0;
45 ///! Returns the id of the document
46 virtual const std::string& id() const = 0;
48 //! Returns the object in the group by the index (started from zero)
49 //! \param theGroupID group that contains an object
50 //! \param theIndex zero-based index of feature in the group
51 //! \param theHidden if it is true, it counts also the features that are not in tree
52 virtual boost::shared_ptr<ModelAPI_Object>
53 object(const std::string& theGroupID, const int theIndex, const bool theHidden = false) = 0;
55 //! Returns the number of objects in the group of objects
56 //! If theHidden is true, it counts also the features that are not in tree
57 virtual int size(const std::string& theGroupID, const bool theHidden = false) = 0;
59 /// To virtually destroy the fields of successors
60 virtual ~ModelAPI_Document()
64 /// Creates a construction cresults
65 virtual boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction(
66 const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
67 /// Creates a body results
68 virtual boost::shared_ptr<ModelAPI_ResultBody> createBody(
69 const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
70 /// Creates a part results
71 virtual boost::shared_ptr<ModelAPI_ResultPart> createPart(
72 const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
74 //! Returns a feature by result (owner of result)
75 virtual boost::shared_ptr<ModelAPI_Feature> feature(
76 const boost::shared_ptr<ModelAPI_Result>& theResult) = 0;
79 /// Only for SWIG wrapping it is here
80 MODELAPI_EXPORT ModelAPI_Document()
85 //! Pointer on document object
86 typedef boost::shared_ptr<ModelAPI_Document> DocumentPtr;