libpniio
close.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2013 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 // Created on: Jul 17, 2013
20 // Author: Eugen Wintersberger <eugen.wintersberger@desy.de>
21 //
22 #pragma once
23 
24 #include "../nxobject.hpp"
25 #include "../nximp_code.hpp"
26 #include "../link.hpp"
27 
28 namespace pni{
29 namespace io{
30 namespace nx{
31 
46  template<nximp_code IMPID> void close(nxlink<IMPID> &)
47  {}
48  template<typename OTYPE> void close(OTYPE &o)
49  {
50  o.close();
51  }
52 
53 
54 
55  //------------------------------------------------------------------------
67  template<
68  typename GTYPE,
69  typename FTYPE,
70  typename ATYPE,
71  typename LTYPE
72  >
73  class close_visitor : public boost::static_visitor<void>
74  {
75  public:
77  using result_type = void;
79  using group_type = GTYPE;
81  using field_type = FTYPE;
83  using attribute_type = ATYPE;
85  using link_type = LTYPE;
86 
87  //-----------------------------------------------------------------
100  void operator()(group_type &g) const
101  {
102  close(g);
103  }
104 
105  //-----------------------------------------------------------------
118  void operator()(field_type &f) const
119  {
120  close(f);
121  }
122 
123  //-----------------------------------------------------------------
136  void operator()(attribute_type &a) const
137  {
138  close(a);
139  }
140 
141  //----------------------------------------------------------------
147  void operator()(const link_type &) const
148  {
149 
150  }
151  };
152 
153  //------------------------------------------------------------------------
171  template<
172  typename GTYPE,
173  typename FTYPE,
174  typename ATYPE,
175  typename LTYPE
176  >
178  {
179  using visitor_type = close_visitor<GTYPE,FTYPE,ATYPE,LTYPE>;
180  return boost::apply_visitor(visitor_type(),o);
181  }
182 
183 
184 //end of namespace
185 }
186 }
187 }
void operator()(group_type &g) const
process group instances
Definition: close.hpp:100
void operator()(const link_type &) const
process a link instance
Definition: close.hpp:147
void operator()(field_type &f) const
process field instances
Definition: close.hpp:118
void close(nxlink< IMPID > &)
close object
Definition: close.hpp:46
void operator()(attribute_type &a) const
process attribute instances
Definition: close.hpp:136
LTYPE link_type
link type
Definition: close.hpp:85
Definition: cbf_reader.hpp:41
GTYPE group_type
Nexus group type.
Definition: close.hpp:79
close an object
Definition: close.hpp:73
void result_type
result type (bool)
Definition: close.hpp:77
FTYPE field_type
Nexus field type.
Definition: close.hpp:81
boost::variant< GTYPE, FTYPE, ATYPE, LTYPE > nxobject
Definition: nxobject.hpp:44
ATYPE attribute_type
Nexus attribute type.
Definition: close.hpp:83