Jpp  17.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
static const JObjectSelector< T > & getDefault()
Get default value of template class.
Definition: JDefault.hh:24
virtual bool accept(argument_type object) const
Accept object.
virtual ~JObjectSelector()
Virtual destructor.
Type list.
Definition: JTypeList.hh:22
Interface for selection of objects.
JArgument< T >::argument_type argument_type
Definition: JClass.hh:82
JClass< T >::argument_type argument_type
Type definition of argument of interface method.
Auxiliary class for no type definition.
Definition: JNullType.hh:19
Simple default class.
Definition: JDefault.hh:18