Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

vgtl_visitor.h

Go to the documentation of this file.
00001 // Visitor implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2001-2003 Hermann Schichl
00004 //
00005 // This file is part of the Vienna Graph Template Library.  This library
00006 // is free software; you can redistribute it and/or modify it under the
00007 // terms of the Library GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // Library GNU General Public License for more details.
00015 
00016 // As a special exception, you may use this file as part of a free software
00017 // library without restriction.  Specifically, if other files instantiate
00018 // templates or use macros or inline functions from this file, or you compile
00019 // this file and link it with other files to produce an executable, this
00020 // file does not by itself cause the resulting executable to be covered by
00021 // the Library GNU General Public License.  This exception does not however
00022 // invalidate any other reasons why the executable file might be covered by
00023 // the Library GNU General Public License.
00024 
00030 #ifndef __VGTL_VISITOR_H
00031 #define __VGTL_VISITOR_H
00032 
00033 #include <vgtl_helpers.h>
00034 
00035 __VGTL_BEGIN_NAMESPACE
00036 
00037 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
00038 #pragma set woff 1209
00039 #endif
00040 
00041 //
00042 // visitor base class templates
00043 // 
00044 
00046 
00051 template <class _Node, class _Ret, class _Col = const _Ret&>
00052 class preorder_visitor
00053 {
00054 public:
00056   typedef _Ret return_value;
00057   typedef _Col collect_value;
00058 
00060   preorder_visitor() {}
00062   virtual ~preorder_visitor() {}
00063   
00065 
00066   virtual void vinit() { return; }
00067   virtual return_value vvalue() VGTL_PURE_VIRTUAL
00068   virtual void vcollect(collect_value __r) { return; }
00070 
00072 
00073   virtual bool preorder(const _Node& __n) { return true; }
00074   virtual void collect(const _Node& __n, collect_value __r) { return; }
00075   virtual return_value value() VGTL_PURE_VIRTUAL
00077 };
00078 
00080 
00085 template <class _Node, class _Ret, class _Col = const _Ret&>
00086 class postorder_visitor
00087 {
00088 public:
00089   typedef _Ret return_value;
00090   typedef _Col collect_value;
00091 
00093   postorder_visitor() {}
00095   virtual ~postorder_visitor() {}
00096   
00098 
00099   virtual void vinit() { return; }
00100   virtual return_value vvalue() VGTL_PURE_VIRTUAL
00101   virtual void vcollect(collect_value __r) { return; }
00103 
00105 
00106   virtual void init() { return; }
00107   virtual bool postorder(const _Node& __n) { return false; }
00108   virtual void collect(const _Node& __n, collect_value __r) { return; }
00109   virtual return_value value() VGTL_PURE_VIRTUAL
00111 };
00112 
00114 
00119 template <class _Node, class _Ret, class _Col = const _Ret&>
00120 class prepost_visitor
00121 {
00122 public:
00123   typedef _Ret return_value;
00124   typedef _Col collect_value;
00125 
00127   prepost_visitor() {}
00129   virtual ~prepost_visitor() {}
00130   
00132 
00133   virtual void vinit() { return; }
00134   virtual return_value vvalue() VGTL_PURE_VIRTUAL
00135   virtual void vcollect(collect_value __r) { return; }
00137 
00139 
00140   virtual bool preorder(const _Node& __n) { return true; }
00141   virtual bool postorder(const _Node& __n) { return false; }
00142   virtual void collect(const _Node& __n, collect_value __r) { return; }
00143   virtual return_value value() VGTL_PURE_VIRTUAL
00145 };
00146 
00147 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
00148 #pragma reset woff 1209
00149 #endif
00150 
00151 __VGTL_END_NAMESPACE
00152 
00153 #endif /* __VGTL_VISITOR_H */
00154 
00155 // Local Variables:
00156 // mode:C++
00157 // End:

Generated on Tue Nov 4 01:41:24 2003 for Vienna Graph Template Library by doxygen1.2.18