susy_cfa  b611ccad937ea179f86a1f5663960264616c0a20
cut.hpp
Go to the documentation of this file.
1 #ifndef H_CUT
2 #define H_CUT
3 
4 #include "small_tree.hpp"
5 
6 // Allows selection of different cut comparisons
8  kNotEqual = -3,
9  kLess = -2,
10  kLessEqual = -1,
11  kEqual = 0,
12  kGreater = 1,
14 };
15 
16 // Pointers to the base class can be stored in containers (e.g. vectors). Selection of the template derived class is done automatically by dynamic dispatch
17 struct CutBase{
18  CutBase();
19  CutBase(small_tree const * tree,
20  InequalityType compare = kGreaterEqual);
21 
22  virtual bool Pass() const;
23  operator bool();
24 
25  small_tree const * tree_;
27 
28  virtual ~CutBase();
29 };
30 
31 // The actual implementation for each type is done in this template class
32 template<typename T>
33 struct Cut : public CutBase{
34  typedef T ReturnType;
35  typedef const ReturnType& (small_tree::* FunctionPtrType)() const;
36 
37  Cut();
38  Cut(small_tree const * tree,
39  FunctionPtrType func,
40  const ReturnType &cut_val,
41  InequalityType compare = kGreaterEqual);
42 
43  bool Pass() const;
44 
45  ReturnType cut_val_;
46  FunctionPtrType func_;
47 };
48 
49 // Some convenience functions for making new cuts without specifying the type
50 template<typename T>
51 Cut<T> MakeCut(small_tree const * tree,
52  const T& (small_tree::* func)() const,
53  const T &cut_val,
54  InequalityType compare = kGreaterEqual);
55 
56 template<typename T>
57 Cut<T> * NewCut(small_tree const * tree,
58  const T& (small_tree::* func)() const,
59  const T &cut_val,
60  InequalityType compare = kGreaterEqual);
61 
62 #include "cut_impl.hpp"
63 
64 #endif
InequalityType
Definition: cut.hpp:7
InequalityType compare_
Definition: cut.hpp:26
small_tree const * tree_
Definition: cut.hpp:25
Definition: cut.hpp:8
Definition: cut.hpp:12
FunctionPtrType func_
Definition: cut.hpp:46
virtual bool Pass() const
Definition: cut.cpp:16
ReturnType cut_val_
Definition: cut.hpp:45
Definition: cut.hpp:33
CutBase()
Definition: cut.cpp:5
virtual ~CutBase()
Definition: cut.cpp:24
Definition: cut.hpp:17
Cut< T > * NewCut(small_tree const *tree, const T &(small_tree::*func)() const, const T &cut_val, InequalityType compare=kGreaterEqual)
Definition: cut_impl.hpp:48
T ReturnType
Definition: cut.hpp:34
Definition: cut.hpp:9
const ReturnType &(small_tree::* FunctionPtrType)() const
Definition: cut.hpp:35
Definition: cut.hpp:11
Cut< T > MakeCut(small_tree const *tree, const T &(small_tree::*func)() const, const T &cut_val, InequalityType compare=kGreaterEqual)
Definition: cut_impl.hpp:40