PolyBoRi
CDelayedTermIter.h
Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //*****************************************************************************
00014 //*****************************************************************************
00015 
00016 // include basic definitions
00017 #include "pbori_defs.h"
00018 
00019 // include CTermIter definitions
00020 #include "CTermIter.h"
00021 
00022 #ifndef CDelayedTermIter_h_
00023 #define CDelayedTermIter_h_
00024 
00025 BEGIN_NAMESPACE_PBORI
00026 
00032 template <class TermType, class AppendOp, class TerminalValueOp, class DegIterBase>
00033 class CDelayedTermIter:
00034   public DegIterBase {
00035 
00036 public:
00037   typedef TermType term_type;
00038   typedef typename term_type::size_type size_type;
00039   typedef DegIterBase base;
00040 
00041 
00042   typedef CDelayedTermIter<term_type, AppendOp, TerminalValueOp, DegIterBase> self;
00043 
00044   typedef typename base::stack_type stack_type;
00045   typedef AppendOp appendop_type;
00046   typedef TerminalValueOp terminalop_type;
00047 
00049   CDelayedTermIter(): base() {}
00050 
00052   CDelayedTermIter(const self& rhs): base(rhs) {}
00053 
00055   CDelayedTermIter(const base& rhs): base(rhs) {}
00056 
00058   ~CDelayedTermIter() {}
00059 
00060   term_type term() const {
00061     stack_type the_stack(base::getStack());
00062 
00063     term_type result;
00064     result = terminalop_type()(result, !the_stack.empty());
00065 
00066     appendop_type do_append;
00067 
00068     while(!the_stack.empty() && the_stack.top().isValid()) {
00069 
00070       result =  do_append(result, *the_stack.top() );
00071       the_stack.pop();
00072     }
00073 
00074     return result;
00075   }
00076 };
00077 
00078 
00079 END_NAMESPACE_PBORI
00080 
00081 #endif