libpniio
is_link.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2016 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: Mar 07, 2016
20 // Author: Eugen Wintersberger <eugen.wintersberger@desy.de>
21 //
22 #pragma once
23 
24 #include "../nxobject.hpp"
25 
26 namespace pni{
27 namespace io{
28 namespace nx{
29 
44  template<
45  typename GTYPE,
46  typename FTYPE,
47  typename ATYPE,
48  typename LTYPE
49  >
50  class is_link_visitor : public boost::static_visitor<bool>
51  {
52  public:
54  using result_type = bool;
56  using group_type = GTYPE;
58  using field_type = FTYPE;
60  using attribute_type = ATYPE;
62  using link_type = LTYPE;
63 
64  //----------------------------------------------------------------
71  result_type operator()(const group_type &) const noexcept
72  {
73  return false;
74  }
75 
76  //-----------------------------------------------------------------
83  result_type operator()(const field_type &) const noexcept
84  {
85  return false;
86  }
87 
88  //-----------------------------------------------------------------
95  result_type operator()(const attribute_type &) const noexcept
96  {
97  return false;
98  }
99 
100  //-----------------------------------------------------------------
106  result_type operator()(const link_type &) const noexcept
107  {
108  return true;
109  }
110  };
111 
130  template<
131  typename GTYPE,
132  typename FTYPE,
133  typename ATYPE,
134  typename LTYPE
135  >
137  {
138  using visitor_type = is_link_visitor<GTYPE,FTYPE,ATYPE,LTYPE>;
139  return boost::apply_visitor(visitor_type(),o);
140  }
141 
142 //end of namespace
143 }
144 }
145 }
Definition: cbf_reader.hpp:41
bool is_link(const nxobject< GTYPE, FTYPE, ATYPE, LTYPE > &o) noexcept
test for group
Definition: is_link.hpp:136
boost::variant< GTYPE, FTYPE, ATYPE, LTYPE > nxobject
Definition: nxobject.hpp:44