libpniio
is_field.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 //
20 // Created on: Jun 28, 2013
21 // Author: Eugen Wintersberger <eugen.wintersberger@desy.de>
22 //
23 #pragma once
24 
25 #include "../nxobject.hpp"
26 
27 namespace pni{
28 namespace io{
29 namespace nx{
30 
43  template<
44  typename GTYPE,
45  typename FTYPE,
46  typename ATYPE,
47  typename LTYPE
48  >
49  class is_field_visitor : public boost::static_visitor<bool>
50  {
51  public:
53  using result_type = bool;
55  using group_type = GTYPE;
57  using field_type = FTYPE;
59  using attribute_type = ATYPE;
61  using link_type = LTYPE;
62 
63  //-----------------------------------------------------------------
70  result_type operator()(const group_type &) const noexcept
71  {
72  return false;
73  }
74 
75  //-----------------------------------------------------------------
82  result_type operator()(const field_type &) const noexcept
83  {
84  return true;
85  }
86 
87  //-----------------------------------------------------------------
94  result_type operator()(const attribute_type &) const noexcept
95  {
96  return false;
97  }
98 
99  //-----------------------------------------------------------------
105  result_type operator()(const link_type &) const noexcept
106  {
107  return false;
108  }
109  };
110 
111  //------------------------------------------------------------------------
129  template<
130  typename GTYPE,
131  typename FTYPE,
132  typename ATYPE,
133  typename LTYPE
134  >
136  {
137  using visitor_type = is_field_visitor<GTYPE,FTYPE,ATYPE,LTYPE>;
138  return boost::apply_visitor(visitor_type(),o);
139  }
140 
141 //end of namespace
142 }
143 }
144 }
GTYPE group_type
Nexus group type.
Definition: is_field.hpp:55
bool is_field(const nxobject< GTYPE, FTYPE, ATYPE, LTYPE > &o) noexcept
check if field
Definition: is_field.hpp:135
bool result_type
result type (bool)
Definition: is_field.hpp:53
is_field visitor
Definition: is_field.hpp:49
LTYPE link_type
NeXus link type.
Definition: is_field.hpp:61
result_type operator()(const group_type &) const noexcept
process group instances
Definition: is_field.hpp:70
Definition: cbf_reader.hpp:41
result_type operator()(const attribute_type &) const noexcept
process attribute instances
Definition: is_field.hpp:94
boost::variant< GTYPE, FTYPE, ATYPE, LTYPE > nxobject
Definition: nxobject.hpp:44
result_type operator()(const field_type &) const noexcept
process field instances
Definition: is_field.hpp:82
ATYPE attribute_type
Nexus attribute type.
Definition: is_field.hpp:59
result_type operator()(const link_type &) const noexcept
process link instances
Definition: is_field.hpp:105
FTYPE field_type
Nexus field type.
Definition: is_field.hpp:57