btreenode.h

00001 /***************************************************************************
00002  *   Copyright (C) 2004-2005 by Daniel Clarke                              *
00003  *   daniel.jc@gmail.com                                                   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef BTREENODE_H
00022 #define BTREENODE_H
00023 
00024 #include "btreebase.h"
00025 #include "expression.h"
00026 
00027 #include <qstring.h>
00028 #include <qptrlist.h>
00029 
00037 class BTreeNode
00038 {
00039         public:
00040                 BTreeNode();
00041                 BTreeNode(BTreeNode *p, BTreeNode *l, BTreeNode *r);
00042                 ~BTreeNode();
00043 
00047 //              void printTree();
00051                 void deleteChildren();
00055                 BTreeNode *parent() const { return m_parent; }
00059                 BTreeNode *left() const { return m_left; }
00063                 BTreeNode *right() const { return m_right; }
00064                 void setParent(BTreeNode *parent) { m_parent = parent; }
00069                 void setLeft(BTreeNode *left) { m_left = left; m_left->setParent( this ); }
00074                 void setRight(BTreeNode *right) { m_right = right; m_right->setParent( this ); }
00078                 bool hasChildren() const { return m_left || m_right; }
00079 
00080                 ExprType type() const {return m_type;}
00081                 void setType(ExprType type) { m_type = type; }
00082                 QString value() const {return m_value;}
00083                 void setValue( const QString & value ) { m_value = value; }
00084 
00085                 Expression::Operation childOp() const {return m_childOp;}
00086                 void setChildOp(Expression::Operation op){ m_childOp = op;}
00087 
00088                 void setReg( const QString & r ){ m_reg = r; }
00089                 QString reg() const {return m_reg;}
00090 
00091                 bool needsEvaluating() const { return hasChildren(); }
00092 
00093         protected:
00094                 BTreeNode *m_parent;
00095                 BTreeNode *m_left;
00096                 BTreeNode *m_right;
00097 
00099                 QString m_reg;
00100 
00101                 ExprType m_type;
00102                 QString m_value;
00103 
00104                 Expression::Operation m_childOp;
00105 };
00106 
00107 #endif

Generated on Tue May 8 17:05:28 2007 for KTechLab by  doxygen 1.5.1