Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Operator1Expr.cpp

Go to the documentation of this file.
00001 // Operator1Expr.cpp: implementation of the COperator1Expr class.
00002 /*
00003  * Copyright (c) 1996-2000 Erwin Coumans <[email protected]>

00004  *
00005  * Permission to use, copy, modify, distribute and sell this software

00006  * and its documentation for any purpose is hereby granted without fee,

00007  * provided that the above copyright notice appear in all copies and

00008  * that both that copyright notice and this permission notice appear

00009  * in supporting documentation.  Erwin Coumans makes no

00010  * representations about the suitability of this software for any

00011  * purpose.  It is provided "as is" without express or implied warranty.

00012  *
00013  */
00014 
00015 #include "Operator1Expr.h"
00016 //#include "FactoryManager.h"
00017 #include "EmptyValue.h"
00019 // Construction/Destruction
00021 
00022 COperator1Expr::COperator1Expr()
00023 /*
00024 pre:

00025 effect: constucts an empty COperator1Expr

00026 */
00027 {
00028         m_lhs = NULL;
00029 }
00030 
00031 COperator1Expr::COperator1Expr(VALUE_OPERATOR op, CExpression * lhs)
00032 /*
00033 pre:

00034 effect: constucts a COperator1Expr with op and lhs in it

00035 */
00036 {
00037         m_lhs = lhs;
00038         m_op = op;
00039 }
00040 
00041 COperator1Expr::~COperator1Expr()
00042 /*
00043 pre:

00044 effect: deletes the object

00045 */
00046 {
00047         if (m_lhs) m_lhs->Release();
00048 }
00049 
00050 CValue * COperator1Expr::Calculate()
00051 /*
00052 pre:

00053 ret: a new object containing the result of applying the operator m_op to the

00054          value of m_lhs

00055 */
00056 {
00057         CValue *ret;
00058         CValue *temp = m_lhs->Calculate();
00059         CValue* empty = new CEmptyValue();
00060         ret = empty->Calc(m_op, temp);
00061         empty->Release();
00062         temp->Release();
00063         
00064         return ret;
00065 }
00066 
00067 /*
00068 bool COperator1Expr::IsInside(float x, float y, float z,bool bBorderInclude)

00069 {

00070 
00071         bool result = true;

00072         switch (m_op)

00073         {

00074                 

00075         case VALUE_ADD_OPERATOR:

00076                 {

00077                         

00078                         if (m_lhs)

00079                         {

00080                                 result = result || m_lhs->IsInside(x,y,z,bBorderInclude);

00081                         }

00082                         break;

00083                 }

00084         case VALUE_SUB_OPERATOR:

00085                 {

00086                         result = true;

00087                         if (m_lhs)

00088                         {

00089                                 result = result && (!m_lhs->IsInside(x,y,z,bBorderInclude));

00090                         }

00091                         break;

00092                 }

00093         }

00094         return result;

00095 }

00096 
00097 */
00098 bool COperator1Expr::NeedsRecalculated() {
00099         
00100         return m_lhs->NeedsRecalculated();
00101 
00102 }
00103 
00104 CExpression* COperator1Expr::CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks) {
00105 
00106         CExpression* newlhs = m_lhs->CheckLink(brokenlinks);
00107 
00108         if (newlhs)
00109         {
00110                 if (newlhs==m_lhs) {
00111                         // not changed
00112                 } else {
00113                         // changed
00114                         //numchanges++;
00115                         newlhs->AddRef();
00116                         
00117                         //m_lhs->Release();
00118                         brokenlinks.push_back(new CBrokenLinkInfo(&m_lhs,m_lhs));
00119 
00120                         m_lhs = newlhs;
00121                 }
00122                 return this;
00123         } else {
00124                 //numchanges++;
00125                 AddRef();
00126 
00127                 return Release();
00128         }
00129         
00130 }
00131 
00132 void COperator1Expr::BroadcastOperators(VALUE_OPERATOR op)

00133 {
00134         if (m_lhs)
00135                 m_lhs->BroadcastOperators(m_op);
00136 }
00137 
00138 
00139 
00140 
00141 bool COperator1Expr::MergeExpression(CExpression *otherexpr)

00142 {
00143         if (m_lhs)
00144                 return m_lhs->MergeExpression(otherexpr);
00145         
00146         assertd(false); // should not get here, expression is not compatible for merge
00147         return false;
00148 }

Generated at Thu Feb 1 13:03:08 2001 for Ketsji Game Engine by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000