Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
JSUPPORT::JTreeSampler< T, JSampler_t > Struct Template Reference

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

#include <JTreeSampler.hh>

Inheritance diagram for JSUPPORT::JTreeSampler< T, JSampler_t >:
JLANG::JTemplate< JType_t > JLANG::JObjectSampler< T, JSampler_t > JLANG::JObjectIterator< T >

Public Types

typedef JSampler_t< Tsampler_type
 
typedef JTemplate< JType_t > template_type
 
typedef JObjectIterator< T >
::pointer_type 
pointer_type
 

Public Member Functions

 JTreeSampler (const sampler_type &sampler=sampler_type())
 Constructor. More...
 
 operator const JType_t & () const
 Type conversion. More...
 
 operator JType_t & ()
 Type conversion. More...
 
const JType_t * operator-> () const
 Smart pointer operator. More...
 
JType_t * operator-> ()
 Smart pointer operator. More...
 
template<class T , bool use_polymorphism = false>
const Tget () const
 Get reference to object. More...
 
template<class T , bool use_polymorphism = false>
Tget ()
 Get reference to object. More...
 
template_typeset (const JType_t &value)
 Set value. More...
 
template<bool use_polymorphism, class T >
template_typeset (const T &value)
 Set value. More...
 
virtual bool hasNext () override
 Check availability of next element. More...
 
virtual const pointer_typenext () override
 Get next element. More...
 
const JSampler_t< T > & getSampler () const
 Get sampler. More...
 
JSampler_t< T > & getSampler ()
 Get sampler. More...
 
virtual skip_type skip (const skip_type ns)
 Skip items. More...
 

Protected Member Functions

const JType_t & c_get (JBool< true > option) const
 Get reference to object. More...
 
JType_t & c_get (JBool< true > option)
 Get reference to object. More...
 
template<class T >
template_typec_set (const T &value, JBool< true > option)
 Set value. More...
 

Protected Attributes

JType_t object
 object More...
 
JRewindableObjectIterator< T > & in
 
JSampler_t< Tsampler
 
JPointer< Tps
 
bool has_next
 

Detailed Description

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

Auxiliary class to sample from a list of files.

Definition at line 28 of file JTreeSampler.hh.

Member Typedef Documentation

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

Definition at line 33 of file JTreeSampler.hh.

template<class JType_t>
typedef JTemplate<JType_t> JLANG::JTemplate< JType_t >::template_type
inherited

Definition at line 42 of file JTemplate.hh.

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

Definition at line 45 of file JObjectSampler.hh.

Constructor & Destructor Documentation

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

Constructor.

Parameters
samplersampler

Definition at line 41 of file JTreeSampler.hh.

41  :
44  {}
Interface for object iteration with rewinding.
Auxiliary class for managing multiple objects.
Definition: JTemplate.hh:40
Auxiliary class to sample objects from a JRewindableObjectIterator.
JSampler_t< T > sampler

Member Function Documentation

template<class JType_t>
JLANG::JTemplate< JType_t >::operator const JType_t & ( ) const
inlineinherited

Type conversion.

Returns
reference to object

Definition at line 68 of file JTemplate.hh.

69  {
70  return object;
71  }
JType_t object
object
Definition: JTemplate.hh:222
template<class JType_t>
JLANG::JTemplate< JType_t >::operator JType_t & ( )
inlineinherited

Type conversion.

Returns
reference to object

Definition at line 79 of file JTemplate.hh.

80  {
81  return object;
82  }
JType_t object
object
Definition: JTemplate.hh:222
template<class JType_t>
const JType_t* JLANG::JTemplate< JType_t >::operator-> ( ) const
inlineinherited

Smart pointer operator.

Returns
pointer to object

Definition at line 90 of file JTemplate.hh.

91  {
92  return &object;
93  }
JType_t object
object
Definition: JTemplate.hh:222
template<class JType_t>
JType_t* JLANG::JTemplate< JType_t >::operator-> ( )
inlineinherited

Smart pointer operator.

Returns
pointer to object

Definition at line 101 of file JTemplate.hh.

102  {
103  return &object;
104  }
JType_t object
object
Definition: JTemplate.hh:222
template<class JType_t>
template<class T , bool use_polymorphism = false>
const T& JLANG::JTemplate< JType_t >::get ( ) const
inlineinherited

Get reference to object.

Returns
reference to object

Definition at line 113 of file JTemplate.hh.

114  {
116  }
const JType_t & c_get(JBool< true > option) const
Get reference to object.
Definition: JTemplate.hh:188
Auxiliary template class for type bool.
Definition: JBool.hh:20
Template class test for polymorphism.
Definition: JConversion.hh:22
template<class JType_t>
template<class T , bool use_polymorphism = false>
T& JLANG::JTemplate< JType_t >::get ( )
inlineinherited

Get reference to object.

Returns
reference to object

Definition at line 125 of file JTemplate.hh.

126  {
128  }
const JType_t & c_get(JBool< true > option) const
Get reference to object.
Definition: JTemplate.hh:188
Auxiliary template class for type bool.
Definition: JBool.hh:20
Template class test for polymorphism.
Definition: JConversion.hh:22
template<class JType_t>
template_type& JLANG::JTemplate< JType_t >::set ( const JType_t &  value)
inlineinherited

Set value.

Parameters
valuevalue
Returns
this object

Definition at line 137 of file JTemplate.hh.

138  {
139  return c_set(value, JBool<true>());
140  }
template_type & c_set(const T &value, JBool< true > option)
Set value.
Definition: JTemplate.hh:214
Auxiliary template class for type bool.
Definition: JBool.hh:20
template<class JType_t>
template<bool use_polymorphism, class T >
template_type& JLANG::JTemplate< JType_t >::set ( const T value)
inlineinherited

Set value.

Parameters
valuevalue
Returns
this object

Definition at line 150 of file JTemplate.hh.

151  {
153  }
template_type & c_set(const T &value, JBool< true > option)
Set value.
Definition: JTemplate.hh:214
Auxiliary template class for type bool.
Definition: JBool.hh:20
Template class test for polymorphism.
Definition: JConversion.hh:22
Template class test for availability of a suitable constructor JType_t(const JArgument_t).
Definition: JConstructor.hh:19
template<class JType_t>
const JType_t& JLANG::JTemplate< JType_t >::c_get ( JBool< true >  option) const
inlineprotectedinherited

Get reference to object.

Parameters
optiontrue
Returns
reference to object

Definition at line 188 of file JTemplate.hh.

189  {
190  return object;
191  }
JType_t object
object
Definition: JTemplate.hh:222
template<class JType_t>
JType_t& JLANG::JTemplate< JType_t >::c_get ( JBool< true >  option)
inlineprotectedinherited

Get reference to object.

Parameters
optiontrue
Returns
reference to object

Definition at line 200 of file JTemplate.hh.

201  {
202  return object;
203  }
JType_t object
object
Definition: JTemplate.hh:222
template<class JType_t>
template<class T >
template_type& JLANG::JTemplate< JType_t >::c_set ( const T value,
JBool< true >  option 
)
inlineprotectedinherited

Set value.

Parameters
valuevalue
optiontrue
Returns
this object

Definition at line 214 of file JTemplate.hh.

215  {
216  object = value;
217 
218  return *this;
219  }
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  }
unsigned int skip_type
Type definition for number of objects to skip.
std::vector< size_t > ns
JRewindableObjectIterator< T > & in
virtual void set(JClass_t *p) override
Set pointer.
Definition: JPointer.hh:75
JSampler_t< T > sampler
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
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  }
JSampler_t< T > sampler
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  }
JSampler_t< T > sampler
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::JPipe< T >, JLANG::JPipe< JTail_t >, JLANG::JPipe< JHead_t >, JLANG::JSTDObjectIterator< T >, JLANG::JAbstractObjectReader< T >, JLANG::JAbstractObjectReader< const event_type >, JLANG::JAbstractObjectReader< JNullType >, JLANG::JAbstractObjectReader< const T >, JLANG::JAbstractObjectReader< JTail_t >, JLANG::JAbstractObjectReader< JHead_t >, JLANG::JAbstractObjectReader< KM3NETDAQ::KM3NETDAQ::JDAQEvent >, and JLANG::JAbstractObjectReader< JDAQSummaryslice >.

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  }
unsigned int skip_type
Type definition for number of objects to skip.
std::vector< size_t > ns
virtual const pointer_type & next()=0
Get next element.
virtual bool hasNext()=0
Check availability of next element.

Member Data Documentation

template<class JType_t>
JType_t JLANG::JTemplate< JType_t >::object
protectedinherited

object

Definition at line 222 of file JTemplate.hh.

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.

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.

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.

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: