Base class of all classes with properties. More...

#include <PropertyContainer.h>

Public Member Functions

virtual App::PropertyaddDynamicProperty (const char *type, const char *name=0, const char *group=0, const char *doc=0, short attr=0, bool ro=false, bool hidden=false)
 
virtual App::PropertygetDynamicPropertyByName (const char *name) const
 
DynamicProperty::PropData getDynamicPropertyData (const Property *prop) const
 
virtual std::vector< std::string > getDynamicPropertyNames () const
 
virtual std::string getFullName () const
 
virtual unsigned int getMemSize (void) const
 This method is used to get the size of objects It is not meant to have the exact size, it is more or less an estimation which runs fast! Is it two bytes or a GB? More...
 
virtual PropertygetPropertyByName (const char *name) const
 find a property by its name More...
 
virtual const char * getPropertyDocumentation (const char *name) const
 get the Group of a named Property More...
 
virtual const char * getPropertyDocumentation (const Property *prop) const
 get the Group of a Property More...
 
virtual const char * getPropertyGroup (const char *name) const
 get the Group of a named Property More...
 
virtual const char * getPropertyGroup (const Property *prop) const
 get the Group of a Property More...
 
virtual void getPropertyList (std::vector< Property * > &List) const
 get all properties of the class (including properties of the parent) More...
 
virtual void getPropertyMap (std::map< std::string, Property * > &Map) const
 get all properties of the class (including properties of the parent) More...
 
virtual const char * getPropertyName (const Property *prop) const
 get the name of a property More...
 
const char * getPropertyPrefix () const
 
virtual short getPropertyType (const char *name) const
 get the Type of a named Property More...
 
virtual short getPropertyType (const Property *prop) const
 get the Type of a Property More...
 
bool isHidden (const char *name) const
 check if the named property is hidden More...
 
bool isHidden (const Property *prop) const
 check if the property is hidden More...
 
bool isReadOnly (const char *name) const
 check if the named property is read-only More...
 
bool isReadOnly (const Property *prop) const
 check if the property is read-only More...
 
virtual void onPropertyStatusChanged (const Property &prop, unsigned long oldStatus)
 
 PropertyContainer ()
 A constructor. More...
 
virtual bool removeDynamicProperty (const char *name)
 
virtual void Restore (Base::XMLReader &reader)
 This method is used to restore properties from an XML document. More...
 
virtual void Save (Base::Writer &writer) const
 This method is used to save properties to an XML document. More...
 
void setPropertyPrefix (const char *prefix)
 
void setPropertyStatus (unsigned char bit, bool value)
 set the Status bit of all properties at once More...
 
virtual ~PropertyContainer ()
 A destructor. More...
 
- Public Member Functions inherited from Base::Persistence
void dumpToStream (std::ostream &stream, int compression)
 
virtual Base::Type getTypeId (void) const
 
virtual void RestoreDocFile (Reader &)
 This method is used to restore large amounts of data from a file In this method you simply stream in your SaveDocFile() saved data. More...
 
void restoreFromStream (std::istream &stream)
 
virtual void SaveDocFile (Writer &) const
 This method is used to save large amounts of data to a binary file. More...
 
- Public Member Functions inherited from Base::BaseClass
 BaseClass ()
 Construction. More...
 
virtual PyObjectgetPyObject (void)
 This method returns the Python wrapper for a C++ object. More...
 
bool isDerivedFrom (const Type type) const
 
virtual void setPyObject (PyObject *)
 
virtual ~BaseClass ()
 Destruction. More...
 

Protected Member Functions

virtual const PropertyDatagetPropertyData (void) const
 
virtual void handleChangedPropertyName (Base::XMLReader &reader, const char *TypeName, const char *PropName)
 PropertyContainer::handleChangedPropertyName is called during restore to possibly fix reading of older versions of this property container. More...
 
virtual void handleChangedPropertyType (Base::XMLReader &reader, const char *TypeName, Property *prop)
 PropertyContainer::handleChangedPropertyType is called during restore to possibly fix reading of older versions of the property container. More...
 
virtual void onBeforeChange (const Property *)
 get called before the value is changed More...
 
virtual void onChanged (const Property *)
 get called by the container when a property has changed More...
 

Static Protected Member Functions

static const PropertyDatagetPropertyDataPtr (void)
 
- Static Protected Member Functions inherited from Base::BaseClass
static void initSubclass (Base::Type &toInit, const char *ClassName, const char *ParentName, Type::instantiationMethod method=nullptr)
 

Protected Attributes

DynamicProperty dynamicProps
 

Friends

class DynamicProperty
 
class Property
 

Additional Inherited Members

- Static Public Member Functions inherited from Base::Persistence
static void * create (void)
 
static std::string encodeAttribute (const std::string &)
 Encodes an attribute upon saving. More...
 
static Base::Type getClassTypeId (void)
 
static void init (void)
 
- Static Public Member Functions inherited from Base::BaseClass
static void * create (void)
 
static Type getClassTypeId (void)
 
static void init (void)
 

Detailed Description

Base class of all classes with properties.

Constructor & Destructor Documentation

◆ PropertyContainer()

PropertyContainer::PropertyContainer ( )

A constructor.

A more elaborate description of the constructor.

◆ ~PropertyContainer()

PropertyContainer::~PropertyContainer ( )
virtual

A destructor.

A more elaborate description of the destructor.

Member Function Documentation

◆ addDynamicProperty()

App::Property * PropertyContainer::addDynamicProperty ( const char *  type,
const char *  name = 0,
const char *  group = 0,
const char *  doc = 0,
short  attr = 0,
bool  ro = false,
bool  hidden = false 
)
virtual

◆ getDynamicPropertyByName()

◆ getDynamicPropertyData()

DynamicProperty::PropData App::PropertyContainer::getDynamicPropertyData ( const Property prop) const

◆ getDynamicPropertyNames()

virtual std::vector<std::string> App::PropertyContainer::getDynamicPropertyNames ( ) const
virtual

◆ getFullName()

virtual std::string App::PropertyContainer::getFullName ( ) const
virtual

◆ getMemSize()

unsigned int PropertyContainer::getMemSize ( void  ) const
virtual

This method is used to get the size of objects It is not meant to have the exact size, it is more or less an estimation which runs fast! Is it two bytes or a GB?

Implements Base::Persistence.

Reimplemented in Sketcher::SketchObject, App::Document, TechDraw::DrawTemplate, TechDraw::DrawSVGTemplate, and TechDraw::DrawParametricTemplate.

References getPropertyMap().

Referenced by App::Document::getMemSize().

◆ getPropertyByName()

◆ getPropertyData()

const PropertyData & PropertyContainer::getPropertyData ( void  ) const
protectedvirtual

◆ getPropertyDataPtr()

const PropertyData * PropertyContainer::getPropertyDataPtr ( void  )
staticprotected

◆ getPropertyDocumentation() [1/2]

const char * PropertyContainer::getPropertyDocumentation ( const char *  name) const
virtual

◆ getPropertyDocumentation() [2/2]

◆ getPropertyGroup() [1/2]

const char * PropertyContainer::getPropertyGroup ( const char *  name) const
virtual

◆ getPropertyGroup() [2/2]

const char * PropertyContainer::getPropertyGroup ( const Property prop) const
virtual

◆ getPropertyList()

void PropertyContainer::getPropertyList ( std::vector< Property * > &  List) const
virtual

◆ getPropertyMap()

void PropertyContainer::getPropertyMap ( std::map< std::string, Property * > &  Map) const
virtual

◆ getPropertyName()

const char * PropertyContainer::getPropertyName ( const Property prop) const
virtual

◆ getPropertyPrefix()

const char* App::PropertyContainer::getPropertyPrefix ( ) const

◆ getPropertyType() [1/2]

short PropertyContainer::getPropertyType ( const char *  name) const
virtual

get the Type of a named Property

Reimplemented in App::ExtensionContainer.

References getPropertyByName(), and getPropertyType().

◆ getPropertyType() [2/2]

short PropertyContainer::getPropertyType ( const Property prop) const
virtual

◆ handleChangedPropertyName()

void PropertyContainer::handleChangedPropertyName ( Base::XMLReader reader,
const char *  TypeName,
const char *  PropName 
)
protectedvirtual

PropertyContainer::handleChangedPropertyName is called during restore to possibly fix reading of older versions of this property container.

This method is typically called if the property on file has changed its name in more recent versions.

The default implementation does nothing.

Parameters
readerThe XML stream to read from.
TypeNameName of property type on file.
PropNameName of property on file that does not exist in the container anymore.

Reimplemented in TechDraw::DrawViewPart, TechDraw::DrawViewBalloon, Surface::Extend, PartDesign::FeaturePrimitive, PartDesign::Boolean, Part::Part2DObject, Part::Datum, Part::BodyBase, App::LinkElement, App::Link, and Fem::FemAnalysis.

Referenced by Fem::FemAnalysis::handleChangedPropertyName(), Part::BodyBase::handleChangedPropertyName(), Surface::Extend::handleChangedPropertyName(), TechDraw::DrawViewBalloon::handleChangedPropertyName(), TechDraw::DrawViewPart::handleChangedPropertyName(), and Restore().

◆ handleChangedPropertyType()

void PropertyContainer::handleChangedPropertyType ( Base::XMLReader reader,
const char *  TypeName,
Property prop 
)
protectedvirtual

PropertyContainer::handleChangedPropertyType is called during restore to possibly fix reading of older versions of the property container.

This method is typically called if the property on file has changed its type in more recent versions.

The default implementation does nothing.

Parameters
readerThe XML stream to read from.
TypeNameName of property type on file.
propPointer to property to restore. Its type differs from TypeName.

Reimplemented in TechDraw::DrawViewBalloon, TechDraw::DrawView, TechDraw::DrawProjGroup, TechDraw::DrawPage, PartDesign::SubShapeBinder, PartDesign::ShapeBinder, Part::Part2DObject, TechDrawGui::ViewProviderViewPart, TechDrawGui::ViewProviderRichAnno, TechDrawGui::ViewProviderLeader, TechDrawGui::ViewProviderDimension, TechDrawGui::ViewProviderBalloon, TechDraw::DrawViewAnnotation, TechDraw::DrawTile, PartGui::ViewProvider2DObjectGrid, Part::Thickness, Part::Mirroring, and TechDraw::DrawViewDimension.

Referenced by PartDesign::SubShapeBinder::handleChangedPropertyType(), and Restore().

◆ isHidden() [1/2]

bool PropertyContainer::isHidden ( const char *  name) const

check if the named property is hidden

References getPropertyType(), and App::Prop_Hidden.

◆ isHidden() [2/2]

bool PropertyContainer::isHidden ( const Property prop) const

check if the property is hidden

References getPropertyType(), and App::Prop_Hidden.

Referenced by Gui::Dialog::find_placement::operator()().

◆ isReadOnly() [1/2]

bool PropertyContainer::isReadOnly ( const char *  name) const

check if the named property is read-only

References getPropertyType(), and App::Prop_ReadOnly.

◆ isReadOnly() [2/2]

◆ onBeforeChange()

◆ onChanged()

virtual void App::PropertyContainer::onChanged ( const Property )
protectedvirtual

get called by the container when a property has changed

Reimplemented in App::DocumentObject, App::Document, App::TextDocument, App::MeasureDistance, App::ExtensionContainer, TechDrawGui::ViewProviderTemplate, TechDrawGui::ViewProviderPage, TechDrawGui::ViewProviderHatch, TechDrawGui::ViewProviderGeomHatch, TechDrawGui::ViewProviderDrawingView, TechDraw::LandmarkDimension, TechDraw::DrawViewSymbol, TechDraw::DrawViewSection, TechDraw::DrawViewPart, TechDraw::DrawViewMulti, TechDraw::DrawViewDimension, TechDraw::DrawViewDetail, TechDraw::DrawViewBalloon, TechDraw::DrawView, TechDraw::DrawProjGroupItem, TechDraw::DrawProjGroup, TechDraw::DrawPage, TechDraw::DrawLeaderLine, TechDraw::DrawHatch, TechDraw::DrawGeomHatch, Surface::Extend, SketcherGui::ViewProviderSketch, PartDesignGui::ViewProviderBoolean, PartDesignGui::ViewProviderBody, PartDesignGui::ViewProvider, PartDesign::SubShapeBinder, PartDesign::FeaturePrimitive, PartDesign::Boolean, PartDesign::Point, PartDesign::Body, PartGui::ViewProviderPartExt, Part::Primitive, Part::Feature, Part::Revolution, Part::BodyBase, Gui::ViewProviderPlacement, Gui::ViewProviderPart, Gui::ViewProviderLink, Gui::ViewProviderDocumentObject, TechDrawGui::ViewProviderViewSection, TechDrawGui::ViewProviderViewPart, TechDrawGui::ViewProviderProjGroup, TechDrawGui::ViewProviderImage, TechDraw::DrawWeldSymbol, TechDraw::DrawViewSpreadsheet, TechDraw::DrawViewImage, TechDraw::DrawViewDimExtent, TechDraw::DrawViewCollection, TechDraw::DrawViewClip, TechDraw::DrawViewAnnotation, TechDraw::DrawTileWeld, TechDraw::DrawTile, TechDraw::DrawTemplate, TechDraw::DrawSVGTemplate, TechDraw::DrawRichAnno, TechDraw::DrawParametricTemplate, SketcherGui::ViewProviderCustom, Sandbox::SandboxObject, RobotGui::ViewProviderRobotObject, Robot::TrajectoryObject, Robot::TrajectoryDressUpObject, Robot::RobotObject, Robot::Edge2TracObject, PointsGui::ViewProviderPoints, Points::Feature, PathGui::ViewProviderPath, Path::Feature, PartDesignGui::ViewProviderDatumPoint, PartDesign::ProfileBased, PartDesign::Hole, PartDesign::DressUp, PartDesign::FeatureBase, PartDesign::Plane, PartDesign::Line, PartGui::ViewProviderSpline, PartGui::ViewProviderPartReference, PartGui::ViewProviderCustom, PartGui::ViewProvider2DObjectGrid, Part::Wedge, Part::Spiral, Part::Helix, Part::Sweep, Part::Loft, Part::RuledSurface, Part::Box, Part::Mirroring, MeshGui::ViewProviderMeshNode, MeshGui::ViewProviderMeshDefects, MeshGui::ViewProviderMeshCurvature, MeshGui::ViewProviderMesh, Mesh::Feature, InspectionGui::ViewProviderInspection, FemGui::ViewProviderFemPostObject, FemGui::ViewProviderFemPostFunction, FemGui::ViewProviderFemPostFunctionProvider, FemGui::ViewProviderFemMesh, FemGui::ViewProviderFemConstraint, Fem::FemPostPipeline, Fem::FemPostSphereFunction, Fem::FemPostPlaneFunction, Fem::FemPostFunctionProvider, Fem::FemPostCutFilter, Fem::FemPostWarpVectorFilter, Fem::FemPostScalarClipFilter, Fem::FemPostDataAtPointFilter, Fem::FemPostDataAlongLineFilter, Fem::FemPostClipFilter, Fem::FemMeshObject, Fem::ConstraintTransform, Fem::ConstraintTemperature, Fem::ConstraintPulley, Fem::ConstraintPressure, Fem::ConstraintPlaneRotation, Fem::ConstraintInitialTemperature, Fem::ConstraintHeatflux, Fem::ConstraintGear, Fem::ConstraintForce, Fem::ConstraintFluidBoundary, Fem::ConstraintFixed, Fem::ConstraintDisplacement, Fem::ConstraintContact, Fem::ConstraintBearing, Fem::Constraint, Drawing::FeatureViewSymbol, Drawing::FeaturePage, Drawing::FeatureClip, Gui::ViewProviderTextDocument, Gui::ViewProviderOriginFeature, Gui::ViewProviderOrigin, Gui::ViewProviderMeasureDistance, Gui::ViewProviderGeometryObject, Gui::ViewProviderAnnotationLabel, Gui::ViewProviderAnnotation, Gui::ViewProvider, TechDrawGui::ViewProviderWeld, TechDrawGui::ViewProviderRichAnno, TechDrawGui::ViewProviderLeader, TechDrawGui::ViewProviderDimension, TechDrawGui::ViewProviderBalloon, Sketcher::SketchObject, PartDesign::Chamfer, Surface::GeomFillSurface, PartDesignGui::ViewProviderDatumCoordinateSystem, Part::Ellipse, Part::Line, Part::Vertex, Part::Circle, and App::VRMLObject.

Referenced by draftviewproviders.view_base.ViewProviderDraft::attach(), ArchSite.Compass::buildCoordinates(), draftobjects.wire.Wire::execute(), App::Property::hasSetValue(), ArchAxis.CommandArchGrid::IsActive(), App::ExtensionContainer::onChanged(), App::Property::touch(), ArchBuildingPart.ViewProviderBuildingPart::updateData(), ArchPanel.ViewProviderPanelCut::updateData(), ArchPanel.ViewProviderPanelSheet::updateData(), draftviewproviders.view_label.ViewProviderLabel::updateData(), draftviewproviders.view_layer.ViewProviderLayer::updateData(), and draftviewproviders.view_wpproxy.ViewProviderWorkingPlaneProxy::updateData().

◆ onPropertyStatusChanged()

void PropertyContainer::onPropertyStatusChanged ( const Property prop,
unsigned long  oldStatus 
)
virtual

◆ removeDynamicProperty()

virtual bool App::PropertyContainer::removeDynamicProperty ( const char *  name)
virtual

◆ Restore()

void PropertyContainer::Restore ( Base::XMLReader )
virtual

This method is used to restore properties from an XML document.

It uses the XMLReader class, which bases on SAX, to read the in Save() written information. Again the Vector as an example:

{
// read my Element
reader.readElement("PropertyVector");
// get the value of my Attribute
_cVec.x = reader.getAttributeAsFloat("valueX");
_cVec.y = reader.getAttributeAsFloat("valueY");
_cVec.z = reader.getAttributeAsFloat("valueZ");
}
virtual void Restore(Base::XMLReader &reader) override
This method is used to restore properties from an XML document.
Definition: PropertyGeo.cpp:170
The XML reader class This is an important helper class for the store and retrieval system of objects ...
Definition: Reader.h:118
void readElement(const char *ElementName=0)
read until a start element is found (<name>) or start-end element (<name/>) (with special name if giv...
Definition: Reader.cpp:240
double getAttributeAsFloat(const char *AttrName) const
return the named attribute as a double floating point (does type checking)
Definition: Reader.cpp:158

Implements Base::Persistence.

Reimplemented in TechDraw::DrawViewDimension, PartDesign::Chamfer, Part::Primitive, Part::Part2DObject, App::ExtensionContainer, App::Document, Points::Feature, PartDesign::Transformed, PartDesign::ProfileBased, PartDesign::Hole, PartDesign::Fillet, PartDesign::Plane, PartGui::ViewProvider2DObjectGrid, Part::Box, Gui::ViewProvider, App::VRMLObject, Sketcher::SketchObject, and Robot::RobotObject.

References Base::XMLReader::clearPartialRestoreProperty(), Base::Console(), dynamicProps, Base::ConsoleSingleton::Error(), Base::XMLReader::getAttribute(), Base::XMLReader::getAttributeAsInteger(), Base::XMLReader::getAttributeAsUnsigned(), App::Property::getName(), getPropertyByName(), getPropertyType(), handleChangedPropertyName(), handleChangedPropertyType(), Base::XMLReader::hasAttribute(), App::Prop_Transient, App::Property::PropTransient, Base::XMLReader::readElement(), Base::XMLReader::readEndElement(), App::DynamicProperty::restore(), Base::XMLReader::setPartialRestore(), App::Property::setStatusValue(), App::Property::StatusBits, Base::XMLReader::testStatus(), and App::Property::Transient.

Referenced by App::Document::Restore(), and App::ExtensionContainer::Restore().

◆ Save()

void PropertyContainer::Save ( Base::Writer ) const
virtual

This method is used to save properties to an XML document.

A good example you'll find in PropertyStandard.cpp, e.g. the vector:

void PropertyVector::Save (Writer &writer) const
{
writer << writer.ind() << "<PropertyVector valueX=\"" << _cVec.x <<
"\" valueY=\"" << _cVec.y <<
"\" valueZ=\"" << _cVec.z <<"\"/>" << endl;
}
virtual void Save(Base::Writer &writer) const override
This method is used to save properties to an XML document.
Definition: PropertyGeo.cpp:165

The writer.ind() expression writes the indentation, just for pretty printing of the XML. As you see, the writing of the XML document is not done with a DOM implementation because of performance reasons. Therefore the programmer has to take care that a valid XML document is written. This means closing tags and writing UTF-8.

See also
Base::Writer

Implements Base::Persistence.

Reimplemented in App::ExtensionContainer, App::DocumentObject, App::Document, App::VRMLObject, Sketcher::SketchObject, and Robot::RobotObject.

References Base::Console(), Base::Writer::decInd(), dynamicProps, Base::ConsoleSingleton::Error(), getPropertyMap(), getPropertyType(), Base::Writer::incInd(), Base::Writer::ind(), App::Prop_Transient, App::Property::PropDynamic, App::Property::PropNoPersist, App::DynamicProperty::save(), Base::Writer::Stream(), and App::Property::Transient.

Referenced by App::Document::Save(), and App::ExtensionContainer::Save().

◆ setPropertyPrefix()

void App::PropertyContainer::setPropertyPrefix ( const char *  prefix)

◆ setPropertyStatus()

void PropertyContainer::setPropertyStatus ( unsigned char  bit,
bool  value 
)

set the Status bit of all properties at once

References getPropertyList().

Friends And Related Function Documentation

◆ DynamicProperty

friend class DynamicProperty
friend

◆ Property

friend class Property
friend

Member Data Documentation

◆ dynamicProps


The documentation for this class was generated from the following files:
  • Sources/FreeCAD/src/App/PropertyContainer.h
  • Sources/FreeCAD/src/App/PropertyContainer.cpp