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... | |
Property * | getDynamicPropertyByName (const char *name) const |
Find a dynamic property by its name. More... | |
Property * | 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) |
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 |
Property * | restore (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) |
This class implements an interface to add properties at run-time to an object derived from PropertyContainer.
The additional properties are made persistent.
DynamicProperty::DynamicProperty | ( | ) |
|
virtual |
References clear().
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,
is equivalent to
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().
Add a pre-existing property.
The property is not treated as dynamic, and will not trigger signal.
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().
bool DynamicProperty::changeDynamicProperty | ( | const Property * | prop, |
const char * | group, | ||
const char * | doc | ||
) |
void DynamicProperty::clear | ( | ) |
Remove all properties.
Referenced by ~DynamicProperty().
Property * DynamicProperty::getDynamicPropertyByName | ( | const char * | name | ) | const |
Find a dynamic property by its name.
Referenced by App::PropertyContainer::getPropertyByName().
DynamicProperty::PropData DynamicProperty::getDynamicPropertyData | ( | const Property * | prop | ) | const |
std::vector< std::string > DynamicProperty::getDynamicPropertyNames | ( | ) | const |
Get a list of all dynamic properties.
const char * DynamicProperty::getPropertyDocumentation | ( | const char * | name | ) | const |
Get the documentation of a named property.
const char * DynamicProperty::getPropertyDocumentation | ( | const Property * | prop | ) | const |
Get the documentation of a property.
Referenced by App::PropertyContainer::getPropertyDocumentation().
const char * DynamicProperty::getPropertyGroup | ( | const char * | name | ) | const |
Get the group name of a named property.
const char * DynamicProperty::getPropertyGroup | ( | const Property * | prop | ) | const |
Get the group name of a property.
Referenced by App::PropertyContainer::getPropertyGroup().
void DynamicProperty::getPropertyList | ( | std::vector< Property * > & | List | ) | const |
Get all properties of the class (including parent)
Referenced by App::PropertyContainer::getPropertyList().
void DynamicProperty::getPropertyMap | ( | std::map< std::string, Property * > & | Map | ) | const |
Get all properties of the class (including parent)
Referenced by App::PropertyContainer::getPropertyMap().
const char * DynamicProperty::getPropertyName | ( | const Property * | prop | ) | const |
Get the name of a property.
Referenced by App::PropertyContainer::getPropertyName().
void DynamicProperty::getPropertyNamedList | ( | std::vector< std::pair< const char *, Property * > > & | List | ) | const |
get all properties with their names
Referenced by App::PropertyContainer::getPropertyNamedList().
short DynamicProperty::getPropertyType | ( | const char * | name | ) | const |
Get the attributes of a named property.
References App::Prop_Hidden, and App::Prop_ReadOnly.
short DynamicProperty::getPropertyType | ( | const Property * | prop | ) | const |
Get the attributes of a property.
References App::Property::getType().
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.
Remove pre-existing property, which will not be deleted.
Property * DynamicProperty::restore | ( | PropertyContainer & | pc, |
const char * | PropName, | ||
const char * | TypeName, | ||
Base::XMLReader & | reader | ||
) |
References addDynamicProperty(), Base::XMLReader::getAttribute(), and Base::XMLReader::hasAttribute().
Referenced by App::PropertyContainer::Restore(), and Part::Box::Restore().
void DynamicProperty::save | ( | const Property * | prop, |
Base::Writer & | writer | ||
) | const |
References Base::Persistence::encodeAttribute(), and Base::Writer::Stream().
Referenced by Mod.Show.mTempoVis.TempoVis::modify(), Mod.Show.mTempoVis.TempoVis::modifyVPProperty(), draftguitools.gui_setstyle.Draft_SetStyle_TaskPanel::onSaveStyle(), App::PropertyContainer::Save(), and Mod.Show.mTempoVis.TempoVis::saveCamera().
size_t App::DynamicProperty::size | ( | ) | const |
Get property count.
Referenced by gzip_utf8.GzipFile::close(), PathScripts.PostUtils.GCodeEditorDialog::done(), and gzip_utf8.GzipFile::write().