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

Expression.h

Go to the documentation of this file.
00001 // Expression.h: interface for the CExpression 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 #if !defined _EXPRESSION_H
00016 #define _EXPRESSION_H
00017 
00018 #include "Value.h"
00019 
00020 //extern int gRefCountExpr;     // only for debugging purposes (detect mem.leaks)
00021 
00022 
00023 
00024 
00025 #define PLUGIN_DECLARE_SERIAL_EXPRESSION(class_name,base_class_name)                                                                    \

00026 public:                                                                                                                                                                         \

00027         virtual base_class_name *       Copy()                                          { return new class_name; }              \

00028         virtual bool EdSerialize(CompressorArchive& arch,class CFactoryManager* facmgr,bool bIsStoring);    \

00029         virtual bool EdIdSerialize(CompressorArchive& arch,class CFactoryManager* facmgr,bool bIsStoring)  \

00030 {                               \

00031         if (bIsStoring)                 \

00032         {                                                       \

00033                 unsigned char exprID = GetExpressionID(); \

00034                 arch << exprID;                                 \

00035         }                                               \

00036         return true; \

00037 }                               \

00038 
00039 
00040 
00041 class CExpression;
00042 
00043 
00044 // for undo/redo system the deletion in the expressiontree can be restored by replacing broken links 'inplace'
00045 class CBrokenLinkInfo
00046 {
00047         public:
00048                 CBrokenLinkInfo(CExpression** pmemexpr,CExpression* expr)
00049                         :m_pmemExpr(pmemexpr),
00050                         m_pExpr(expr)

00051                  { 
00052                         assertd(pmemexpr);
00053                         m_bRestored=false;
00054                 };
00055 
00056                 virtual ~CBrokenLinkInfo();
00057                 void RestoreLink();
00058                 void BreakLink();
00059                 
00060                 
00061         // members vars
00062         private:
00063         CExpression** m_pmemExpr;
00064         CExpression* m_pExpr;
00065         bool            m_bRestored;
00066         
00067 };
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 class CExpression  
00077 {
00078 public:
00079         enum {
00080                         COPERATOR1EXPRESSIONID = 1,
00081                         COPERATOR2EXPRESSIONID = 2,
00082                         CCONSTEXPRESSIONID = 3,
00083                         CIFEXPRESSIONID = 4,
00084                         COPERATORVAREXPRESSIONID = 5,
00085                         CIDENTIFIEREXPRESSIONID = 6
00086         };
00087 
00088 
00089 protected:
00090         virtual                         ~CExpression() = 0;                     //pure virtual
00091 public:
00092         virtual bool MergeExpression(CExpression* otherexpr) = 0;
00093         CExpression();
00094 
00095         
00096         virtual                         CValue* Calculate() = 0;        //pure virtual
00097         virtual unsigned char GetExpressionID() = 0;
00098         //virtual bool          IsInside(float x,float y,float z,bool bBorderInclude=true) = 0;         //pure virtual
00099         virtual bool            NeedsRecalculated() = 0; // another pure one
00100         virtual CExpression * CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks) =0; // another pure one
00101         virtual void                            ClearModified() = 0; // another pure one
00102         //virtual CExpression * Copy() =0;
00103         virtual void            BroadcastOperators(VALUE_OPERATOR op) =0;
00104 
00105         virtual CExpression * AddRef() { // please leave multiline, for debugger !!!
00106 
00107 #ifdef _DEBUG
00108                 //gRefCountExpr++;
00109                 assertd(m_refcount < 255);
00110 #endif
00111                 m_refcount++; 
00112                 return this;
00113         };
00114         virtual CExpression* Release(CExpression* complicatedtrick=NULL) { 
00115 #ifdef _DEBUG
00116                 //gRefCountExpr--;
00117 #endif
00118                 if (--m_refcount < 1) 
00119                 {
00120                         delete this;
00121                 } //else
00122                 //      return this;
00123                 return complicatedtrick;
00124         };
00125         
00126 
00127 protected:
00128 
00129         int m_refcount;
00130 };
00131 
00132 #endif // !defined _EXPRESSION_H

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