rename handleMissingProperty to handleChangedPropertyName
This commit is contained in:
@@ -153,17 +153,22 @@ const PropertyData * PropertyContainer::getPropertyDataPtr(void){return &propert
|
||||
const PropertyData & PropertyContainer::getPropertyData(void) const{return propertyData;}
|
||||
|
||||
/**
|
||||
* @brief PropertyContainer::handleMissingProperty is called during restore to possibly
|
||||
* fix reading of older versions of this property container.
|
||||
* @brief 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.
|
||||
*
|
||||
* @param reader The XML stream to read from.
|
||||
* @param TypeName Name of property type on file.
|
||||
* @param PropName Name of property on file that does not exist in the container anymore.
|
||||
*/
|
||||
|
||||
void PropertyContainer::handleMissingProperty(XMLReader &reader, const char *PropName)
|
||||
void PropertyContainer::handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName)
|
||||
{
|
||||
(void)reader;
|
||||
(void)TypeName;
|
||||
(void)PropName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,6 +185,9 @@ void PropertyContainer::handleMissingProperty(XMLReader &reader, const char *Pro
|
||||
|
||||
void PropertyContainer::handleChangedPropertyType(XMLReader &reader, const char *TypeName, Property *prop)
|
||||
{
|
||||
(void)reader;
|
||||
(void)TypeName;
|
||||
(void)prop;
|
||||
}
|
||||
|
||||
PropertyData PropertyContainer::propertyData;
|
||||
@@ -264,16 +272,18 @@ void PropertyContainer::Restore(Base::XMLReader &reader)
|
||||
// not its name. In this case we would force to read-in a wrong property
|
||||
// type and the behaviour would be undefined.
|
||||
try {
|
||||
|
||||
// Property not found in container, but one file?
|
||||
if (!prop)
|
||||
handleMissingProperty(reader, PropName);
|
||||
// name and type match
|
||||
if (prop && strcmp(prop->getTypeId().getName(), TypeName) == 0) {
|
||||
prop->Restore(reader);
|
||||
}
|
||||
// name matches but not the type
|
||||
else if (prop) {
|
||||
handleChangedPropertyType(reader, TypeName, prop);
|
||||
}
|
||||
// name doesn't match, the sub-class then has to know
|
||||
// if the property has been renamed or removed
|
||||
else {
|
||||
// Has the type changed?
|
||||
if (strcmp(prop->getTypeId().getName(), TypeName) != 0)
|
||||
handleChangedPropertyType(reader, TypeName, prop);
|
||||
else
|
||||
prop->Restore(reader); // All as before
|
||||
handleChangedPropertyName(reader, TypeName, PropName);
|
||||
}
|
||||
}
|
||||
catch (const Base::XMLParseException&) {
|
||||
|
||||
@@ -196,8 +196,7 @@ protected:
|
||||
static const PropertyData * getPropertyDataPtr(void);
|
||||
virtual const PropertyData& getPropertyData(void) const;
|
||||
|
||||
virtual void handleMissingProperty(Base::XMLReader &reader, const char *PropName);
|
||||
|
||||
virtual void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName);
|
||||
virtual void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, Property * prop);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user