susy_cfa  b611ccad937ea179f86a1f5663960264616c0a20
cut_impl.hpp
Go to the documentation of this file.
1 //Implementation for template functions needed by cut.hpp
2 
3 #ifndef H_CUT_IMPL
4 #define H_CUT_IMPL
5 
6 #include "cut.hpp"
7 
8 template<typename T>
10  CutBase(),
11  func_(NULL){
12 }
13 
14 template<typename T>
15 Cut<T>::Cut(small_tree const * tree,
16  FunctionPtrType func,
17  const T &cut_val,
18  InequalityType compare):
19  CutBase(tree, compare),
20  cut_val_(cut_val),
21  func_(func){
22  }
23 
24 template<typename T>
25 bool Cut<T>::Pass() const{
26  if(!(tree_ && func_)) return false;
27  ReturnType val = (tree_->*func_)();
28  switch(compare_){
29  case kNotEqual: return val != cut_val_;
30  case kLess: return val < cut_val_;
31  case kLessEqual: return val <= cut_val_;
32  case kEqual: return val == cut_val_;
33  default:
34  case kGreaterEqual: return val >= cut_val_;
35  case kGreater: return val > cut_val_;
36  }
37 }
38 
39 template<typename T>
40 Cut<T> MakeCut(small_tree const * tree,
41  const T& (small_tree::* func)() const,
42  const T &cut_val,
43  InequalityType compare){
44  return Cut<T>(tree, func, cut_val, compare);
45 }
46 
47 template<typename T>
48 Cut<T> * NewCut(small_tree const * tree,
49  const T& (small_tree::* func)() const,
50  const T &cut_val,
51  InequalityType compare){
52  return new Cut<T>(tree, func, cut_val, compare);
53 }
54 
55 #endif
InequalityType
Definition: cut.hpp:7
InequalityType compare_
Definition: cut.hpp:26
Cut()
Definition: cut_impl.hpp:9
small_tree const * tree_
Definition: cut.hpp:25
Definition: cut.hpp:8
Definition: cut.hpp:12
FunctionPtrType func_
Definition: cut.hpp:46
ReturnType cut_val_
Definition: cut.hpp:45
bool Pass() const
Definition: cut_impl.hpp:25
Definition: cut.hpp:33
Definition: cut.hpp:17
Cut< T > * NewCut(small_tree const *tree, const T &(small_tree::*func)() const, const T &cut_val, InequalityType compare)
Definition: cut_impl.hpp:48
T ReturnType
Definition: cut.hpp:34
Definition: cut.hpp:9
Cut< T > MakeCut(small_tree const *tree, const T &(small_tree::*func)() const, const T &cut_val, InequalityType compare)
Definition: cut_impl.hpp:40
const ReturnType &(small_tree::* FunctionPtrType)() const
Definition: cut.hpp:35
Definition: cut.hpp:11