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

HxSyntaxLeafNode.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 HxSyntaxLeafNode_h
00012 #define HxSyntaxLeafNode_h
00013 
00014 #include "HxIoFwd.h"
00015 #include "HxToken.h"
00016 #include "HxSyntaxNode.h"
00017 
00018 #include "HxMemoryPool.h"
00019 #include "HxMemoryPoolFactory.h"
00020 
00021 
00022 class HxSyntaxLeafNode : public HxSyntaxNode
00023 {
00024 public:
00025                             HxSyntaxLeafNode(const HxToken&);
00026     virtual                 ~HxSyntaxLeafNode();
00027 
00028     virtual int             type() const;
00029     virtual STD_OSTREAM&    put(STD_OSTREAM&, int indent = 0) const;
00030 
00031     HxToken&                token();
00032 
00033     virtual void            destroy();
00034 
00035     void*                   operator new(size_t);
00036     void                    operator delete(void*);
00037 
00038 private:
00039     HxToken                 _token;
00040 
00041     static HxMemoryPool*    _memoryPool;
00042 
00043 };
00044 
00045 inline HxSyntaxNode*
00046 makeHxSyntaxNode(const HxToken& token) { return new HxSyntaxLeafNode(token); }
00047 
00048 inline
00049 HxSyntaxLeafNode::HxSyntaxLeafNode(const HxToken& token) : _token(token) {}
00050 
00051 inline HxToken&
00052 HxSyntaxLeafNode::token() { return _token; }
00053 
00054 inline void*
00055 HxSyntaxLeafNode::operator new(size_t s)
00056 {
00057     if (!_memoryPool)
00058         _memoryPool = HxMemoryPoolFactory::instance().getMemoryPool(s);
00059     return _memoryPool->alloc();
00060 }
00061 
00062 inline void
00063 HxSyntaxLeafNode::operator delete(void* m) { _memoryPool->free(m); }
00064 
00065 #endif

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