libpniio
is_valid.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 
28 namespace pni{
29 namespace io{
30 namespace nx{
31 
53  template<typename OTYPE> bool is_valid(const OTYPE &o) noexcept
54  {
55  return o.is_valid();
56  }
57 
72  template<
73  typename GTYPE,
74  typename FTYPE,
75  typename ATYPE,
76  typename LTYPE
77  >
78  class is_valid_visitor : public boost::static_visitor<bool>
79  {
80  public:
82  using result_type = bool;
84  using group_type = GTYPE;
86  using field_type = FTYPE;
88  using attribute_type = ATYPE;
90  using link_type = LTYPE;
91 
92  //-----------------------------------------------------------------
105  {
106  return is_valid(g);
107  }
108 
109  //-----------------------------------------------------------------
122  {
123  return is_valid(f);
124  }
125 
126  //-----------------------------------------------------------------
139  {
140  return is_valid(a);
141  }
142 
143  //-----------------------------------------------------------------
153  {
154  return is_valid(l);
155  }
156  };
157 
158  //------------------------------------------------------------------------
165 
175  template<
187  typename GTYPE,
188  typename FTYPE,
189  typename ATYPE,
190  typename LTYPE
191  >
193  {
194  using visitor_type = is_valid_visitor<GTYPE,FTYPE,ATYPE,LTYPE>;
195  return boost::apply_visitor(visitor_type(),o);
196  }
197 
198 //end of namespace
199 }
200 }
201 }
bool result_type
result type (bool)
Definition: is_valid.hpp:82
result_type operator()(const group_type &g) const
process group instances
Definition: is_valid.hpp:104
FTYPE field_type
Nexus field type.
Definition: is_valid.hpp:86
result_type operator()(const link_type &l) const
process nxlink instances
Definition: is_valid.hpp:152
Definition: cbf_reader.hpp:41
LTYPE link_type
NeXus link type.
Definition: is_valid.hpp:90
check object validity
Definition: is_valid.hpp:78
bool is_valid(const OTYPE &o) noexcept
visitor checking object validity
Definition: is_valid.hpp:53
result_type operator()(const attribute_type &a) const
process attribute instances
Definition: is_valid.hpp:138
ATYPE attribute_type
Nexus attribute type.
Definition: is_valid.hpp:88
result_type operator()(const field_type &f) const
process field instances
Definition: is_valid.hpp:121
boost::variant< GTYPE, FTYPE, ATYPE, LTYPE > nxobject
Definition: nxobject.hpp:44
GTYPE group_type
Nexus group type.
Definition: is_valid.hpp:84