Jpp
JMatch.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JMATCH__
2 #define __JTRIGGER__JMATCH__
3 
4 #include "JLang/JClonable.hh"
5 
6 
7 /**
8  * \file
9  *
10  * Base class for match operations for cluster and hit-preprocessing methods.
11  * \author mdejong
12  */
13 namespace JTRIGGER {}
14 namespace JPP { using namespace JTRIGGER; }
15 
16 namespace JTRIGGER {
17 
18  using JLANG::JClonable;
19 
20 
21  /**
22  * Function object interface for hit matching.
23  */
24  template<class JHit_t>
25  class JMatch :
26  public JClonable< JMatch<JHit_t> >
27  {
28  public:
29  /**
30  * Virtual destructor.
31  */
32  virtual ~JMatch()
33  {}
34 
35 
36  /**
37  * Match operator.
38  *
39  * \param first hit
40  * \param second hit
41  * \return match result
42  */
43  virtual bool operator()(const JHit_t& first, const JHit_t& second) const = 0;
44  };
45 
46 
47  /**
48  * Auxiliary class to handle pointer to match function.
49  */
50  template<class JHit_t>
51  class JMatchHelper :
52  public JClonable< JMatch<JHit_t> , JMatchHelper<JHit_t> >
53  {
54  public:
55 
56  typedef bool (*pFun)(const JHit_t&, const JHit_t&); //!< pointer to match function
57 
58  /**
59  * Constructor
60  *
61  * \param match pointer to match function
62  */
64  match(match)
65  {}
66 
67 
68  /**
69  * Match operator.
70  *
71  * \param first hit
72  * \param second hit
73  * \return match result
74  */
75  virtual bool operator()(const JHit_t& first, const JHit_t& second) const
76  {
77  return match(first, second);
78  }
79 
80  protected:
82  };
83 
84 
85  /**
86  * Auxiliary method to make JMatch object based on pointer to match function.
87  *
88  * \param match pointer to match function
89  * \return match object
90  */
91  template<class JHit_t>
92  JMatchHelper<JHit_t> make_match(bool (*match)(const JHit_t&, const JHit_t&))
93  {
94  return JMatchHelper<JHit_t>(match);
95  }
96 }
97 
98 #endif
JTRIGGER::JMatch::~JMatch
virtual ~JMatch()
Virtual destructor.
Definition: JMatch.hh:32
JTRIGGER::JMatchHelper::match
pFun match
Definition: JMatch.hh:81
JTRIGGER::JMatchHelper::operator()
virtual bool operator()(const JHit_t &first, const JHit_t &second) const
Match operator.
Definition: JMatch.hh:75
JTRIGGER::JMatch
Function object interface for hit matching.
Definition: JMatch.hh:25
JTRIGGER::JMatchHelper::JMatchHelper
JMatchHelper(pFun match)
Constructor.
Definition: JMatch.hh:63
JTRIGGER::JMatchHelper
Auxiliary class to handle pointer to match function.
Definition: JMatch.hh:51
JTRIGGER::JMatchHelper::pFun
bool(* pFun)(const JHit_t &, const JHit_t &)
pointer to match function
Definition: JMatch.hh:56
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JTRIGGER::make_match
JMatchHelper< JHit_t > make_match(bool(*match)(const JHit_t &, const JHit_t &))
Auxiliary method to make JMatch object based on pointer to match function.
Definition: JMatch.hh:92
JTRIGGER::JMatch::operator()
virtual bool operator()(const JHit_t &first, const JHit_t &second) const =0
Match operator.
JClonable.hh
JTRIGGER
Checksum.
Definition: JSupport/JSupport.hh:35
JLANG::JClonable
Template class for object cloning.
Definition: JClonable.hh:20