Jpp  18.2.1
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 
28 
29 
30  /**
31  * Default constructor.
32  */
34  JPointer<JClass_t>()
35  {}
36 
37 
38  /**
39  * Constructor.
40  *
41  * \param p pointer to object
42  */
43  JMultiPointer(JClass_t* p) :
44  JPointer<JClass_t>(p)
45  {}
46 
47 
48  /**
49  * Reset multi-pointer.
50  *
51  * \param pointer multi-pointer
52  */
53  void reset(const JMultiPointer<JClass_t>& pointer)
54  {
55  static_cast<JPointer<JClass_t>&>(*this).reset(static_cast<const JPointer<JClass_t>&>(pointer).get());
56  }
57 
58 
59  /**
60  * Get single pointer.
61  *
62  * \return pointer
63  */
64  template<class T>
65  T* get() const
66  {
67  return static_cast<const JPointer<T>&>(*this).get();
68  }
69  };
70 
71 
72  /**
73  * Implementation of multiple pointers for multiple data types.
74  */
75  template<class JHead_t, class JTail_t>
76  struct JMultiPointer< JTypeList<JHead_t, JTail_t> > :
77  public JMultiPointer<JHead_t>,
78  public JMultiPointer<JTail_t>
79  {
80 
83 
84 
85  /**
86  * Default constructor.
87  */
89  JMultiPointer<JHead_t>(),
90  JMultiPointer<JTail_t>()
91  {}
92 
93 
94  /**
95  * Constructor.
96  *
97  * \param first first multi-pointer
98  * \param second second multi-pointer
99  */
101  const JMultiPointer<JTail_t>& second) :
102  JMultiPointer<JHead_t>(first),
103  JMultiPointer<JTail_t>(second)
104  {}
105 
106 
107  /**
108  * Reset multi-pointer.
109  *
110  * \param pointer multi-pointer
111  */
113  {
114  static_cast<JMultiPointer<JHead_t>&>(*this).reset(pointer);
115  static_cast<JMultiPointer<JTail_t>&>(*this).reset(pointer);
116  }
117 
118 
119  /**
120  * Reset multi-pointer.
121  *
122  * \param first first multi-pointer
123  * \param second second multi-pointer
124  */
126  const JMultiPointer<JTail_t>& second)
127  {
128  static_cast<JMultiPointer<JHead_t>&>(*this).reset(first);
129  static_cast<JMultiPointer<JTail_t>&>(*this).reset(second);
130  }
131 
132 
133  /**
134  * Check validity of pointer.
135  *
136  * \return true if all pointers are not null; else false
137  */
138  bool is_valid() const
139  {
140  return (static_cast<const JMultiPointer<JHead_t>&>(*this).is_valid() &&
141  static_cast<const JMultiPointer<JTail_t>&>(*this).is_valid());
142  }
143 
144 
145  /**
146  * Get single pointer.
147  *
148  * \return pointer
149  */
150  template<class T>
151  T* get() const
152  {
153  return static_cast<const JPointer<T>&>(*this).get();
154  }
155  };
156 
157 
158  /**
159  * Terminator class of recursive JMultiPointer class.
160  */
161  template<class JHead_t>
162  struct JMultiPointer< JTypeList<JHead_t, JNullType> > :
163  public JMultiPointer<JHead_t>
164  {
165  /**
166  * Default constructor.
167  */
169  JMultiPointer<JHead_t>()
170  {}
171 
172 
173  /**
174  * Constructor.
175  *
176  * \param p pointer to object
177  */
178  JMultiPointer(JHead_t* p) :
179  JMultiPointer<JHead_t>(p)
180  {}
181 
182 
183  /**
184  * Constructor.
185  *
186  * \param pointer multi-pointer
187  */
189  JMultiPointer<JHead_t>(pointer)
190  {}
191  };
192 }
193 
194 #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.