App::DynamicProperty Class Reference

This class implements an interface to add properties at run-time to an object derived from PropertyContainer. More...

#include <DynamicProperty.h>

Classes

struct  PropData
 

Public Member Functions

 DynamicProperty ()
 
virtual ~DynamicProperty ()
 
Access properties
void getPropertyList (std::vector< Property * > &List) const
 Get all properties of the class (including parent) More...
 
void getPropertyNamedList (std::vector< std::pair< const char *, Property * > > &List) const
 get all properties with their names More...
 
void getPropertyMap (std::map< std::string, Property * > &Map) const
 Get all properties of the class (including parent) More...
 
PropertygetDynamicPropertyByName (const char *name) const
 Find a dynamic property by its name. More...
 
PropertyaddDynamicProperty (PropertyContainer &pc, const char *type, const char *name=nullptr, const char *group=nullptr, const char *doc=nullptr, short attr=0, bool ro=false, bool hidden=false)
 
bool addProperty (Property *prop)
 Add a pre-existing property. More...
 
bool removeDynamicProperty (const char *name)
 
bool removeProperty (const Property *prop)
 Remove pre-existing property, which will not be deleted. More...
 
std::vector< std::string > getDynamicPropertyNames () const
 Get a list of all dynamic properties. More...
 
const char * getPropertyName (const Property *prop) const
 Get the name of a property. More...
 

Property attributes

short getPropertyType (const Property *prop) const
 Get the attributes of a property. More...
 
short getPropertyType (const char *name) const
 Get the attributes of a named property. More...
 
const char * getPropertyGroup (const Property *prop) const
 Get the group name of a property. More...
 
const char * getPropertyGroup (const char *name) const
 Get the group name of a named property. More...
 
const char * getPropertyDocumentation (const Property *prop) const
 Get the documentation of a property. More...
 
const char * getPropertyDocumentation (const char *name) const
 Get the documentation of a named property. More...
 
void clear ()
 Remove all properties. More...
 
size_t size () const
 Get property count. More...
 
void save (const Property *prop, Base::Writer &writer) const
 
Propertyrestore (PropertyContainer &pc, const char *PropName, const char *TypeName, Base::XMLReader &reader)
 
PropData getDynamicPropertyData (const Property *prop) const
 
bool changeDynamicProperty (const Property *prop, const char *group, const char *doc)
 

Detailed Description

This class implements an interface to add properties at run-time to an object derived from PropertyContainer.

The additional properties are made persistent.

Author
Werner Mayer

Constructor & Destructor Documentation

◆ DynamicProperty()

DynamicProperty::DynamicProperty ( )

◆ ~DynamicProperty()

DynamicProperty::~DynamicProperty ( )
virtual

References clear().

Member Function Documentation

◆ addDynamicProperty()

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

Add a dynamic property of the type type and with the name name. Group gives the grouping name which appears in the property editor and doc shows the tooltip there. With attr, ro and hidden the behaviour of the property can be controlled. attr is an OR'ed value of the PropertyType enumeration. If no special attribute should be set Prop_None can be set (or leave the default of 0). For convenience the attributes for 'Read-Only' and 'Hidden' can also be controlled with the values ro or hidden. This means,

addDynamicProperty(..., ..., "Base","blah", Prop_ReadOnly | Prop_Hidden);

is equivalent to

addDynamicProperty(..., ..., "Base","blah", Prop_None, true, true);

References Base::Type::createInstance(), App::GetApplication(), ParameterGrp::GetBool(), Base::Persistence::getClassTypeId(), App::PropertyContainer::getFullName(), Base::Tools::getIdentifier(), App::Application::GetParameterGroupByPath(), App::PropertyContainer::getPropertyByName(), Base::Type::getTypeIfDerivedFrom(), Base::Type::isBad(), App::Prop_Hidden, App::Prop_ReadOnly, App::Property::PropDynamic, App::Property::setContainer(), App::Application::signalAppendDynamicProperty, and App::Property::StatusBits.

Referenced by App::PropertyContainer::addDynamicProperty(), and restore().

◆ addProperty()

bool DynamicProperty::addProperty ( Property prop)

Add a pre-existing property.

The property is not treated as dynamic, and will not trigger signal.

Returns
Return false if there is a property exist with the same name.

References App::Property::getDocumentation(), App::Property::getGroup(), App::Property::getName(), App::Property::getType(), and App::Property::hasName().

Referenced by DocumentObject.Box::init(), and DocumentObject.DocumentObject::onChanged().

◆ changeDynamicProperty()

bool DynamicProperty::changeDynamicProperty ( const Property prop,
const char *  group,
const char *  doc 
)

◆ clear()

void DynamicProperty::clear ( )

Remove all properties.

Referenced by ~DynamicProperty().

◆ getDynamicPropertyByName()

Property * DynamicProperty::getDynamicPropertyByName ( const char *  name) const

Find a dynamic property by its name.

Referenced by App::PropertyContainer::getPropertyByName().

◆ getDynamicPropertyData()

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

◆ getDynamicPropertyNames()

std::vector< std::string > DynamicProperty::getDynamicPropertyNames ( ) const

Get a list of all dynamic properties.

◆ getPropertyDocumentation() [1/2]

const char * DynamicProperty::getPropertyDocumentation ( const char *  name) const

Get the documentation of a named property.

◆ getPropertyDocumentation() [2/2]

const char * DynamicProperty::getPropertyDocumentation ( const Property prop) const

Get the documentation of a property.

Referenced by App::PropertyContainer::getPropertyDocumentation().

◆ getPropertyGroup() [1/2]

const char * DynamicProperty::getPropertyGroup ( const char *  name) const

Get the group name of a named property.

◆ getPropertyGroup() [2/2]

const char * DynamicProperty::getPropertyGroup ( const Property prop) const

Get the group name of a property.

Referenced by App::PropertyContainer::getPropertyGroup().

◆ getPropertyList()

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

Get all properties of the class (including parent)

Referenced by App::PropertyContainer::getPropertyList().

◆ getPropertyMap()

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

Get all properties of the class (including parent)

Referenced by App::PropertyContainer::getPropertyMap().

◆ getPropertyName()

const char * DynamicProperty::getPropertyName ( const Property prop) const

Get the name of a property.

Referenced by App::PropertyContainer::getPropertyName().

◆ getPropertyNamedList()

void DynamicProperty::getPropertyNamedList ( std::vector< std::pair< const char *, Property * > > &  List) const

get all properties with their names

Referenced by App::PropertyContainer::getPropertyNamedList().

◆ getPropertyType() [1/2]

short DynamicProperty::getPropertyType ( const char *  name) const

Get the attributes of a named property.

References App::Prop_Hidden, and App::Prop_ReadOnly.

◆ getPropertyType() [2/2]

short DynamicProperty::getPropertyType ( const Property prop) const

Get the attributes of a property.

References App::Property::getType().

◆ removeDynamicProperty()

bool DynamicProperty::removeDynamicProperty ( const char *  name)

Removes a dynamic property by name. Returns true if the property is part of the container, otherwise false is returned.

References App::Property::destroy(), App::GetApplication(), App::Property::LockDynamic, App::Property::PropDynamic, and App::Application::signalRemoveDynamicProperty.

◆ removeProperty()

bool DynamicProperty::removeProperty ( const Property prop)

Remove pre-existing property, which will not be deleted.

◆ restore()

Property * DynamicProperty::restore ( PropertyContainer pc,
const char *  PropName,
const char *  TypeName,
Base::XMLReader reader 
)

◆ save()

◆ size()

size_t App::DynamicProperty::size ( ) const

The documentation for this class was generated from the following files: