libpniio
selection_guard.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2014 DESY, Eugen Wintersberger <eugen.wintersberger@desy.de>
3 //
4 // This file is part of libpniio.
5 //
6 // libpniio is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // libpniio is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with libpniio. If not, see <http://www.gnu.org/licenses/>.
18 // ===========================================================================
19 //
20 // Created on: Nov 4, 2014
21 // Author: Eugen Wintersberger <eugen.wintersberger@desy.de>
22 //
23 #pragma once
24 
25 
26 namespace pni{
27 namespace io{
28 namespace nx{
29 namespace h5{
30 
31  //forward declaration
32  class selection;
33 
44  template<typename STYPE> class selection_guard
45  {
46  private:
48  const STYPE &_space_ref;
50  bool _apply;
51  public:
52  //----------------------------------------------------------------
63  selection_guard(const selection &s,const STYPE &space,bool apply):
64  _space_ref(space),
65  _apply(apply)
66  {
67  if(_apply) _space_ref.apply_selection(s);
68  }
69 
70  //----------------------------------------------------------------
72  {
73  if(_apply) _space_ref.reset_selection();
74  }
75  };
76 
77 
78 //end of namespace
79 }
80 }
81 }
82 }
bool _apply
flag to decide whether or not to apply the selection
Definition: selection_guard.hpp:50
const STYPE & _space_ref
reference to the dataspace to which to apply the selection
Definition: selection_guard.hpp:48
selection guard
Definition: selection_guard.hpp:44
Definition: cbf_reader.hpp:41
describe a selection in an HDF5 file
Definition: selection.hpp:37
selection_guard(const selection &s, const STYPE &space, bool apply)
constructor
Definition: selection_guard.hpp:63
~selection_guard()
Definition: selection_guard.hpp:71