Blender V2.61 - r43446

ConstExpr.cpp

Go to the documentation of this file.
00001 
00004 // ConstExpr.cpp: implementation of the CConstExpr class.
00005 
00006 /*
00007  * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
00008  *
00009  * Permission to use, copy, modify, distribute and sell this software
00010  * and its documentation for any purpose is hereby granted without fee,
00011  * provided that the above copyright notice appear in all copies and
00012  * that both that copyright notice and this permission notice appear
00013  * in supporting documentation.  Erwin Coumans makes no
00014  * representations about the suitability of this software for any
00015  * purpose.  It is provided "as is" without express or implied warranty.
00016  *
00017  */
00018 
00019 #include "Value.h" // for precompiled header
00020 #include "ConstExpr.h"
00021 #include "VectorValue.h"
00022 
00024 // Construction/Destruction
00026 
00027 CConstExpr::CConstExpr()
00028 {
00029 }
00030 
00031 
00032 
00033 CConstExpr::CConstExpr(CValue* constval) 
00034 /*
00035 pre:
00036 effect: constructs a CConstExpr cointing the value constval
00037 */
00038 {
00039     m_value = constval;
00040 //  m_bModified=true;
00041 }
00042 
00043 
00044 
00045 CConstExpr::~CConstExpr()
00046 /*
00047 pre:
00048 effect: deletes the object
00049 */
00050 {
00051     if (m_value)
00052         m_value->Release();
00053 }
00054 
00055 
00056 
00057 unsigned char CConstExpr::GetExpressionID()
00058 {
00059     return CCONSTEXPRESSIONID;
00060 }
00061 
00062 
00063 
00064 CValue* CConstExpr::Calculate()
00065 /*
00066 pre:
00067 ret: a new object containing the value of the stored CValue
00068 */
00069 {
00070     return m_value->AddRef();
00071 }
00072 
00073 
00074 
00075 void CConstExpr::ClearModified()
00076 { 
00077     if (m_value)
00078     {
00079         m_value->SetModified(false);
00080         m_value->SetAffected(false);
00081     }
00082 }
00083 
00084 
00085 
00086 double CConstExpr::GetNumber()
00087 {
00088     return -1;
00089 }
00090 
00091 
00092 
00093 bool CConstExpr::NeedsRecalculated()
00094 {
00095     return m_value->IsAffected(); // IsAffected is m_bModified OR m_bAffected !!!
00096 }
00097 
00098 
00099 
00100 CExpression* CConstExpr::CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks)
00101 {
00102 // parent checks if child is still useful.
00103 // When for example it's value it's deleted flag set
00104 // then release Value, and return NULL in case of constexpression
00105 // else return this...
00106 
00107     assertd(m_value);
00108     if (m_value->IsReleaseRequested())
00109     {
00110         AddRef(); //numchanges++;
00111         return Release();
00112     }
00113     else
00114         return this;
00115 }
00116 
00117 
00118 
00119 void CConstExpr::BroadcastOperators(VALUE_OPERATOR op)
00120 {
00121     assertd(m_value);
00122     m_value->SetColorOperator(op);
00123 }
00124 
00125 
00126 
00127 bool CConstExpr::MergeExpression(CExpression *otherexpr)
00128 {
00129     assertd(false);
00130     return false;
00131 }