A class that manages a list of Sample objects. More...
#include <SampleHandler.h>
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 | |
SampleHandler & | operator= (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 | |
Sample * | get (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. | |
Sample * | findBySource (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 | |
Sample * | operator[] (std::size_t index) const |
the sample with the given index | |
Sample * | at (std::size_t index) const |
the sample with the given index | |
Friends | |
void | swap (SampleHandler &a, SampleHandler &b) |
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.
SH::SampleHandler::SampleHandler | ( | ) |
standard constructor
SH::SampleHandler::SampleHandler | ( | const SampleHandler & | that | ) |
standard copy constructor
SH::SampleHandler::~SampleHandler | ( | ) |
standard destructor
void SH::SampleHandler::add | ( | const SampleHandler & | sh | ) |
add all samples from the given SampleHandler to this one
void SH::SampleHandler::add | ( | const SamplePtr & | sample | ) |
add a sample to the handler
void SH::SampleHandler::add | ( | std::unique_ptr< Sample > | sample | ) |
add a sample to the handler
void SH::SampleHandler::add | ( | Sample * | sample | ) |
add a sample to the handler
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
Sample* SH::SampleHandler::at | ( | std::size_t | index | ) | const |
iterator SH::SampleHandler::begin | ( | ) | const |
the begin iterator to use
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.
source | the source SampleHandler |
iterator SH::SampleHandler::end | ( | ) | const |
the end iterator to use
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.
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.
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.
SampleHandler SH::SampleHandler::find | ( | const TagList & | tags | ) | const |
find all samples which have at least one of the given tags.
SampleHandler SH::SampleHandler::findByName | ( | const std::string & | pattern | ) | const |
find samples by pattern on the name
pattern | the regular expression that's matched against the name |
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.
Sample* SH::SampleHandler::get | ( | const std::string & | name | ) | const |
get the sample with the given name
void SH::SampleHandler::load | ( | const std::string & | directory | ) |
load all the samples from the given directory
SampleHandler& SH::SampleHandler::operator= | ( | const SampleHandler & | that | ) |
standard assignment operator
Sample* SH::SampleHandler::operator[] | ( | std::size_t | index | ) | const |
void SH::SampleHandler::print | ( | ) | const |
print the debugging output to the screen
void SH::SampleHandler::printContent | ( | ) | const |
print the debugging output to the screen
void SH::SampleHandler::remove | ( | Sample * | sample | ) |
remove the given sample
void SH::SampleHandler::remove | ( | const std::string & | name | ) |
void SH::SampleHandler::save | ( | const std::string & | directory | ) | const |
save the list of samples to the given directory
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.
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 |
void SH::SampleHandler::setMetaDouble | ( | const std::string & | name, | |
double | value | |||
) |
set the meta-data double with the given name for all samples.
name | the name of the meta-data | |
value | the value to which it is 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.
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 |
void SH::SampleHandler::setMetaString | ( | const std::string & | name, | |
const std::string & | value | |||
) |
set the meta-data string with the given name for all samples.
name | the name of the meta-data | |
value | the value to which it is set |
std::size_t SH::SampleHandler::size | ( | ) | const |
the number of samples contained
void SH::SampleHandler::testInvariant | ( | ) | const |
test the invariant of this object
void SH::SampleHandler::updateLocation | ( | const std::string & | from, | |
const std::string & | to | |||
) |
update all file references starting with from to to
from | the original path to the data area | |
to | the new path to the data area |