App: add Property::isSame() API

To compare if two property contains the same content. The default
implementation in Property uses the persistense interface to save both
properties to string and compares the content. This may not work at the
moment if the property saves content in separate file or in binary.

Various properties have cheaper implementation to direct compare their
internal values.
This commit is contained in:
Zheng, Lei
2020-01-01 18:26:39 +08:00
committed by Chris Hennes
parent 875452c020
commit 54c484df9b
9 changed files with 133 additions and 6 deletions

View File

@@ -84,6 +84,27 @@ void PropertyLinkBase::hasSetValue() {
Property::hasSetValue();
}
bool PropertyLinkBase::isSame(const Property &other) const
{
if(other.isDerivedFrom(PropertyLinkBase::getClassTypeId())
|| getScope() != static_cast<const PropertyLinkBase*>(&other)->getScope())
return false;
static std::vector<App::DocumentObject*> ret;
static std::vector<std::string> subs;
static std::vector<App::DocumentObject*> ret2;
static std::vector<std::string> subs2;
ret.clear();
subs.clear();
ret2.clear();
subs2.clear();
getLinks(ret,true,&subs,false);
static_cast<const PropertyLinkBase *>(&other)->getLinks(ret2,true,&subs2,true);
return ret==ret2 && subs==subs2;
}
void PropertyLinkBase::unregisterElementReference() {
}