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

Auxiliary class to sample from a list of files. More...

#include <JMultipleFileSampler.hh>

Inheritance diagram for JSUPPORT::JMultipleFileSampler< T, JSampler_t >:
JSUPPORT::JMultipleFileSampler_t< T > JLANG::JObjectSampler< T, JSampler_t > JLANG::JObjectIterator< T >

Public Types

typedef JSampler_t< T > sampler_type
 
typedef JObjectIterator< T >::pointer_type pointer_type
 

Public Member Functions

 JMultipleFileSampler (const sampler_type &sampler=sampler_type())
 Constructor.
 
const JMultipleFileScanner< T > *const operator-> () const
 Smart pointer operator.
 
JMultipleFileScanner< T > * operator-> ()
 Smart pointer operator.
 
virtual bool hasNext () override
 Check availability of next element.
 
virtual const pointer_typenext () override
 Get next element.
 
const JSampler_t< T > & getSampler () const
 Get sampler.
 
JSampler_t< T > & getSampler ()
 Get sampler.
 
virtual skip_type skip (const skip_type ns)
 Skip items.
 

Protected Attributes

JMultipleFileScanner< T > scanner
 
JRewindableObjectIterator< T > & in
 
JSampler_t< T > sampler
 
JPointer< T > ps
 
bool has_next
 

Detailed Description

template<class T, template< class > class JSampler_t = JSampler>
struct JSUPPORT::JMultipleFileSampler< T, JSampler_t >

Auxiliary class to sample from a list of files.

Definition at line 55 of file JMultipleFileSampler.hh.

Member Typedef Documentation

◆ sampler_type

template<class T , template< class > class JSampler_t = JSampler>
JSampler_t<T> JSUPPORT::JMultipleFileSampler< T, JSampler_t >::sampler_type

Definition at line 60 of file JMultipleFileSampler.hh.

◆ pointer_type

template<class T , template< class > class JSampler_t = JSampler>
JObjectIterator<T>::pointer_type JLANG::JObjectSampler< T, JSampler_t >::pointer_type
inherited

Definition at line 45 of file JObjectSampler.hh.

Constructor & Destructor Documentation

◆ JMultipleFileSampler()

template<class T , template< class > class JSampler_t = JSampler>
JSUPPORT::JMultipleFileSampler< T, JSampler_t >::JMultipleFileSampler ( const sampler_type & sampler = sampler_type())
inline

Constructor.

Parameters
samplersampler

Definition at line 68 of file JMultipleFileSampler.hh.

68 :
71 {}
JSampler_t< T > sampler
JObjectSampler(JRewindableObjectIterator< T > &input)
Constructor.
Auxiliary base class to sample from a list of files.

Member Function Documentation

◆ operator->() [1/2]

template<class T >
const JMultipleFileScanner< T > *const JSUPPORT::JMultipleFileSampler_t< T >::operator-> ( ) const
inlineinherited

Smart pointer operator.

Returns
pointer to scanner

Definition at line 31 of file JMultipleFileSampler.hh.

32 {
33 return &scanner;
34 }

◆ operator->() [2/2]

template<class T >
JMultipleFileScanner< T > * JSUPPORT::JMultipleFileSampler_t< T >::operator-> ( )
inlineinherited

Smart pointer operator.

Returns
pointer to scanner

Definition at line 41 of file JMultipleFileSampler.hh.

42 {
43 return &scanner;
44 }

◆ hasNext()

template<class T , template< class > class JSampler_t = JSampler>
virtual bool JLANG::JObjectSampler< T, JSampler_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 78 of file JObjectSampler.hh.

79 {
80 while (!has_next) {
81
82 if (!in.hasNext()) {
83 in.rewind();
84 }
85
86 if (in.hasNext()) {
87
88 ps.set(in.next());
89
90 skip_type ns = sampler(*ps);
91
92 if (ns == 0) {
93
94 has_next = true;
95
96 } else {
97
98 while ((ns -= in.skip(ns)) != 0) {
99 in.rewind();
100 }
101 }
102
103 } else {
104
105 // nothing to sample
106
107 break;
108 }
109 }
110
111 return has_next;
112 }
JRewindableObjectIterator< T > & in
virtual void set(JClass_t *p) override
Set pointer.
Definition JPointer.hh:75
unsigned int skip_type
Type definition for number of objects to skip.

◆ next()

template<class T , template< class > class JSampler_t = JSampler>
virtual const pointer_type & JLANG::JObjectSampler< T, JSampler_t >::next ( )
inlineoverridevirtualinherited

Get next element.

Returns
pointer to element

Implements JLANG::JObjectIterator< T >.

Definition at line 120 of file JObjectSampler.hh.

121 {
122 if (!has_next) {
123 ps.reset(NULL);
124 }
125
126 has_next = false;
127
128 return ps;
129 }
virtual void reset() override
Reset pointer.
Definition JPointer.hh:84

◆ getSampler() [1/2]

template<class T , template< class > class JSampler_t = JSampler>
const JSampler_t< T > & JLANG::JObjectSampler< T, JSampler_t >::getSampler ( ) const
inlineinherited

Get sampler.

Returns
sampler

Definition at line 137 of file JObjectSampler.hh.

138 {
139 return sampler;
140 }

◆ getSampler() [2/2]

template<class T , template< class > class JSampler_t = JSampler>
JSampler_t< T > & JLANG::JObjectSampler< T, JSampler_t >::getSampler ( )
inlineinherited

Get sampler.

Returns
sampler

Definition at line 148 of file JObjectSampler.hh.

149 {
150 return sampler;
151 }

◆ skip()

template<class T >
virtual skip_type JLANG::JObjectIterator< T >::skip ( const skip_type ns)
inlinevirtualinherited

Skip items.

Parameters
nsnumber of items to skip
Returns
number of items skipped

Reimplemented in JLANG::JAbstractObjectReader< T >, JLANG::JAbstractObjectReader< const event_type >, JLANG::JAbstractObjectReader< Evt >, JLANG::JAbstractObjectReader< JDAQSummaryslice >, JLANG::JAbstractObjectReader< JHead_t >, JLANG::JAbstractObjectReader< JTail_t >, JLANG::JAbstractObjectReader< JTypeList< JDAQEvent, JNullType > >, JLANG::JAbstractObjectReader< KM3NETDAQ::JDAQEvent >, JLANG::JPipe< T >, JLANG::JPipe< JHead_t >, JLANG::JPipe< JTail_t >, JLANG::JSTDObjectIterator< T >, JROOT::JRootFileReader< T, false >, JROOT::JTreeReaderObjectIterator< T >, JSUPPORT::JMultipleFileScanner< T >, JSUPPORT::JMultipleFileScanner< Evt >, JSUPPORT::JMultipleFileScanner< JDAQSummaryslice >, JSUPPORT::JMultipleFileScanner< JHead_t >, JSUPPORT::JMultipleFileScanner< JTail_t >, JSUPPORT::JMultipleFileScanner< JTypeList< JDAQEvent, JNullType > >, JSUPPORT::JMultipleFileScanner< JTypeList< JHead_t, JTail_t > >, JSUPPORT::JMultipleFileScanner< KM3NETDAQ::JDAQEvent >, JSUPPORT::JMultipleFileScanner<>, JSUPPORT::JSingleFileScanner< T >, JSUPPORT::JSingleFileScanner< JHead_t >, JSUPPORT::JSingleFileScanner< JTail_t >, JSUPPORT::JSingleFileScanner< JTypeList< JHead_t, JTail_t > >, and JSUPPORT::JSingleFileScanner<>.

Definition at line 90 of file JObjectIterator.hh.

91 {
92 skip_type i = 0;
93
94 for ( ; i != ns && hasNext(); ++i) {
95 next();
96 }
97
98 return i;
99 }
virtual bool hasNext()=0
Check availability of next element.
virtual const pointer_type & next()=0
Get next element.

Member Data Documentation

◆ scanner

template<class T >
JMultipleFileScanner<T> JSUPPORT::JMultipleFileSampler_t< T >::scanner
protectedinherited

Definition at line 47 of file JMultipleFileSampler.hh.

◆ in

template<class T , template< class > class JSampler_t = JSampler>
JRewindableObjectIterator<T>& JLANG::JObjectSampler< T, JSampler_t >::in
protectedinherited

Definition at line 154 of file JObjectSampler.hh.

◆ sampler

template<class T , template< class > class JSampler_t = JSampler>
JSampler_t<T> JLANG::JObjectSampler< T, JSampler_t >::sampler
protectedinherited

Definition at line 155 of file JObjectSampler.hh.

◆ ps

template<class T , template< class > class JSampler_t = JSampler>
JPointer<T> JLANG::JObjectSampler< T, JSampler_t >::ps
protectedinherited

Definition at line 156 of file JObjectSampler.hh.

◆ has_next

template<class T , template< class > class JSampler_t = JSampler>
bool JLANG::JObjectSampler< T, JSampler_t >::has_next
protectedinherited

Definition at line 157 of file JObjectSampler.hh.


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