00001
00002
00037
00038
00039
00040 #include "pbori_defs.h"
00041
00042
00043 #include "CTermIter.h"
00044
00045 #ifndef CDelayedTermIter_h_
00046 #define CDelayedTermIter_h_
00047
00048 BEGIN_NAMESPACE_PBORI
00049
00055 template <class TermType, class AppendOp, class TerminalValueOp, class DegIterBase>
00056 class CDelayedTermIter:
00057 public DegIterBase {
00058
00059 public:
00060 typedef TermType term_type;
00061 typedef typename term_type::size_type size_type;
00062 typedef DegIterBase base;
00063
00064
00065 typedef CDelayedTermIter<term_type, AppendOp, TerminalValueOp, DegIterBase> self;
00066
00067 typedef typename base::stack_type stack_type;
00068 typedef AppendOp appendop_type;
00069 typedef TerminalValueOp terminalop_type;
00070
00072 CDelayedTermIter(): base() {}
00073
00075 CDelayedTermIter(const self& rhs): base(rhs) {}
00076
00078 CDelayedTermIter(const base& rhs): base(rhs) {}
00079
00081 ~CDelayedTermIter() {}
00082
00083 term_type term() const {
00084 stack_type the_stack(base::getStack());
00085
00086 term_type result;
00087 result = terminalop_type()(result, !the_stack.empty());
00088
00089 appendop_type do_append;
00090
00091 while(!the_stack.empty() && the_stack.top().isValid()) {
00092
00093 result = do_append(result, *the_stack.top() );
00094 the_stack.pop();
00095 }
00096
00097 return result;
00098 }
00099 };
00100
00101
00102 END_NAMESPACE_PBORI
00103
00104 #endif