Jpp  15.0.1-rc.2-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMultiPointer.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JMULTIPOINTER__
2 #define __JLANG__JMULTIPOINTER__
3 
4 #include "JLang/JPointer.hh"
5 #include "JLang/JTypeList.hh"
6 #include "JLang/JNullType.hh"
7 
8 
9 /**
10  * \author mdejong
11  */
12 
13 namespace JLANG {}
14 namespace JPP { using namespace JLANG; }
15 
16 namespace JLANG {
17 
18  /**
19  * General purpose class for multiple pointers.
20  */
21  template<class JClass_t>
22  struct JMultiPointer :
23  public JPointer<JClass_t>
24  {
25 
27 
28 
29  /**
30  * Default constructor.
31  */
33  JPointer<JClass_t>()
34  {}
35 
36 
37  /**
38  * Constructor.
39  *
40  * \param p pointer to object
41  */
42  JMultiPointer(JClass_t* p) :
43  JPointer<JClass_t>(p)
44  {}
45 
46 
47  /**
48  * Reset multi-pointer.
49  *
50  * \param pointer multi-pointer
51  */
52  void reset(const JMultiPointer<JClass_t>& pointer)
53  {
54  static_cast<JPointer<JClass_t>&>(*this).reset(static_cast<const JPointer<JClass_t>&>(pointer).get());
55  }
56 
57 
58  /**
59  * Get single pointer.
60  *
61  * \return pointer
62  */
63  template<class T>
64  T* get() const
65  {
66  return static_cast<const JPointer<T>&>(*this).get();
67  }
68  };
69 
70 
71  /**
72  * Implementation of multiple pointers for multiple data types.
73  */
74  template<class JHead_t, class JTail_t>
75  struct JMultiPointer< JTypeList<JHead_t, JTail_t> > :
76  public JMultiPointer<JHead_t>,
77  public JMultiPointer<JTail_t>
78  {
79 
82 
83 
84  /**
85  * Default constructor.
86  */
88  JMultiPointer<JHead_t>(),
89  JMultiPointer<JTail_t>()
90  {}
91 
92 
93  /**
94  * Constructor.
95  *
96  * \param first first multi-pointer
97  * \param second second multi-pointer
98  */
100  const JMultiPointer<JTail_t>& second) :
101  JMultiPointer<JHead_t>(first),
102  JMultiPointer<JTail_t>(second)
103  {}
104 
105 
106  /**
107  * Reset multi-pointer.
108  *
109  * \param pointer multi-pointer
110  */
112  {
113  static_cast<JMultiPointer<JHead_t>&>(*this).reset(pointer);
114  static_cast<JMultiPointer<JTail_t>&>(*this).reset(pointer);
115  }
116 
117 
118  /**
119  * Reset multi-pointer.
120  *
121  * \param first first multi-pointer
122  * \param second second multi-pointer
123  */
125  const JMultiPointer<JTail_t>& second)
126  {
127  static_cast<JMultiPointer<JHead_t>&>(*this).reset(first);
128  static_cast<JMultiPointer<JTail_t>&>(*this).reset(second);
129  }
130 
131 
132  /**
133  * Check validity of pointer.
134  *
135  * \return true if all pointers are not null; else false
136  */
137  bool is_valid() const
138  {
139  return (static_cast<const JMultiPointer<JHead_t>&>(*this).is_valid() &&
140  static_cast<const JMultiPointer<JTail_t>&>(*this).is_valid());
141  }
142 
143 
144  /**
145  * Get single pointer.
146  *
147  * \return pointer
148  */
149  template<class T>
150  T* get() const
151  {
152  return static_cast<const JPointer<T>&>(*this).get();
153  }
154  };
155 
156 
157  /**
158  * Terminator class of recursive JMultiPointer class.
159  */
160  template<class JHead_t>
161  struct JMultiPointer< JTypeList<JHead_t, JNullType> > :
162  public JMultiPointer<JHead_t>
163  {
164  /**
165  * Default constructor.
166  */
168  JMultiPointer<JHead_t>()
169  {}
170 
171 
172  /**
173  * Constructor.
174  *
175  * \param p pointer to object
176  */
177  JMultiPointer(JHead_t* p) :
178  JMultiPointer<JHead_t>(p)
179  {}
180 
181 
182  /**
183  * Constructor.
184  *
185  * \param pointer multi-pointer
186  */
188  JMultiPointer<JHead_t>(pointer)
189  {}
190  };
191 }
192 
193 #endif
void reset(const JMultiPointer< JClass_t > &pointer)
Reset multi-pointer.
JMultiPointer()
Default constructor.
void reset(const JMultiPointer< JTypeList< JHead_t, JTail_t > > &pointer)
Reset multi-pointer.
bool is_valid() const
Check validity of pointer.
bool is_valid() const
Check validity of pointer.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
Type list.
Definition: JTypeList.hh:22
void reset(const JMultiPointer< JHead_t > &first, const JMultiPointer< JTail_t > &second)
Reset multi-pointer.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Auxiliary class for no type definition.
Definition: JNullType.hh:19
Template implementation of class that holds pointer to object(s).
Definition: JPointer.hh:22
JMultiPointer(const JMultiPointer< JHead_t > &pointer)
Constructor.
General purpose class for multiple pointers.
virtual JClass_t * get() const override
Get pointer.
Definition: JPointer.hh:64
virtual void reset() override
Reset pointer.
Definition: JPointer.hh:84
JMultiPointer(JClass_t *p)
Constructor.
JMultiPointer(const JMultiPointer< JHead_t > &first, const JMultiPointer< JTail_t > &second)
Constructor.