Changeset 1224


Ignore:
Timestamp:
Oct 17, 2010, 6:23:14 PM (11 years ago)
Author:
Peter Johansson
Message:

refs #476. Functions in Node structure that interacts with visitors.

Location:
branches/visitor/lib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/visitor/lib/Directory.cc

    r1186 r1224  
    2727#include "html_utility.h"
    2828#include "Node.h"
     29#include "NodeVisitor.h"
    2930#include "SVN.h"
    3031#include "SVNlog.h"
     
    278279  }
    279280
     281
     282  void Directory::traverse(NodeVisitor& visitor)
     283  {
     284    visitor.enter(*this);
     285    for (NodeIterator first=daughters_.begin(), end=daughters_.end();
     286         first!=end; ++first)
     287      (*first)->traverse(visitor);
     288    visitor.leave(*this);
     289  }
     290
     291
    280292}} // end of namespace svndigest and namespace theplu
  • branches/visitor/lib/Directory.h

    r978 r1224  
    3232namespace theplu{
    3333namespace svndigest{
     34
     35  class NodeVisitor;
    3436
    3537  ///
     
    9698                         const std::map<int, svn_revnum_t>&) const;
    9799
     100    /**
     101       Calls visitor.enter(*this), traverses daughter nodes, and calls
     102       visitor.leave(*this).
     103     */
     104    void traverse(NodeVisitor& visitor);
     105
    98106  private:
    99107    /**
  • branches/visitor/lib/File.cc

    r1222 r1224  
    3030#include "html_utility.h"
    3131#include "HtmlStream.h"
     32#include "NodeVisitor.h"
    3233#include "Stats.h"
    3334#include "SVNblame.h"
     
    398399  }
    399400
     401
     402  void File::traverse(NodeVisitor& visitor)
     403  {
     404    visitor.visit(*this);
     405  }
     406
     407
    400408  void File::update_copyright(const std::string& new_block,
    401409                              size_t start_at_line, size_t end_at_line) const
  • branches/visitor/lib/File.h

    r978 r1224  
    3131namespace theplu{
    3232namespace svndigest{
     33
     34  class NodeVisitor;
    3335
    3436  class File : public Node
     
    7779    void print_copyright(std::map<std::string, Alias>&, bool verbose,
    7880                         const std::map<int, svn_revnum_t>&) const;
     81
     82    /**
     83       Let the visitor perform its mission via visitor(*this)
     84     */
     85    void traverse(NodeVisitor& visitor);
    7986
    8087  private:
  • branches/visitor/lib/Node.h

    r1137 r1224  
    4040
    4141  class Alias;
     42  class NodeVisitor;
    4243
    4344  ///
     
    193194    */
    194195    inline bool svndigest_ignore(void) const { return svndigest_ignore_; }
     196
     197    /**
     198       Access point for a NodeVisitor to start traversing Node and its
     199       daughter nodes.
     200     */
     201    virtual void traverse(NodeVisitor& visitor)=0;
    195202
    196203    /**
Note: See TracChangeset for help on using the changeset viewer.