nidas v1.2.3
SortedSampleSet.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 ** NIDAS: NCAR In-situ Data Acquistion Software
6 **
7 ** 2005, Copyright University Corporation for Atmospheric Research
8 **
9 ** This program is free software; you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License as published by
11 ** the Free Software Foundation; either version 2 of the License, or
12 ** (at your option) any later version.
13 **
14 ** This program is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ** GNU General Public License for more details.
18 **
19 ** The LICENSE.txt file accompanying this software contains
20 ** a copy of the GNU General Public License. If it is not found,
21 ** write to the Free Software Foundation, Inc.,
22 ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 **
24 ********************************************************************
25*/
26#ifndef NIDAS_CORE_SORTEDSAMPLESET_H
27#define NIDAS_CORE_SORTEDSAMPLESET_H
28
29#include "Sample.h"
30
31#include <set>
32
33namespace nidas { namespace core {
34
39public:
43 bool operator() (const Sample* x, const Sample *y) const {
44 return x->getTimeTag() < y->getTimeTag();
45 }
46};
47
60public:
64 bool operator() (const Sample* x, const Sample *y) const {
65 if (x->getTimeTag() > y->getTimeTag()) return false;
66 if (x->getTimeTag() == y->getTimeTag()) {
67 if (x->getId() > y->getId()) return false;
68 if (x->getId() == y->getId())
69 return x->getDataLength() < y->getDataLength();
70 }
71 return true;
72 }
73};
74
81public:
85 bool operator() (const Sample* x, const Sample *y) const {
86 if (x->getTimeTag() > y->getTimeTag()) return false;
87 if (x->getTimeTag() == y->getTimeTag()) {
88 if (x->getId() > y->getId()) return false;
89 if (x->getId() == y->getId()) {
90 if (x->getDataLength() > y->getDataLength()) return false;
91 if (x->getDataLength() == y->getDataLength()) {
92 // compare the data
93 return ::memcmp(x->getConstVoidDataPtr(),
94 y->getConstVoidDataPtr(),x->getDataLength()) < 0;
95 }
96 }
97 }
98 return true;
99 }
100};
101
107typedef std::multiset<const Sample*,SampleTimetagComparator> SortedSampleSet;
108
118typedef std::set<const Sample*,SampleHeaderComparator> SortedSampleSet2;
119
120typedef std::set<const Sample*,FullSampleComparator> SortedSampleSet3;
121
122}} // namespace nidas namespace core
123
124#endif
Comparator of pointers to Samples, does the same checks as SampleHeaderComparator,...
Definition SortedSampleSet.h:80
bool operator()(const Sample *x, const Sample *y) const
Return true if x is less than y.
Definition SortedSampleSet.h:85
Timetag and Id comparator of pointers to Samples: if two timetags are the same, then compare Ids,...
Definition SortedSampleSet.h:59
bool operator()(const Sample *x, const Sample *y) const
Return true if x is less than y.
Definition SortedSampleSet.h:64
Sample time tag comparator.
Definition SortedSampleSet.h:38
bool operator()(const Sample *x, const Sample *y) const
Return true if x is less than y.
Definition SortedSampleSet.h:43
Interface to a data sample.
Definition Sample.h:190
std::set< const Sample *, SampleHeaderComparator > SortedSampleSet2
A set for storing samples sorted by the timetag, id and data length.
Definition SortedSampleSet.h:118
std::set< const Sample *, FullSampleComparator > SortedSampleSet3
Definition SortedSampleSet.h:120
std::multiset< const Sample *, SampleTimetagComparator > SortedSampleSet
A multiset for storing samples sorted by timetag.
Definition SortedSampleSet.h:107
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31