00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
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
00154
00155
00156
00157