ATLAS Offline Software
Public Types | Public Member Functions | Private Types | Private Attributes | Friends | Related Functions | List of all members
SH::SampleHandler Class Reference

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

#include <SampleHandler.h>

Inheritance diagram for SH::SampleHandler:
Collaboration diagram for SH::SampleHandler:

Public Types

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

Public Member Functions

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

Private Types

typedef std::vector< SH::Sample * >::const_iterator SamplesIter
 the iterator for m_samples More...
 
typedef std::vector< SH::Sample * >::iterator SamplesMIter
 the mutable iterator for m_samples More...
 
typedef std::map< std::string, SH::SamplePtr >::iterator NamedIter
 the iterator for m_named More...
 
typedef std::map< std::string, SH::SamplePtr >::iterator NamedMIter
 the mutable iterator for m_named More...
 

Private Attributes

std::vector< SH::Sample * > m_samples
 the list of samples managed More...
 
std::map< std::string, SH::SamplePtrm_named
 the list of samples by name More...
 

Friends

void swap (SampleHandler &a, SampleHandler &b)
 

Related Functions

(Note that these are not member functions.)

std::string dbg (const SampleHandler &obj, unsigned verbosity=0)
 the debugging info of this object More...
 
void swap (SampleHandler &a, SampleHandler &b)
 standard swap More...
 

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.

Definition at line 59 of file SampleHandler.h.

Member Typedef Documentation

◆ iterator

typedef std::vector<Sample*>::const_iterator SH::SampleHandler::iterator

the iterator to use

Definition at line 475 of file SampleHandler.h.

◆ NamedIter

typedef std::map<std::string,SH::SamplePtr>::iterator SH::SampleHandler::NamedIter
private

the iterator for m_named

Definition at line 545 of file SampleHandler.h.

◆ NamedMIter

typedef std::map<std::string,SH::SamplePtr>::iterator SH::SampleHandler::NamedMIter
private

the mutable iterator for m_named

Definition at line 549 of file SampleHandler.h.

◆ SamplesIter

typedef std::vector<SH::Sample*>::const_iterator SH::SampleHandler::SamplesIter
private

the iterator for m_samples

Definition at line 533 of file SampleHandler.h.

◆ SamplesMIter

typedef std::vector<SH::Sample*>::iterator SH::SampleHandler::SamplesMIter
private

the mutable iterator for m_samples

Definition at line 537 of file SampleHandler.h.

Constructor & Destructor Documentation

◆ SampleHandler() [1/2]

SH::SampleHandler::SampleHandler ( )

standard constructor

Guarantee
strong
Failures
out of memory I

◆ SampleHandler() [2/2]

SH::SampleHandler::SampleHandler ( const SampleHandler that)

standard copy constructor

Guarantee
strong
Failures
out of memory II

◆ ~SampleHandler()

SH::SampleHandler::~SampleHandler ( )

standard destructor

Guarantee
no-fail

Member Function Documentation

◆ add() [1/5]

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

◆ add() [2/5]

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

◆ add() [3/5]

void SH::SampleHandler::add ( 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()

◆ add() [4/5]

void SH::SampleHandler::add ( 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()

◆ add() [5/5]

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()

◆ addWithPrefix()

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

◆ at()

Sample* SH::SampleHandler::at ( std::size_t  index) const

the sample with the given index

Precondition
index < size()
Guarantee
no-fail

◆ begin()

iterator SH::SampleHandler::begin ( ) const

the begin iterator to use

Guarantee
no-fail

◆ check_complete()

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
sourcethe source SampleHandler
Returns
whether all samples in the source sample handler are contained in this sample.
Guarantee
strong
Failures
out of memory II

◆ end()

iterator SH::SampleHandler::end ( ) const

the end iterator to use

Guarantee
no-fail

◆ fetch()

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

◆ fetchDefaults()

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

◆ find() [1/2]

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

◆ find() [2/2]

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

◆ findByName()

SampleHandler SH::SampleHandler::findByName ( const std::string &  pattern) const

find samples by pattern on the name

Parameters
patternthe regular expression that's matched against the name
Returns
a sample handler with the new samples
Guarantee
strong
Failures
out of memory II

◆ findBySource()

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

◆ get() [1/2]

Sample* SH::SampleHandler::get ( const std::string &  name)

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

◆ get() [2/2]

const 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

◆ load()

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

◆ operator=()

SampleHandler& SH::SampleHandler::operator= ( const SampleHandler that)

standard assignment operator

Guarantee
strong
Failures
out of memory II

◆ operator[]()

Sample* SH::SampleHandler::operator[] ( std::size_t  index) const

the sample with the given index

Precondition
index < size()
Guarantee
no-fail

◆ print()

void SH::SampleHandler::print ( ) const

print the debugging output to the screen

Guarantee
basic, may print partially
Failures
out of memory II
stream errors

◆ printContent()

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

◆ remove() [1/2]

void SH::SampleHandler::remove ( const Sample sample)

remove the given sample

Guarantee
strong
Failures
out of memory II
sample not in SampleHandler
Precondition
sample != 0

◆ remove() [2/2]

void SH::SampleHandler::remove ( const std::string &  name)

remove the given sample

Guarantee
strong
Failures
out of memory II
sample not in SampleHandler

◆ save()

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

◆ setMetaDouble() [1/2]

void SH::SampleHandler::setMetaDouble ( const std::string &  name,
double  value 
)

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

Parameters
namethe name of the meta-data
valuethe 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.

◆ setMetaDouble() [2/2]

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
patternthe regular expression against which the sample name is matched
namethe name of the meta-data
valuethe 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.

◆ setMetaString() [1/2]

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
namethe name of the meta-data
valuethe 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.

◆ setMetaString() [2/2]

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
patternthe regular expression against which the sample name is matched
namethe name of the meta-data
valuethe 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.

◆ size()

std::size_t SH::SampleHandler::size ( ) const

the number of samples contained

Guarantee
no-fail

◆ testInvariant()

void SH::SampleHandler::testInvariant ( ) const

test the invariant of this object

Guarantee
no-fail

◆ updateLocation()

void SH::SampleHandler::updateLocation ( const std::string &  from,
const std::string &  to 
)

update all file references starting with from to to

Parameters
fromthe original path to the data area
tothe 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

Friends And Related Function Documentation

◆ dbg()

std::string dbg ( const SampleHandler obj,
unsigned  verbosity = 0 
)
related

the debugging info of this object

Returns
a string representation of the object content
Parameters
objthe object to be presented
verbositythe level of verbosity (higher number -> more information)
Guarantee
strong
Failures
out of memory II

◆ swap() [1/2]

void swap ( SampleHandler a,
SampleHandler b 
)
related

standard swap

Guarantee
no-fail

◆ swap [2/2]

void swap ( SampleHandler a,
SampleHandler b 
)
friend

Member Data Documentation

◆ m_named

std::map<std::string,SH::SamplePtr> SH::SampleHandler::m_named
private

the list of samples by name

Definition at line 541 of file SampleHandler.h.

◆ m_samples

std::vector<SH::Sample*> SH::SampleHandler::m_samples
private

the list of samples managed

Definition at line 529 of file SampleHandler.h.


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