bes
Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
DmrppChunkOdometer.h
1
// -*- mode: c++; c-basic-offset:4 -*-
2
3
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
4
// Access Protocol.
5
6
// Copyright (c) 2015 OPeNDAP, Inc.
7
// Author: James Gallagher <jgallagher@opendap.org>
8
//
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
13
//
14
// This library 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 GNU
17
// Lesser General Public License for more details.
18
//
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
//
23
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24
25
#ifndef DMRPP_CHUNK_ODOMETER_H_
26
#define DMRPP_CHUNK_ODOMETER_H_
27
28
#include <vector>
29
30
namespace
dmrpp {
31
32
using
shape = std::vector<unsigned long long>;
33
56
class
DmrppChunkOdometer
57
{
58
private
:
59
// The state set by the ctor
60
shape d_shape;
61
shape d_array_shape;
62
63
// The varying state of the Odometer
64
shape d_indices;
65
66
public
:
67
DmrppChunkOdometer() =
default
;
68
~DmrppChunkOdometer() =
default
;
69
78
DmrppChunkOdometer
(shape chunk_shape, shape array_shape) :
79
d_shape(std::move(chunk_shape)), d_array_shape(std::move(array_shape))
80
{
81
reset
();
82
}
83
88
void
reset
() noexcept
89
{
90
d_indices.resize(d_shape.size(), 0);
91
}
92
104
inline
bool
next
()
105
{
106
bool
status =
false
;
// false indicates the last 'odometer value' has been found
107
auto
si = d_shape.rbegin();
108
auto
ai = d_array_shape.rbegin();
109
for
(
auto
i = d_indices.rbegin(), e = d_indices.rend(); i != e; ++i, ++si, ++ai) {
110
*i = *i + *ai;
111
if
(*i >= *si) {
112
*i = 0;
113
}
114
else
{
115
status =
true
;
116
break
;
117
}
118
}
119
120
return
status;
121
}
122
129
inline
const
shape &
indices
() const noexcept
130
{
131
return
d_indices;
132
}
133
};
134
135
}
// namespace libdap
136
137
#endif
// DMRPP_CHUNK_ODOMETER_H_
dmrpp::DmrppChunkOdometer::DmrppChunkOdometer
DmrppChunkOdometer(shape chunk_shape, shape array_shape)
Definition
DmrppChunkOdometer.h:78
dmrpp::DmrppChunkOdometer::indices
const shape & indices() const noexcept
Definition
DmrppChunkOdometer.h:129
dmrpp::DmrppChunkOdometer::reset
void reset() noexcept
Definition
DmrppChunkOdometer.h:88
dmrpp::DmrppChunkOdometer::next
bool next()
Definition
DmrppChunkOdometer.h:104
modules
dmrpp_module
DmrppChunkOdometer.h
Generated by
1.13.2