SH::SampleHandler Class Reference

A class that manages a list of Sample objects. More...

#include <SampleHandler.h>

List of all members.

Public Types

typedef std::vector< Sample * >
::const_iterator 
iterator
 the iterator to use

Public Member Functions

void testInvariant () const
 test the invariant of this object
 SampleHandler ()
 standard constructor
 SampleHandler (const SampleHandler &that)
 standard copy constructor
 ~SampleHandler ()
 standard destructor
SampleHandleroperator= (const SampleHandler &that)
 standard assignment operator
void add (Sample *sample)
 add a sample to the handler
void add (std::unique_ptr< Sample > sample)
 add a sample to the handler
void add (const SamplePtr &sample)
 add a sample to the handler
void add (const SampleHandler &sh)
 add all samples from the given SampleHandler to this one
void addWithPrefix (const SampleHandler &sh, const std::string &prefix)
 add all samples from the given SampleHandler to this one, with prefix prepended to their name
void remove (const std::string &name)
 remove the given sample
void remove (Sample *sample)
 remove the given sample
Sampleget (const std::string &name) const
 get the sample with the given name
SampleHandler find (const TagList &tags) const
 find all samples which have at least one of the given tags.
SampleHandler find (const std::string &tags) const
 find all samples which have at least one of the given tags.
SamplefindBySource (const std::string &name) const
 find a sample by the name in the source sample handler
SampleHandler findByName (const std::string &pattern) const
 find samples by pattern on the name
void print () const
 print the debugging output to the screen
void printContent () const
 print the debugging output to the screen
void save (const std::string &directory) const
 save the list of samples to the given directory
void load (const std::string &directory)
 load all the samples from the given directory
void updateLocation (const std::string &from, const std::string &to)
 update all file references starting with from to to
void fetch (const SampleHandler &source)
 fetch the meta-data for all samples that are also in the source sample handler.
void fetchDefaults (const SampleHandler &source)
 fetch the meta-data for all that samples that don't have it in this sample.
bool check_complete (const SampleHandler &source) const
 whether we have all samples from the source SampleHandler.
void setMetaDouble (const std::string &name, double value)
 set the meta-data double with the given name for all samples.
void setMetaString (const std::string &name, const std::string &value)
 set the meta-data string with the given name for all samples.
void setMetaDouble (const std::string &pattern, const std::string &name, double value)
 set the meta-data double with the given name for samples matching a pattern.
void setMetaString (const std::string &pattern, const std::string &name, const std::string &value)
 set the meta-data double with the given name for samples matching a pattern.
iterator begin () const
 the begin iterator to use
iterator end () const
 the end iterator to use
std::size_t size () const
 the number of samples contained
Sampleoperator[] (std::size_t index) const
 the sample with the given index
Sampleat (std::size_t index) const
 the sample with the given index

Friends

void swap (SampleHandler &a, SampleHandler &b)

Detailed Description

A class that manages a list of Sample objects.

This class is typically used either to hold a list of all samples known to the analyzer or to hold a list of samples produced by a search operation on another SampleHandler. It is also extensively used to manage the inputs and outputs of EventLoop.


Constructor & Destructor Documentation

SH::SampleHandler::SampleHandler (  ) 

standard constructor

Guarantee
strong
Failures
out of memory I
SH::SampleHandler::SampleHandler ( const SampleHandler that  ) 

standard copy constructor

Guarantee
strong
Failures
out of memory II
SH::SampleHandler::~SampleHandler (  ) 

standard destructor

Guarantee
no-fail

Member Function Documentation

void SH::SampleHandler::add ( const SampleHandler sh  ) 

add all samples from the given SampleHandler to this one

Guarantee
basic, some samples may be added
Failures
out of memory II
sample of same name already in use
Precondition:
this != &sh
void SH::SampleHandler::add ( const SamplePtr sample  ) 

add a sample to the handler

Guarantee
basic, sample is released if this is the last copy
Failures
out of memory I
sample of same name already in use
Precondition:
!sample.empty()
!sample->name().empty()
void SH::SampleHandler::add ( std::unique_ptr< Sample sample  ) 

add a sample to the handler

Guarantee
basic, sample is released
Failures
out of memory I
sample of same name already in use
Precondition:
!sample.empty()
!sample->name().empty()
void SH::SampleHandler::add ( Sample sample  ) 

add a sample to the handler

Guarantee
basic, sample is released if this is the last copy
Failures
out of memory I
sample of same name already in use
Precondition:
sample != 0
void SH::SampleHandler::addWithPrefix ( const SampleHandler sh,
const std::string &  prefix 
)

add all samples from the given SampleHandler to this one, with prefix prepended to their name

Guarantee
basic, some samples may be added
Failures
out of memory II
sample of same name already in use
Precondition:
this != &sh
Sample* SH::SampleHandler::at ( std::size_t  index  )  const

the sample with the given index

Precondition:
index < size()
Guarantee
no-fail
iterator SH::SampleHandler::begin (  )  const

the begin iterator to use

Guarantee
no-fail
bool SH::SampleHandler::check_complete ( const SampleHandler source  )  const

whether we have all samples from the source SampleHandler.

samples are identified by name in the source. the name is either taken from the meta-data field "nc_source" or (if not available) by the name of the sample.

Parameters:
source the source SampleHandler
Returns:
whether all samples in the source sample handler are contained in this sample.
Guarantee
strong
Failures
out of memory II
iterator SH::SampleHandler::end (  )  const

the end iterator to use

Guarantee
no-fail
void SH::SampleHandler::fetch ( const SampleHandler source  ) 

fetch the meta-data for all samples that are also in the source sample handler.

samples are identified by name in the source. the name is either taken from the meta-data field "nc_source" or (if not available) by the name of the sample. fields that have a name that starts with "nc_" are not copied.

Guarantee
basic, may only fetch some meta-data
Failures
out of memory II
void SH::SampleHandler::fetchDefaults ( const SampleHandler source  ) 

fetch the meta-data for all that samples that don't have it in this sample.

this ignores any meta-data without name and any samples not present in source.

Guarantee
basic, may only fetch some meta-data
Failures
out of memory II
SampleHandler SH::SampleHandler::find ( const std::string &  tags  )  const

find all samples which have at least one of the given tags.

this version uses a comma separated tag list instead of a TagList object.

Returns:
a SampleHandler with all found samples
Guarantee
strong
Failures
out of memory II
SampleHandler SH::SampleHandler::find ( const TagList tags  )  const

find all samples which have at least one of the given tags.

Returns:
a SampleHandler with all found samples
Guarantee
strong
Failures
out of memory II
SampleHandler SH::SampleHandler::findByName ( const std::string &  pattern  )  const

find samples by pattern on the name

Parameters:
pattern the regular expression that's matched against the name
Returns:
a sample handler with the new samples
Guarantee
strong
Failures
out of memory II
Sample* SH::SampleHandler::findBySource ( const std::string &  name  )  const

find a sample by the name in the source sample handler

this means it needs to match the content of the meta-data field "nc_source" or if that is not present by its own name.

Returns:
the sample or NULL if no sample was found
Guarantee
strong
Failures
out of memory II
more than one sample found
Sample* SH::SampleHandler::get ( const std::string &  name  )  const

get the sample with the given name

Returns:
the sample with the given name, or NULL if the sample can not be found
Guarantee
strong
Failures
out of memory II
void SH::SampleHandler::load ( const std::string &  directory  ) 

load all the samples from the given directory

Guarantee
basic, may load partially
Failures
out of memory III
duplicate sample
Rationale
Due to some ancient design decision we store a SampleHandler as a directory with one root file per Sample, instead of storing them all in a single root file
SampleHandler& SH::SampleHandler::operator= ( const SampleHandler that  ) 

standard assignment operator

Guarantee
strong
Failures
out of memory II
Sample* SH::SampleHandler::operator[] ( std::size_t  index  )  const

the sample with the given index

Precondition:
index < size()
Guarantee
no-fail
void SH::SampleHandler::print (  )  const

print the debugging output to the screen

Guarantee
basic, may print partially
Failures
out of memory II
stream errors
void SH::SampleHandler::printContent (  )  const

print the debugging output to the screen

Guarantee
basic, may print partially
Failures
out of memory II
stream errors
Rationale
added a second print method for python
void SH::SampleHandler::remove ( Sample sample  ) 

remove the given sample

Guarantee
strong
Failures
out of memory II
sample not in SampleHandler
Precondition:
sample != 0
void SH::SampleHandler::remove ( const std::string &  name  ) 

remove the given sample

Guarantee
strong
Failures
out of memory II
sample not in SampleHandler
void SH::SampleHandler::save ( const std::string &  directory  )  const

save the list of samples to the given directory

Guarantee
basic, may save partially
Failures
out of memory II
stream errors
Rationale
Due to some ancient design decision we store a SampleHandler as a directory with one root file per Sample, instead of storing them all in a single root file
void SH::SampleHandler::setMetaDouble ( const std::string &  pattern,
const std::string &  name,
double  value 
)

set the meta-data double with the given name for samples matching a pattern.

Parameters:
pattern the regular expression against which the sample name is matched
name the name of the meta-data
value the value to which it is set
Guarantee
basic, may clear old entry without adding new one or may not do it for all samples
Failures
out of memory II
Warning:
: this is a one-time effect, if you add more samples they will not get their meta-data set.
void SH::SampleHandler::setMetaDouble ( const std::string &  name,
double  value 
)

set the meta-data double with the given name for all samples.

Parameters:
name the name of the meta-data
value the value to which it is set
Guarantee
basic, may clear old entry without adding new one or may not do it for all samples
Failures
out of memory II
Warning:
: this is a one-time effect, if you add more samples they will not get their meta-data set.
void SH::SampleHandler::setMetaString ( const std::string &  pattern,
const std::string &  name,
const std::string &  value 
)

set the meta-data double with the given name for samples matching a pattern.

Parameters:
pattern the regular expression against which the sample name is matched
name the name of the meta-data
value the value to which it is set
Guarantee
basic, may clear old entry without adding new one or may not do it for all samples
Failures
out of memory II
Warning:
: this is a one-time effect, if you add more samples they will not get their meta-data set.
void SH::SampleHandler::setMetaString ( const std::string &  name,
const std::string &  value 
)

set the meta-data string with the given name for all samples.

Parameters:
name the name of the meta-data
value the value to which it is set
Guarantee
basic, may clear old entry without adding new one or may not do it for all samples
Failures
out of memory II
Warning:
: this is a one-time effect, if you add more samples they will not get their meta-data set.
std::size_t SH::SampleHandler::size (  )  const

the number of samples contained

Guarantee
no-fail
void SH::SampleHandler::testInvariant (  )  const

test the invariant of this object

Guarantee
no-fail
void SH::SampleHandler::updateLocation ( const std::string &  from,
const std::string &  to 
)

update all file references starting with from to to

Parameters:
from the original path to the data area
to the new path to the data area
Guarantee
basic, may update partially
Failures
out of memory II
Precondition:
!from.empty()
Postcondition:
!to.empty()
Rationale
this is needed when moving data around without recreating the samples from scratch

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 1 Dec 2017 for RootCore Packages by  doxygen 1.6.1