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  * \param limit limit
52  */
53  JParallelFileScanner(const input_type& input, const JLimit& limit = JLimit())
54  {
55  this->configure(input, limit);
56  }
57 
58 
59  /**
60  * Get next element.
61  *
62  * \return multi-pointer to element
63  */
64  virtual const multi_pointer_type& next()
65  {
66  ps.set(JFileScanner_t<T>::next());
67 
68  return ps;
69  }
70 
71  private:
73  };
74 
75 
76  /**
77  * Template specialisation of JParallelFileScanner for multiple data types.
78  */
79  template<class JHead_t, class JTail_t, template<class> class JFileScanner_t>
80  class JParallelFileScanner<JTypeList<JHead_t, JTail_t>, JFileScanner_t> :
81  public JParallelFileScanner<JHead_t, JFileScanner_t>,
82  public JParallelFileScanner<JTail_t, JFileScanner_t>
83  {
84  public:
85 
86  typedef typename JFileScanner_t<JNullType>::input_type input_type;
88 
91 
92 
93  /**
94  * Default constructor.
95  */
97  {}
98 
99 
100  /**
101  * Constructor.
102  *
103  * \param input input
104  * \param limit limit
105  */
106  JParallelFileScanner(const input_type& input, const JLimit& limit = JLimit())
107  {
108  this->configure(input, limit);
109  }
110 
111 
112  /**
113  * Rewind.\n
114  * This method rewinds the JParallelFileScanner for each data type.
115  */
116  virtual void rewind()
117  {
120  }
121 
122 
123  /**
124  * Check availability of next element.\n
125  * Note that the availability of the next element is tested for each data type.
126  *
127  * \return true if each iteration has more elements; else false
128  */
129  virtual bool hasNext()
130  {
133  }
134 
135 
136  /**
137  * Get next element.
138  *
139  * \return multi-pointer to elements
140  */
141  virtual const multi_pointer_type& next()
142  {
145 
146  return ps;
147  }
148 
149  private:
151  };
152 
153 
154  /**
155  * Terminator class of recursive JParallelFileScanner class.
156  */
157  template<class JHead_t, template<class> class JFileScanner_t>
158  class JParallelFileScanner<JTypeList<JHead_t, JNullType>, JFileScanner_t> :
159  public JParallelFileScanner<JHead_t, JFileScanner_t>
160  {
161  public:
162 
165 
166 
167  /**
168  * Default constructor.
169  */
171  JParallelFileScanner<JHead_t, JFileScanner_t>()
172  {}
173 
174 
175  /**
176  * Constructor.
177  *
178  * \param input input
179  * \param limit limit
180  */
181  JParallelFileScanner(const input_type& input, const JLimit& limit = JLimit())
182  {
183  this->configure(input, limit);
184  }
185  };
186 }
187 
188 #endif
std::ostream & rewind(std::ostream &out)
Rewind character.
Definition: JPrint.hh:258
void reset(const JMultiPointer< JClass_t > &pointer)
Reset multi-pointer.
General purpose class for parallel reading of objects from a single file or multiple files...
Type list.
Definition: JTypeList.hh:22
Scanning of objects from a single file according a format that follows from the extension of each fil...
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
JParallelFileScanner< JHead_t, JFileScanner_t >::input_type input_type
virtual const multi_pointer_type & next()
Constructor.
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
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)
Set pointer.
Definition: JPointer.hh:75