Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JParallelFileScanner.hh
Go to the documentation of this file.
1 #ifndef __JSUPPORT__JPARALLELFILESCANNER__
2 #define __JSUPPORT__JPARALLELFILESCANNER__
3 
4 #include "JLang/JTypeList.hh"
5 #include "JLang/JNullType.hh"
6 #include "JLang/JMultiPointer.hh"
7 
10 
11 
12 /**
13  * \file
14  * Parallel scanning of objects from a single file or multiple files according a format that follows from the file name extension.
15  * \author mdejong
16  */
17 namespace JSUPPORT {}
18 namespace JPP { using namespace JSUPPORT; }
19 
20 namespace JSUPPORT {
21 
22  using JLANG::JTypeList;
23  using JLANG::JNullType;
25 
26 
27  /**
28  * General purpose class for parallel reading of objects from a single file or multiple files.
29  */
30  template<class T, template<class> class JFileScanner_t = JSingleFileScanner>
32  public JFileScanner_t<T>
33  {
34  public:
35 
36  typedef typename JFileScanner_t<JNullType>::input_type input_type;
38 
39 
40  /**
41  * Default constructor.
42  */
44  {}
45 
46 
47  /**
48  * Constructor.
49  *
50  * \param input input
51  */
53  {
54  this->configure(input, JLimit());
55  }
56 
57 
58  /**
59  * Constructor.
60  *
61  * \param input input
62  * \param limit limit
63  */
64  JParallelFileScanner(const input_type& input, const JLimit& limit)
65  {
66  this->configure(input, limit);
67  }
68 
69 
70  /**
71  * Get next element.
72  *
73  * \return multi-pointer to element
74  */
75  virtual const multi_pointer_type& next() override
76  {
77  ps.set(JFileScanner_t<T>::next());
78 
79  return ps;
80  }
81 
82  private:
84  };
85 
86 
87  /**
88  * Template specialisation of JParallelFileScanner for multiple data types.
89  */
90  template<class JHead_t, class JTail_t, template<class> class JFileScanner_t>
91  class JParallelFileScanner<JTypeList<JHead_t, JTail_t>, JFileScanner_t> :
92  public JParallelFileScanner<JHead_t, JFileScanner_t>,
93  public JParallelFileScanner<JTail_t, JFileScanner_t>
94  {
95  public:
96 
97  typedef typename JFileScanner_t<JNullType>::input_type input_type;
99 
102 
103 
104  /**
105  * Default constructor.
106  */
108  {}
109 
110 
111  /**
112  * Constructor.
113  *
114  * \param input input
115  */
117  {
118  this->configure(input, JLimit());
119  }
120 
121 
122  /**
123  * Constructor.
124  *
125  * \param input input
126  * \param limit limit
127  */
128  JParallelFileScanner(const input_type& input, const JLimit& limit)
129  {
130  this->configure(input, limit);
131  }
132 
133 
134  /**
135  * Rewind.\n
136  * This method rewinds the JParallelFileScanner for each data type.
137  */
138  virtual void rewind() override
139  {
142  }
143 
144 
145  /**
146  * Check availability of next element.\n
147  * Note that the availability of the next element is tested for each data type.
148  *
149  * \return true if each iteration has more elements; else false
150  */
151  virtual bool hasNext() override
152  {
155  }
156 
157 
158  /**
159  * Get next element.
160  *
161  * \return multi-pointer to elements
162  */
163  virtual const multi_pointer_type& next() override
164  {
167 
168  return ps;
169  }
170 
171  private:
173  };
174 
175 
176  /**
177  * Terminator class of recursive JParallelFileScanner class.
178  */
179  template<class JHead_t, template<class> class JFileScanner_t>
180  class JParallelFileScanner<JTypeList<JHead_t, JNullType>, JFileScanner_t> :
181  public JParallelFileScanner<JHead_t, JFileScanner_t>
182  {
183  public:
184 
187 
188 
189  /**
190  * Default constructor.
191  */
193  JParallelFileScanner<JHead_t, JFileScanner_t>()
194  {}
195 
196 
197  /**
198  * Constructor.
199  *
200  * \param input input
201  */
203  {
204  this->configure(input, JLimit());
205  }
206 
207 
208  /**
209  * Constructor.
210  *
211  * \param input input
212  * \param limit limit
213  */
214  JParallelFileScanner(const input_type& input, const JLimit& limit)
215  {
216  this->configure(input, limit);
217  }
218  };
219 }
220 
221 #endif
virtual const multi_pointer_type & next() override
Get next element.
void reset(const JMultiPointer< JClass_t > &pointer)
Reset multi-pointer.
JParallelFileScanner(const input_type &input)
Constructor.
JParallelFileScanner(const input_type &input, const JLimit &limit)
Constructor.
General purpose class for parallel reading of objects from a single file or multiple files...
JParallelFileScanner(const input_type &input, const JLimit &limit)
Constructor.
Type list.
Definition: JTypeList.hh:22
Scanning of objects from a single file according a format that follows from the extension of each fil...
std::ostream & rewind(std::ostream &out)
Rewind character.
Definition: JManip.hh:221
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Implementation of multiple pointers for multiple data types.
Auxiliary class for no type definition.
Definition: JNullType.hh:19
virtual bool hasNext() override
Check availability of next element.
JParallelFileScanner< JHead_t, JFileScanner_t >::input_type input_type
virtual const multi_pointer_type & next() override
Get next element.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
JParallelFileScanner()
Default constructor.
void configure(const T &value, const JAbstractCollection< JAbscissa_t > &bounds, JBool< false > option)
Configuration of value.
JParallelFileScanner< JHead_t, JFileScanner_t >::multi_pointer_type multi_pointer_type
JParallelFileScanner(const input_type &input, const JLimit &limit)
Constructor.
Object reading from a list of files.
JFileScanner_t< JNullType >::input_type input_type
General purpose class for multiple pointers.
virtual void set(JClass_t *p) override
Set pointer.
Definition: JPointer.hh:75