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