5ed5c1f211988898edce9a15e23677892d131031
[occt.git] / src / Expr / Expr_NamedExpression.cxx
1 // Created on: 1991-04-11
2 // Created by: Arnaud BOUZY
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Expr_GeneralExpression.hxx>
19 #include <Expr_NamedExpression.hxx>
20 #include <Standard_Type.hxx>
21 #include <TCollection_AsciiString.hxx>
22
23 IMPLEMENT_STANDARD_RTTIEXT(Expr_NamedExpression,Expr_GeneralExpression)
24
25 //=======================================================================
26 //function : GetName
27 //purpose  : 
28 //=======================================================================
29 const TCollection_AsciiString& Expr_NamedExpression::GetName() const
30 {
31   return myName;
32 }
33
34 //=======================================================================
35 //function : SetName
36 //purpose  : 
37 //=======================================================================
38
39 void Expr_NamedExpression::SetName(const TCollection_AsciiString& name)
40 {
41   myName = name;
42 }
43
44 //=======================================================================
45 //function : IsShareable
46 //purpose  : 
47 //=======================================================================
48
49 Standard_Boolean Expr_NamedExpression::IsShareable () const
50 {
51   return Standard_True;
52 }
53
54 //=======================================================================
55 //function : IsIdentical
56 //purpose  : 
57 //=======================================================================
58
59 Standard_Boolean Expr_NamedExpression::IsIdentical
60                         (const Handle(Expr_GeneralExpression)& theOther) const
61 {
62   Standard_Boolean aResult(Standard_False);
63   if (theOther->IsKind(STANDARD_TYPE(Expr_NamedExpression))) {
64 //  Handle(Expr_NamedExpression) me = this;
65 //  Handle(Expr_NamedExpression) NEOther = Handle(Expr_NamedExpression)::DownCast(Other);
66 //  return  (me == NEOther);
67
68 //AGV 22.03.12: Comparison should be based on names rather than Handles
69     const Expr_NamedExpression* pOther =
70       static_cast<const Expr_NamedExpression*>(theOther.operator->());
71     if (pOther == this || pOther->GetName().IsEqual(myName))
72       aResult = Standard_True;
73   }
74   return aResult;
75 }
76
77 TCollection_AsciiString Expr_NamedExpression::String() const
78 {
79   return GetName();
80 }