nidas  v1.2-1520
SampleMatcher.h
Go to the documentation of this file.
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2 // vim: set shiftwidth=4 softtabstop=4 expandtab:
3 /*
4  ********************************************************************
5  Copyright 2016 UCAR, NCAR, All Rights Reserved
6  ********************************************************************
7 */
8 #ifndef NIDAS_CORE_SAMPLEMATCHER_H
9 #define NIDAS_CORE_SAMPLEMATCHER_H
10 
11 #include "SampleTag.h"
12 #include <nidas/util/UTime.h>
13 
14 namespace nidas { namespace core {
15 
21 {
22  struct RangeMatcher
23  {
29  RangeMatcher(int d1, int d2, int s1, int s2, int inc);
30 
31  int dsm1;
32  int dsm2;
33  int sid1;
34  int sid2;
35  bool include;
36  };
37 
38 public:
39 
44  SampleMatcher();
45 
57  bool
58  addCriteria(const std::string& ctext);
59 
67  bool
69 
74  bool
75  match(const Sample* samp);
76 
82  bool
84 
88  int
90  {
91  return _ranges.size();
92  }
93 
97  void
99  {
100  _startTime = start;
101  }
102 
105  {
106  return _startTime;
107  }
108 
112  void
114  {
115  _endTime = end;
116  }
117 
120  {
121  return _endTime;
122  }
123 
124 private:
125  typedef std::map<dsm_sample_id_t, bool> id_lookup_t;
126  typedef std::vector<RangeMatcher> range_matches_t;
127 
132 };
133 
134 
135 }} // namespace nidas namespace core
136 
137 #endif // NIDAS_CORE_SAMPLEMATCHER_H
Definition: SampleMatcher.h:22
nidas::util::UTime getEndTime()
Definition: SampleMatcher.h:119
A class for parsing, formatting and doing operations on time, based on Unix time conventions, where leap seconds are ignored, so that there are always 60 seconds in a minute, 3600 seconds in an hour and 86400 seconds in a day.
Definition: UTime.h:76
unsigned int dsm_sample_id_t
Definition: Sample.h:63
RangeMatcher(int d1, int d2, int s1, int s2, int inc)
Construct a RangeMatcher with the given range endpoints: d1 &lt;= DSM ID &lt;= d2, s1 &lt;= Sample ID &lt;= s2...
Definition: SampleMatcher.cc:50
bool exclusiveMatch()
Return true if this matcher can only match a single ID pair (DSM,SID), meaning only one range has bee...
Definition: SampleMatcher.cc:159
bool match(dsm_sample_id_t id)
Return true if the given id satisfies the current range criteria.
Definition: SampleMatcher.cc:106
int sid1
Definition: SampleMatcher.h:33
nidas::util::UTime _endTime
Definition: SampleMatcher.h:131
range_matches_t _ranges
Definition: SampleMatcher.h:128
int numRanges()
The number of ranges added to this SampleMatcher.
Definition: SampleMatcher.h:89
std::map< dsm_sample_id_t, bool > id_lookup_t
Definition: SampleMatcher.h:125
int dsm2
Definition: SampleMatcher.h:32
id_lookup_t _lookup
Definition: SampleMatcher.h:129
std::vector< RangeMatcher > range_matches_t
Definition: SampleMatcher.h:126
bool addCriteria(const std::string &ctext)
Add a sample range using this syntax:
Definition: SampleMatcher.cc:67
nidas::util::UTime _startTime
Definition: SampleMatcher.h:130
bool include
Definition: SampleMatcher.h:35
int dsm1
Definition: SampleMatcher.h:31
nidas::util::UTime getStartTime()
Definition: SampleMatcher.h:104
void setEndTime(nidas::util::UTime end)
Set the time after which samples will not match.
Definition: SampleMatcher.h:113
int sid2
Definition: SampleMatcher.h:34
Interface to a data sample.
Definition: Sample.h:189
Match samples according to DSM and Sample ID ranges, and configure the ranges with criteria in text f...
Definition: SampleMatcher.h:20
void setStartTime(nidas::util::UTime start)
Set the time before which samples will not match.
Definition: SampleMatcher.h:98
SampleMatcher()
Construct an empty SampleMatcher with no ranges.
Definition: SampleMatcher.cc:56