1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0025257: Expr should use names for comparing

Expression should use string names for comparing, fixed
This commit is contained in:
pdn 2014-09-22 19:47:04 +04:00 committed by bugmaster
parent 0d1b4a2271
commit a2ca2a304f
2 changed files with 42 additions and 8 deletions

View File

@ -16,29 +16,57 @@
#include <Expr_NamedExpression.ixx>
//=======================================================================
//function : GetName
//purpose :
//=======================================================================
const TCollection_AsciiString& Expr_NamedExpression::GetName() const
{
return myName;
}
//=======================================================================
//function : SetName
//purpose :
//=======================================================================
void Expr_NamedExpression::SetName(const TCollection_AsciiString& name)
{
myName = name;
}
//=======================================================================
//function : IsShareable
//purpose :
//=======================================================================
Standard_Boolean Expr_NamedExpression::IsShareable () const
{
return Standard_True;
}
Standard_Boolean Expr_NamedExpression::IsIdentical (const Handle(Expr_GeneralExpression)& Other) const
//=======================================================================
//function : IsIdentical
//purpose :
//=======================================================================
Standard_Boolean Expr_NamedExpression::IsIdentical
(const Handle(Expr_GeneralExpression)& theOther) const
{
if (!Other->IsKind(STANDARD_TYPE(Expr_NamedExpression))) {
return Standard_False;
Standard_Boolean aResult(Standard_False);
if (theOther->IsKind(STANDARD_TYPE(Expr_NamedExpression))) {
// Handle(Expr_NamedExpression) me = this;
// Handle(Expr_NamedExpression) NEOther = Handle(Expr_NamedExpression)::DownCast(Other);
// return (me == NEOther);
//AGV 22.03.12: Comparison should be based on names rather than Handles
const Expr_NamedExpression* pOther =
static_cast<const Expr_NamedExpression*>(theOther.operator->());
if (pOther == this || pOther->GetName().IsEqual(myName))
aResult = Standard_True;
}
Handle(Expr_NamedExpression) me = this;
Handle(Expr_NamedExpression) NEOther = Handle(Expr_NamedExpression)::DownCast(Other);
return (me == NEOther);
return aResult;
}
TCollection_AsciiString Expr_NamedExpression::String() const

View File

@ -92,10 +92,16 @@ Standard_Boolean Expr_NamedUnknown::ContainsUnknowns () const
}
}
Standard_Boolean Expr_NamedUnknown::Contains (const Handle(Expr_GeneralExpression)& exp) const
Standard_Boolean Expr_NamedUnknown::Contains
(const Handle(Expr_GeneralExpression)& exp) const
{
if (!IsAssigned()) {
return Standard_False;
const Handle(Expr_NamedUnknown) expNamed =
Handle(Expr_NamedUnknown)::DownCast(exp);
if (expNamed.IsNull() || expNamed->IsAssigned())
return Standard_False;
//AGV 22.03.12: Comparison based on name coincidence
return IsIdentical(expNamed);
}
if (myExpression == exp) {
return Standard_True;