Extensions: Implement persistence

This commit is contained in:
Stefan Tröger
2016-12-09 22:48:46 +01:00
committed by wmayer
parent 207432c0bd
commit cd1c753fa2
9 changed files with 235 additions and 13 deletions

View File

@@ -331,6 +331,11 @@ std::string DynamicProperty::encodeAttribute(const std::string& str) const
void DynamicProperty::Save (Base::Writer &writer) const
{
//extenions must be saved first, as they need to be read and initialised before properties (as
//they have their own properties which they need to handle on restore)
if(this->pc->isDerivedFrom(App::ExtensionContainer::getClassTypeId()))
static_cast<App::ExtensionContainer*>(this->pc)->saveExtensions(writer);
std::map<std::string,Property*> Map;
getPropertyMap(Map);
@@ -389,6 +394,10 @@ void DynamicProperty::Save (Base::Writer &writer) const
void DynamicProperty::Restore(Base::XMLReader &reader)
{
//first all extensions must be initialised so that they can handle their properties
if(this->pc->isDerivedFrom(App::ExtensionContainer::getClassTypeId()))
static_cast<App::ExtensionContainer*>(this->pc)->restoreExtensions(reader);
reader.readElement("Properties");
int Cnt = reader.getAttributeAsInteger("Count");