Jpp
JObjectSelector.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JOBJECTSELECTOR__
2 #define __JLANG__JOBJECTSELECTOR__
3 
4 #include "JLang/JDefault.hh"
5 #include "JLang/JTypeList.hh"
6 #include "JLang/JClass.hh"
7 
8 /**
9  * \author mdejong
10  */
11 
12 namespace JLANG {}
13 namespace JPP { using namespace JLANG; }
14 
15 namespace JLANG {
16 
17  /**
18  * Interface for selection of objects.
19  */
20  template<class T>
21  struct JObjectSelector :
22  public JDefault< JObjectSelector<T> >
23  {
24  /**
25  * Type definition of argument of interface method.
26  */
28 
29 
30  /**
31  * Virtual destructor.
32  */
33  virtual ~JObjectSelector()
34  {}
35 
36 
37  /**
38  * Accept object.
39  *
40  * \param object object
41  * \return true if accepted; else false
42  */
43  virtual bool accept(argument_type object) const
44  {
45  return true;
46  }
47  };
48 
49 
50  /**
51  * Interface for multiple selection of objects.
52  *
53  * This class recursively defines the JLANG::JObjectSelector interface
54  * for all data types by deriving from:
55  * - JObjectSelector<JHead_t>; and
56  * - JObjectSelector<JTail_t>.
57  */
58  template<class JHead_t, class JTail_t>
59  struct JObjectSelector< JTypeList<JHead_t, JTail_t> > :
60  public JDefault< JObjectSelector< JTypeList<JHead_t, JTail_t> > >,
61  public virtual JObjectSelector<JHead_t>,
62  public virtual JObjectSelector<JTail_t>
63  {
65  };
66 
67 
68  /**
69  * Terminator class of recursive JObjectSelector class.
70  */
71  template<class JHead_t>
72  struct JObjectSelector< JTypeList<JHead_t, JNullType> > :
73  public virtual JObjectSelector<JHead_t>
74  {};
75 }
76 
77 #endif
JLANG::JObjectSelector
Interface for selection of objects.
Definition: JObjectIterator.hh:33
JLANG::JNullType
Auxiliary class for no type definition.
Definition: JNullType.hh:19
JLANG::JClass::argument_type
JArgument< T >::argument_type argument_type
Definition: JClass.hh:82
JLANG::JDefault
Simple default class.
Definition: JDefault.hh:18
JDefault.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JLANG::JObjectSelector::~JObjectSelector
virtual ~JObjectSelector()
Virtual destructor.
Definition: JObjectSelector.hh:33
JLANG::JDefault< JObjectSelector< T > >::getDefault
static const JObjectSelector< T > & getDefault()
Get default value of template class.
Definition: JDefault.hh:24
JLANG::JTypeList
Type list.
Definition: JTypeList.hh:22
JLANG::JObjectSelector::accept
virtual bool accept(argument_type object) const
Accept object.
Definition: JObjectSelector.hh:43
JLANG::JObjectSelector::argument_type
JClass< T >::argument_type argument_type
Type definition of argument of interface method.
Definition: JObjectSelector.hh:27
JTypeList.hh
JClass.hh
JLANG
Auxiliary classes and methods for language specific functionality.
Definition: JAbstractClass.hh:10