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:
@@ -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() {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user