1 // File: ModelAPI_Feature.hxx
2 // Created: 21 Mar 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef ModelAPI_Feature_HeaderFile
6 #define ModelAPI_Feature_HeaderFile
8 #include "ModelAPI_Object.h"
9 #include "ModelAPI_PluginManager.h"
13 #include <boost/shared_ptr.hpp>
16 class ModelAPI_Document;
17 class ModelAPI_Result;
19 /**\class ModelAPI_Feature
21 * \brief Feature function that represents the particular functionality
22 * of this operation. Produces results by the arguments.
24 class ModelAPI_Feature : public ModelAPI_Object
26 ///< list of current results of this feature
27 std::list<boost::shared_ptr<ModelAPI_Result> > myResults;
29 /// Returns the unique kind of a feature (like "Point")
30 virtual const std::string& getKind() = 0;
32 /// Returns the group identifier of all features
33 static std::string group()
34 {static std::string MY_GROUP = "Features"; return MY_GROUP;}
36 /// Returns the group identifier of this result
37 virtual std::string groupName() { return group(); }
39 /// Request for initialization of data model of the feature: adding all attributes
40 virtual void initAttributes() = 0;
42 /// Computes or recomputes the results
43 virtual void execute() = 0;
45 /// returns the current results of the feature
46 MODELAPI_EXPORT const std::list<boost::shared_ptr<ModelAPI_Result> >& results();
47 /// returns the first result in the list or NULL reference
48 MODELAPI_EXPORT boost::shared_ptr<ModelAPI_Result> firstResult();
49 /// sets the alone result
50 MODELAPI_EXPORT void setResult(const boost::shared_ptr<ModelAPI_Result>& theResult);
51 /// sets the result by index (zero based), results before this must be set before
52 MODELAPI_EXPORT void setResult(
53 const boost::shared_ptr<ModelAPI_Result>& theResult, const int theIndex);
55 /// Returns true if this feature must not be created: this is just an action
56 /// that is not stored in the features history and data model (like "delete part").
57 virtual bool isAction() {return false;}
59 /// Must return document where the new feature must be added to
60 /// By default it is current document
61 MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document> documentToAdd();
63 /// To virtually destroy the fields of successors
64 MODELAPI_EXPORT virtual ~ModelAPI_Feature();
67 //! Pointer on feature object
68 typedef boost::shared_ptr<ModelAPI_Feature> FeaturePtr;