#ifndef TreeSearch__TreeWalk
#define TreeSearch__TreeWalk
#include "Node.h"
#include <fstream>
#include <iostream>
#include <map>
namespace TreeSearch {
class NodeVisitor {
public:
enum ETreeOp { kRecurse, kRecurseUncond, kSkipChildNodes, kError };
virtual ETreeOp operator() ( const NodeDescriptor& nd ) = 0;
virtual ~NodeVisitor() {}
protected:
static void SetLinkPattern( Link* link, Pattern* pattern );
static void SetLinkType( Link* link, Int_t type );
static void SetLinkNext( Link* link, Link* next );
static void SetPatternChild( Pattern* pat, Link* link );
};
class TreeWalk {
private:
UInt_t fNlevels;
public:
TreeWalk( UInt_t nlevels = 0 ) : fNlevels(nlevels) {}
virtual ~TreeWalk() {}
void SetNlevels( UInt_t n ) { fNlevels = n; }
NodeVisitor::ETreeOp
operator() ( Link* link, NodeVisitor& op, Pattern* parent = 0,
UInt_t depth = 0, UInt_t shift = 0,
Bool_t mirrored = false ) const;
ClassDef(TreeWalk, 0)
};
class WritePattern : public NodeVisitor {
public:
WritePattern( const char* filename, size_t index_size = sizeof(Int_t) );
virtual ~WritePattern() { delete os; }
virtual ETreeOp operator() ( const NodeDescriptor& nd );
private:
std::ofstream* os;
size_t fIdxSiz;
std::map<Pattern*,Int_t> fMap;
WritePattern( const WritePattern& orig );
WritePattern& operator=( const WritePattern& rhs );
};
class CountPattern : public NodeVisitor {
public:
CountPattern() : fCount(0) {}
virtual ETreeOp operator() ( const NodeDescriptor& )
{ fCount++; return kRecurse; }
ULong64_t GetCount() const { return fCount; }
private:
ULong64_t fCount;
};
class PrintPattern : public NodeVisitor {
public:
PrintPattern( std::ostream& ostr = std::cout, bool dump = false )
: os(ostr), fCount(0), fDump(dump) {}
virtual ETreeOp operator() ( const NodeDescriptor& nd );
ULong64_t GetCount() const { return fCount; }
private:
std::ostream& os;
ULong64_t fCount;
Bool_t fDump;
};
}
#endif
Last update: Tue Jul 7 19:26:19 2009
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.