X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelAPI%2FModelAPI_Object.h;h=aba6567eb3a0d643409a36dc40644d2811650511;hb=67e9407be59cbfa36082e09f077f9da274c25bfe;hp=55ee0952733f50dbe8943d7c11f347b41e46414b;hpb=0b779059afbd6c2024e1453d3133044c52bea638;p=modules%2Fshaper.git diff --git a/src/ModelAPI/ModelAPI_Object.h b/src/ModelAPI/ModelAPI_Object.h index 55ee09527..aba6567eb 100644 --- a/src/ModelAPI/ModelAPI_Object.h +++ b/src/ModelAPI/ModelAPI_Object.h @@ -2,36 +2,87 @@ // Created: 19 May 2014 // Author: Mikhail PONIKAROV -#ifndef ModelAPI_Object_HeaderFile -#define ModelAPI_Object_HeaderFile +#ifndef ModelAPI_Object_H_ +#define ModelAPI_Object_H_ -#include "ModelAPI_Feature.h" +#include "ModelAPI.h" +#include "ModelAPI_Data.h" #include +class ModelAPI_Data; +class ModelAPI_Document; + /**\class ModelAPI_Object * \ingroup DataModel - * \brief Represents the result of some feature in the object browser - * under the specific folder. Just a reference to specific feature-operation - * with possibility to rename it. + * \brief Represents any object in the data model and in the object browser. + * + * It may be feature or result of the feature. User just may set name for it + * or change this name later. Generic class for Feature, Body, Parameter and other + * objects related to the features and their results. Contains attributes of this + * object in the "Data". */ -class ModelAPI_Object : public ModelAPI_Feature +class ModelAPI_Object { -public: + boost::shared_ptr myData; ///< manager of the data model of a feature + boost::shared_ptr myDoc; ///< document this object belongs to + public: + /// By default object is displayed in the object browser. + virtual bool isInHistory() + { + return true; + } - /// It is never located in history - MODELAPI_EXPORT virtual bool isInHistory() {return false;} + /// Returns the data manager of this object: attributes + virtual boost::shared_ptr data() const + { + return myData; + } - /// Reference to the feature-operation that produces this object - MODELAPI_EXPORT virtual boost::shared_ptr featureRef() = 0; + /// Returns true if object refers to the same data model instance + virtual bool isSame(const boost::shared_ptr& theObject) + { + return theObject.get() == this; + } - /// Returns the name of this object (by default equal to the name of feature) - MODELAPI_EXPORT virtual std::string getName() = 0; + /// Returns document this feature belongs to + virtual boost::shared_ptr document() const + { + return myDoc; + } - /// Defines the name of the object - MODELAPI_EXPORT virtual void setName(std::string theName) = 0; -}; + /// Returns the group identifier of this object + virtual std::string groupName() = 0; + + /// Called on change of any argument-attribute of this object + MODELAPI_EXPORT virtual void attributeChanged() + {} + + /// To use virtuality for destructors + virtual ~ModelAPI_Object() {} + + protected: + /// Sets the data manager of an object (document does) + virtual void setData(boost::shared_ptr theData) + { + myData = theData; + } + /// Sets the data manager of an object (document does) + virtual void setDoc(boost::shared_ptr theDoc) + { + myDoc = theDoc; + } + + /// removes all fields from this feature + MODELAPI_EXPORT virtual void erase() { + if (myData) myData->erase(); + setData(DataPtr()); + } + + friend class Model_Document; + +}; typedef boost::shared_ptr ObjectPtr;