1 /** \file gameengine/Expressions/IfExpr.cpp
4 // IfExpr.cpp: implementation of the CIfExpr class.
6 * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
8 * Permission to use, copy, modify, distribute and sell this software
9 * and its documentation for any purpose is hereby granted without fee,
10 * provided that the above copyright notice appear in all copies and
11 * that both that copyright notice and this permission notice appear
12 * in supporting documentation. Erwin Coumans makes no
13 * representations about the suitability of this software for any
14 * purpose. It is provided "as is" without express or implied warranty.
19 #include "EmptyValue.h"
20 #include "ErrorValue.h"
21 #include "BoolValue.h"
23 //////////////////////////////////////////////////////////////////////
24 // Construction/Destruction
25 //////////////////////////////////////////////////////////////////////
34 CIfExpr::CIfExpr(CExpression *guard, CExpression *e1, CExpression *e2)
37 effect: constructs an CifExpr-object corresponding to IF(guard, e1, e2)
50 effect: dereferences the object
65 CValue* CIfExpr::Calculate()
68 ret: a new object containing the value of m_e1 if m_guard is a boolean TRUE
69 a new object containing the value of m_e2 if m_guard is a boolean FALSE
70 an new errorvalue if m_guard is not a boolean
74 guardval = m_guard->Calculate();
75 const STR_String& text = guardval->GetText();
78 if (&text == &CBoolValue::sTrueString)
80 return m_e1->Calculate();
82 else if (&text == &CBoolValue::sFalseString)
84 return m_e2->Calculate();
88 return new CErrorValue("Guard should be of boolean type");
94 bool CIfExpr::MergeExpression(CExpression *otherexpr)
102 bool CIfExpr::IsInside(float x,float y,float z,bool bBorderInclude)
110 bool CIfExpr::NeedsRecalculated()
112 return (m_guard->NeedsRecalculated() ||
113 m_e1->NeedsRecalculated() ||
114 m_e2->NeedsRecalculated());
119 CExpression* CIfExpr::CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks)
127 void CIfExpr::ClearModified()
134 void CIfExpr::BroadcastOperators(VALUE_OPERATOR op)
141 unsigned char CIfExpr::GetExpressionID()
143 return CIFEXPRESSIONID;