PolyBoRi
CDelayedTermIter.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
40 //*****************************************************************************
41 
42 // include basic definitions
43 #include "pbori_defs.h"
44 
45 // include CTermIter definitions
46 #include "CTermIter.h"
47 
48 #ifndef CDelayedTermIter_h_
49 #define CDelayedTermIter_h_
50 
52 
58 template <class TermType, class AppendOp, class TerminalValueOp, class DegIterBase>
60  public DegIterBase {
61 
62 public:
63  typedef TermType term_type;
64  typedef typename term_type::size_type size_type;
65  typedef DegIterBase base;
66 
67 
69 
70  typedef typename base::stack_type stack_type;
71  typedef AppendOp appendop_type;
72  typedef TerminalValueOp terminalop_type;
73 
76 
78  CDelayedTermIter(const self& rhs): base(rhs) {}
79 
81  CDelayedTermIter(const base& rhs): base(rhs) {}
82 
85 
86  term_type term() const {
87  stack_type the_stack(base::getStack());
88 
89  term_type result;
90  result = terminalop_type()(result, !the_stack.empty());
91 
92  appendop_type do_append;
93 
94  while(!the_stack.empty() && the_stack.top().isValid()) {
95 
96  result = do_append(result, *the_stack.top() );
97  the_stack.pop();
98  }
99 
100  return result;
101  }
102 };
103 
104 
106 
107 #endif