Permalink
Browse files

Make QDo a virtual function, letting subclasses filter everything if …

…they need to.
  • Loading branch information...
ElectricMagic committed May 21, 2012
1 parent 2400589 commit a8e78d772be531523f69117c2f50c1a4dbf8faeb
Showing with 5 additions and 15 deletions.
  1. +5 −15 zoolib/ZVisitor_Do_T.h
View
@@ -41,7 +41,7 @@ class ZVisitor_Do_T
{}
// Our protocol
- ZQ<Result_t> QDo(const ZRef<ZVisitee>& iRep)
+ virtual ZQ<Result_t> QDo(const ZRef<ZVisitee>& iRep)
{
if (iRep)
{
@@ -54,25 +54,15 @@ class ZVisitor_Do_T
Result_t DDo(const Result_t& iDefault, const ZRef<ZVisitee>& iRep)
{
- if (iRep)
- {
- ZSetRestore_T<ZQ<Result_t> > sr(fResultQ);
- iRep->Accept(*this);
- if (fResultQ)
- return *fResultQ;
- }
+ if (ZQ<Result_t> theQ = this->QDo(iRep))
+ return *theQ;
return iDefault;
}
Result_t Do(const ZRef<ZVisitee>& iRep)
{
- if (iRep)
- {
- ZSetRestore_T<ZQ<Result_t> > sr(fResultQ);
- iRep->Accept(*this);
- if (fResultQ)
- return *fResultQ;
- }
+ if (ZQ<Result_t> theQ = this->QDo(iRep))
+ return *theQ;
return Result_t();
}

0 comments on commit a8e78d7

Please sign in to comment.