Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JSUPPORT::JParallelFileScanner< T, JFileScanner_t > Class Template Reference

General purpose class for parallel reading of objects from a single file or multiple files. More...

#include <JParallelFileScanner.hh>

Inheritance diagram for JSUPPORT::JParallelFileScanner< T, JFileScanner_t >:
JSUPPORT::JSingleFileScanner< T > JLANG::JRewindableObjectIterator< T > JLANG::JObjectIterator< T > JLANG::JRewindable< T >

Public Types

typedef JFileScanner_t< JNullType >::input_type input_type
 
typedef JMultiPointer< T > multi_pointer_type
 
typedef JRewindableObjectIterator< T >::pointer_type pointer_type
 

Public Member Functions

 JParallelFileScanner ()
 Default constructor.
 
 JParallelFileScanner (const input_type &input)
 Constructor.
 
 JParallelFileScanner (const input_type &input, const JLimit &limit)
 Constructor.
 
virtual const multi_pointer_typenext () override
 Get next element.
 
counter_type getCounter () const
 Get counter.
 
virtual void rewind () override
 Rewind.
 
virtual bool hasNext () override
 Check availability of next element.
 
virtual skip_type skip (const skip_type ns) override
 Skip items.
 

Protected Attributes

JFileScanner< T > scanner
 
counter_type counter
 

Private Attributes

multi_pointer_type ps
 

Detailed Description

template<class T, template< class > class JFileScanner_t = JSingleFileScanner>
class JSUPPORT::JParallelFileScanner< T, JFileScanner_t >

General purpose class for parallel reading of objects from a single file or multiple files.

Definition at line 33 of file JParallelFileScanner.hh.

Member Typedef Documentation

◆ input_type

template<class T , template< class > class JFileScanner_t = JSingleFileScanner>
JFileScanner_t<JNullType>::input_type JSUPPORT::JParallelFileScanner< T, JFileScanner_t >::input_type

Definition at line 38 of file JParallelFileScanner.hh.

◆ multi_pointer_type

template<class T , template< class > class JFileScanner_t = JSingleFileScanner>
JMultiPointer<T> JSUPPORT::JParallelFileScanner< T, JFileScanner_t >::multi_pointer_type

Definition at line 39 of file JParallelFileScanner.hh.

◆ pointer_type

template<class T >
JRewindableObjectIterator<T>::pointer_type JSUPPORT::JSingleFileScanner< T >::pointer_type
inherited

Definition at line 176 of file JSingleFileScanner.hh.

Constructor & Destructor Documentation

◆ JParallelFileScanner() [1/3]

template<class T , template< class > class JFileScanner_t = JSingleFileScanner>
JSUPPORT::JParallelFileScanner< T, JFileScanner_t >::JParallelFileScanner ( )
inline

Default constructor.

Definition at line 45 of file JParallelFileScanner.hh.

46 {}

◆ JParallelFileScanner() [2/3]

template<class T , template< class > class JFileScanner_t = JSingleFileScanner>
JSUPPORT::JParallelFileScanner< T, JFileScanner_t >::JParallelFileScanner ( const input_type & input)
inline

Constructor.

Parameters
inputinput

Definition at line 54 of file JParallelFileScanner.hh.

55 {
56 this->configure(input, JLimit());
57 }
void configure(const T &value, const JAbstractCollection< JAbscissa_t > &bounds, JBool< false > option)
Configuration of value.
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45

◆ JParallelFileScanner() [3/3]

template<class T , template< class > class JFileScanner_t = JSingleFileScanner>
JSUPPORT::JParallelFileScanner< T, JFileScanner_t >::JParallelFileScanner ( const input_type & input,
const JLimit & limit )
inline

Constructor.

Parameters
inputinput
limitlimit

Definition at line 66 of file JParallelFileScanner.hh.

67 {
68 this->configure(input, limit);
69 }

Member Function Documentation

◆ next()

template<class T , template< class > class JFileScanner_t = JSingleFileScanner>
virtual const multi_pointer_type & JSUPPORT::JParallelFileScanner< T, JFileScanner_t >::next ( )
inlineoverridevirtual

Get next element.

Returns
multi-pointer to element

Reimplemented from JSUPPORT::JSingleFileScanner< T >.

Reimplemented in JSUPPORT::JParallelFileScanner< JTypeList< JHead_t, JTail_t >, JFileScanner_t >, and JSUPPORT::JTriggeredFileScanner< JTypelist_t, JFileScanner_t >.

Definition at line 77 of file JParallelFileScanner.hh.

78 {
79 ps.set(JFileScanner_t<T>::next());
80
81 return ps;
82 }
virtual void set(JClass_t *p) override
Set pointer.
Definition JPointer.hh:75

◆ getCounter()

template<class T >
counter_type JSUPPORT::JSingleFileScanner< T >::getCounter ( ) const
inlineinherited

Get counter.

Returns
counter

Definition at line 231 of file JSingleFileScanner.hh.

232 {
233 return counter;
234 }

◆ rewind()

template<class T >
virtual void JSUPPORT::JSingleFileScanner< T >::rewind ( )
inlineoverridevirtualinherited

Rewind.

Implements JLANG::JRewindable< T >.

Reimplemented in JSUPPORT::JSingleFileScanner< JTypeList< JHead_t, JTail_t > >.

Definition at line 240 of file JSingleFileScanner.hh.

241 {
242 if (scanner.is_open()) {
243 scanner.close();
244 }
245
246 counter = 0;
247
248 scanner.reset();
249 }

◆ hasNext()

template<class T >
virtual bool JSUPPORT::JSingleFileScanner< T >::hasNext ( )
inlineoverridevirtualinherited

Check availability of next element.

Returns
true if the iteration has more elements; else false

Implements JLANG::JObjectIterator< T >.

Definition at line 257 of file JSingleFileScanner.hh.

258 {
259 if (is_valid()) {
260
261 if (counter < getUpperLimit()) {
262
263 // first time around
264
265 if (!scanner.is_open()) {
266 scanner.open(this->getFilename().c_str());
267 }
268
269 if (counter < getLowerLimit()) {
270 counter += scanner.skip(getLowerLimit() - counter);
271 }
272
273 if (!scanner.hasNext()) {
274
275 scanner.close();
276
277 return false;
278 }
279
280 return true;
281
282 } else {
283
284 // last time around
285
286 if (scanner.is_open()) {
287 scanner.close();
288 }
289
290 scanner.reset();
291 }
292 }
293
294 return false;
295 }
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
bool is_valid(const json &js)
Check validity of JSon data.

◆ skip()

template<class T >
virtual skip_type JSUPPORT::JSingleFileScanner< T >::skip ( const skip_type ns)
inlineoverridevirtualinherited

Skip items.

Parameters
nsnumber of items to skip
Returns
number of items skipped

Reimplemented from JLANG::JObjectIterator< T >.

Reimplemented in JSUPPORT::JSingleFileScanner< JTypeList< JHead_t, JTail_t > >.

Definition at line 317 of file JSingleFileScanner.hh.

318 {
319 const skip_type previous = counter;
320
321 counter += scanner.skip(ns);
322
323 return counter - previous;
324 }
unsigned int skip_type
Type definition for number of objects to skip.

Member Data Documentation

◆ ps

template<class T , template< class > class JFileScanner_t = JSingleFileScanner>
multi_pointer_type JSUPPORT::JParallelFileScanner< T, JFileScanner_t >::ps
private

Definition at line 85 of file JParallelFileScanner.hh.

◆ scanner

template<class T >
JFileScanner<T> JSUPPORT::JSingleFileScanner< T >::scanner
protectedinherited

Definition at line 328 of file JSingleFileScanner.hh.

◆ counter

template<class T >
counter_type JSUPPORT::JSingleFileScanner< T >::counter
protectedinherited

Definition at line 329 of file JSingleFileScanner.hh.


The documentation for this class was generated from the following file: