0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / Expr / Expr_LessThanOrEqual.cxx
1 // Created on: 1991-06-13
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.hxx>
19 #include <Expr_GeneralExpression.hxx>
20 #include <Expr_GeneralRelation.hxx>
21 #include <Expr_LessThanOrEqual.hxx>
22 #include <Expr_NumericValue.hxx>
23 #include <Standard_NumericError.hxx>
24 #include <Standard_Type.hxx>
25 #include <TCollection_AsciiString.hxx>
26
27 IMPLEMENT_STANDARD_RTTIEXT(Expr_LessThanOrEqual,Expr_SingleRelation)
28
29 Expr_LessThanOrEqual::Expr_LessThanOrEqual (const Handle(Expr_GeneralExpression)& exp1, const Handle(Expr_GeneralExpression)& exp2)
30 {
31   SetFirstMember(exp1);
32   SetSecondMember(exp2);
33 }
34
35 Standard_Boolean Expr_LessThanOrEqual::IsSatisfied () const
36 {
37   Handle(Expr_GeneralExpression) fm = FirstMember();
38   Handle(Expr_GeneralExpression) sm = SecondMember();
39   fm = fm->Simplified();
40   sm = sm->Simplified();
41   if (fm->IsKind(STANDARD_TYPE(Expr_NumericValue))) {
42     if (sm->IsKind(STANDARD_TYPE(Expr_NumericValue))) {
43       Handle(Expr_NumericValue) nfm = Handle(Expr_NumericValue)::DownCast(fm);
44       Handle(Expr_NumericValue) nsm = Handle(Expr_NumericValue)::DownCast(sm);
45       return (nfm->GetValue() <= nsm->GetValue());
46     }
47   }
48   return Standard_False;
49 }
50
51 Handle(Expr_GeneralRelation) Expr_LessThanOrEqual::Simplified () const
52 {
53   Handle(Expr_GeneralExpression) fm = FirstMember();
54   Handle(Expr_GeneralExpression) sm = SecondMember();
55   return new Expr_LessThanOrEqual(fm->Simplified(),sm->Simplified());
56 }
57
58 void Expr_LessThanOrEqual::Simplify ()
59 {
60   Handle(Expr_GeneralExpression) fm = FirstMember();
61   Handle(Expr_GeneralExpression) sm = SecondMember();
62   SetFirstMember(fm->Simplified());
63   SetSecondMember(sm->Simplified());
64 }
65
66 Handle(Expr_GeneralRelation) Expr_LessThanOrEqual::Copy () const
67 {
68   return new Expr_LessThanOrEqual(Expr::CopyShare(FirstMember()),
69                                   Expr::CopyShare(SecondMember()));
70 }
71
72 TCollection_AsciiString Expr_LessThanOrEqual::String() const
73 {
74   return FirstMember()->String() + " <= " + SecondMember()->String();
75 }