nidas  v1.2-1520
Classes | Public Member Functions | Private Types | Private Attributes | List of all members
nidas::core::SampleMatcher Class Reference

Match samples according to DSM and Sample ID ranges, and configure the ranges with criteria in text format. More...

#include <SampleMatcher.h>

Classes

struct  RangeMatcher
 

Public Member Functions

 SampleMatcher ()
 Construct an empty SampleMatcher with no ranges. More...
 
bool addCriteria (const std::string &ctext)
 Add a sample range using this syntax: More...
 
bool match (dsm_sample_id_t id)
 Return true if the given id satisfies the current range criteria. More...
 
bool match (const Sample *samp)
 Return true if this sample matches all the criteria in this matcher, both sample ids and time range. More...
 
bool exclusiveMatch ()
 Return true if this matcher can only match a single ID pair (DSM,SID), meaning only one range has been added and it specifies two specific positive IDs. More...
 
int numRanges ()
 The number of ranges added to this SampleMatcher. More...
 
void setStartTime (nidas::util::UTime start)
 Set the time before which samples will not match. More...
 
nidas::util::UTime getStartTime ()
 
void setEndTime (nidas::util::UTime end)
 Set the time after which samples will not match. More...
 
nidas::util::UTime getEndTime ()
 

Private Types

typedef std::map
< dsm_sample_id_t, bool > 
id_lookup_t
 
typedef std::vector< RangeMatcherrange_matches_t
 

Private Attributes

range_matches_t _ranges
 
id_lookup_t _lookup
 
nidas::util::UTime _startTime
 
nidas::util::UTime _endTime
 

Detailed Description

Match samples according to DSM and Sample ID ranges, and configure the ranges with criteria in text format.

Member Typedef Documentation

Constructor & Destructor Documentation

SampleMatcher::SampleMatcher ( )

Construct an empty SampleMatcher with no ranges.

An empty SampleMatcher implicitly matches all samples.

Member Function Documentation

bool SampleMatcher::addCriteria ( const std::string &  ctext)

Add a sample range using this syntax:

*   [^]{<d1>[-<d2>|*},{<s1>[-<s2>]|*}
* 

The leading '^' will exclude any sample IDs in the given range instead of including them. The '*' matches any ID. The older convention where -1 matches all IDs is still supported.

An empty criteria string is allowed and valid but changes nothing.

References _lookup, _ranges, and err.

Referenced by nidas::core::NidasApp::parseNext(), and nidas::core::SampleTracer::SampleTracer().

bool SampleMatcher::exclusiveMatch ( )

Return true if this matcher can only match a single ID pair (DSM,SID), meaning only one range has been added and it specifies two specific positive IDs.

References _ranges.

Referenced by DumpClient::printHeader(), and DumpClient::setSensors().

nidas::util::UTime nidas::core::SampleMatcher::getEndTime ( )
inline

References _endTime.

nidas::util::UTime nidas::core::SampleMatcher::getStartTime ( )
inline

References _startTime.

bool SampleMatcher::match ( dsm_sample_id_t  id)

Return true if the given id satisfies the current range criteria.

Search the ranges for one which includes this id, then return true if the range is an inclusion and otherwise false. The outcome is cached for future lookups, but the cache is cleared if the criteria change.

References _lookup, _ranges, GET_DSM_ID, GET_SHORT_ID, and if().

Referenced by nidas::core::SampleTracer::active(), DataStats::createCounters(), match(), SampleDispatcher::SampleDispatcher(), and DumpClient::setSensors().

bool SampleMatcher::match ( const Sample samp)

Return true if this sample matches all the criteria in this matcher, both sample ids and time range.

References _endTime, _startTime, nidas::core::Sample::getId(), nidas::core::Sample::getTimeTag(), match(), and nidas::util::UTime::toUsecs().

int nidas::core::SampleMatcher::numRanges ( )
inline

The number of ranges added to this SampleMatcher.

References _ranges.

Referenced by DataDump::parseRunstring().

void nidas::core::SampleMatcher::setEndTime ( nidas::util::UTime  end)
inline

Set the time after which samples will not match.

References _endTime.

Referenced by nidas::core::NidasApp::parseNext().

void nidas::core::SampleMatcher::setStartTime ( nidas::util::UTime  start)
inline

Set the time before which samples will not match.

References _startTime.

Referenced by nidas::core::NidasApp::parseNext().

Member Data Documentation

nidas::util::UTime nidas::core::SampleMatcher::_endTime
private

Referenced by getEndTime(), match(), and setEndTime().

id_lookup_t nidas::core::SampleMatcher::_lookup
private

Referenced by addCriteria(), and match().

range_matches_t nidas::core::SampleMatcher::_ranges
private
nidas::util::UTime nidas::core::SampleMatcher::_startTime
private

Referenced by getStartTime(), match(), and setStartTime().


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