Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's quick Index  

HxSyntaxBranchNode.h

00001 /*
00002  *  Copyright (c) 1998, University of Amsterdam, The Netherlands.
00003  *  All rights reserved.
00004  *
00005  *
00006  *  Author(s):
00007  *  Dennis Koelma (koelma@wins.uva.nl)
00008  *  Edo Poll (poll@wins.uva.nl)
00009  */
00010 
00011 #ifndef HxSyntaxBranchNode_h
00012 #define HxSyntaxBranchNode_h
00013 
00014 #include "HxIoFwd.h"
00015 #include "HxSyntaxNode.h"
00016 
00017 #include "HxMemoryPool.h"
00018 #include "HxMemoryPoolFactory.h"
00019 
00020 
00021 class HxSyntaxBranchNode : public HxSyntaxNode
00022 {
00023 public:
00024                             HxSyntaxBranchNode(
00025                                 HxSyntaxNode* left,
00026                                 HxSyntaxNode* right);
00027                             HxSyntaxBranchNode(
00028                                 int tag,
00029                                 HxSyntaxNode* left,
00030                                 HxSyntaxNode* right);
00031     virtual                 ~HxSyntaxBranchNode();
00032 
00033     virtual int             type() const;
00034     int                     tag() const;
00035     virtual STD_OSTREAM&    put(STD_OSTREAM&, int indent = 0) const;
00036 
00037     HxSyntaxNode*           left() const;
00038     HxSyntaxNode*           right() const;
00039 
00040     HxSyntaxNode*           setLeft(HxSyntaxNode*);
00041     HxSyntaxNode*           setRight(HxSyntaxNode*);
00042 
00043     virtual void            destroy();
00044 
00045     void*                   operator new(size_t);
00046     void                    operator delete(void*);
00047 
00048 private:
00049     int                     _tag;
00050     HxSyntaxNode*           _left;
00051     HxSyntaxNode*           _right;
00052 
00053     static HxMemoryPool*    _memoryPool;
00054 };
00055 
00056 inline HxSyntaxNode*
00057 makeHxSyntaxNode(HxSyntaxNode* left, HxSyntaxNode* right)
00058 {
00059     return new HxSyntaxBranchNode(left, right);
00060 }
00061 
00062 inline HxSyntaxNode*
00063 makeHxSyntaxNode(int tag, HxSyntaxNode* left, HxSyntaxNode* right)
00064 {
00065     return new HxSyntaxBranchNode(tag, left, right);
00066 }
00067 
00068 inline
00069 HxSyntaxBranchNode::HxSyntaxBranchNode(
00070     HxSyntaxNode* left, HxSyntaxNode* right)
00071         : _tag(0), _left(left), _right(right) {}
00072 
00073 inline
00074 HxSyntaxBranchNode::HxSyntaxBranchNode(
00075     int tag, HxSyntaxNode* left, HxSyntaxNode* right)
00076         : _tag(tag), _left(left), _right(right) {}
00077 
00078 inline int
00079 HxSyntaxBranchNode::tag() const { return _tag; }
00080 
00081 inline HxSyntaxNode*
00082 HxSyntaxBranchNode::left() const { return _left; }
00083 
00084 inline HxSyntaxNode*
00085 HxSyntaxBranchNode::right() const { return _right; }
00086 
00087 inline HxSyntaxNode*
00088 HxSyntaxBranchNode::setLeft(HxSyntaxNode* n) { return _left = n; }
00089 
00090 inline HxSyntaxNode*
00091 HxSyntaxBranchNode::setRight(HxSyntaxNode* n) { return _right = n; }
00092 
00093 inline void*
00094 HxSyntaxBranchNode::operator new(size_t s)
00095 {
00096     if (!_memoryPool)
00097         _memoryPool = HxMemoryPoolFactory::instance().getMemoryPool(s);
00098     return _memoryPool->alloc();
00099 }
00100 
00101 inline void
00102 HxSyntaxBranchNode::operator delete(void* m) { _memoryPool->free(m); }
00103 
00104 #endif

Generated on Tue Feb 3 14:18:42 2004 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001