nidas v1.2.3
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
14namespace nidas { namespace core {
15
21{
23 {
24 static const int MATCH_FIRST = -9;
25 static const int MATCH_ALL = -1;
26
27 void
28 parse_range(const std::string& rngstr, int& rngid1, int& rngid2);
29
30 bool
31 parse_specifier(const std::string& specifier);
32
36 bool
37 match(int dsmid, int sid);
38
42 void
43 set_first_dsm(int dsmid);
44
45 int dsm1{0};
46 int dsm2{0};
47 int sid1{0};
48 int sid2{0};
49 bool include{false};
50 };
51
52public:
53
59
71 bool
72 addCriteria(const std::string& ctext);
73
81 bool
83
88 bool
89 match(const Sample* samp);
90
96 bool
98
102 int
104 {
105 return _ranges.size();
106 }
107
111 void
113 {
114 _startTime = start;
115 }
116
119 {
120 return _startTime;
121 }
122
126 void
128 {
129 _endTime = end;
130 }
131
134 {
135 return _endTime;
136 }
137
138private:
139 typedef std::map<dsm_sample_id_t, bool> id_lookup_t;
140 typedef std::vector<RangeMatcher> range_matches_t;
141
147};
148
149
150}} // namespace nidas namespace core
151
152#endif // NIDAS_CORE_SAMPLEMATCHER_H
Match samples according to DSM and Sample ID ranges, and configure the ranges with criteria in text f...
Definition SampleMatcher.h:21
nidas::util::UTime _startTime
Definition SampleMatcher.h:144
void setEndTime(nidas::util::UTime end)
Set the time after which samples will not match.
Definition SampleMatcher.h:127
SampleMatcher()
Construct an empty SampleMatcher with no ranges.
Definition SampleMatcher.cc:128
id_lookup_t _lookup
Definition SampleMatcher.h:143
int numRanges()
The number of ranges added to this SampleMatcher.
Definition SampleMatcher.h:103
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:232
nidas::util::UTime getEndTime()
Definition SampleMatcher.h:133
range_matches_t _ranges
Definition SampleMatcher.h:142
nidas::util::UTime getStartTime()
Definition SampleMatcher.h:118
void setStartTime(nidas::util::UTime start)
Set the time before which samples will not match.
Definition SampleMatcher.h:112
bool addCriteria(const std::string &ctext)
Add a sample range using this syntax:
Definition SampleMatcher.cc:140
dsm_sample_id_t _first_dsmid
Definition SampleMatcher.h:146
bool match(dsm_sample_id_t id)
Return true if the given id satisfies the current range criteria.
Definition SampleMatcher.cc:164
std::vector< RangeMatcher > range_matches_t
Definition SampleMatcher.h:140
std::map< dsm_sample_id_t, bool > id_lookup_t
Definition SampleMatcher.h:139
nidas::util::UTime _endTime
Definition SampleMatcher.h:145
Interface to a data sample.
Definition Sample.h:190
A class for parsing, formatting and doing operations on time, based on Unix time conventions,...
Definition UTime.h:95
unsigned int dsm_sample_id_t
Definition Sample.h:64
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
Definition SampleMatcher.h:23
bool include
Definition SampleMatcher.h:49
int dsm1
Definition SampleMatcher.h:45
static const int MATCH_ALL
Definition SampleMatcher.h:25
int dsm2
Definition SampleMatcher.h:46
bool match(int dsmid, int sid)
Return true when dsmid and sid are matched by this range.
Definition SampleMatcher.cc:101
void set_first_dsm(int dsmid)
Fill in any MATCH_FIRST references with the given dsmid.
Definition SampleMatcher.cc:120
void parse_range(const std::string &rngstr, int &rngid1, int &rngid2)
Definition SampleMatcher.cc:30
static const int MATCH_FIRST
Definition SampleMatcher.h:24
int sid1
Definition SampleMatcher.h:47
bool parse_specifier(const std::string &specifier)
Definition SampleMatcher.cc:59
int sid2
Definition SampleMatcher.h:48