libpniio
get_parent.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 1, 2013
20 // Author: Eugen Wintersberger <eugen.wintersberger@desy.de>
21 //
22 #pragma once
23 
24 #include "../nxobject.hpp"
25 #include "../nxobject_traits.hpp"
26 
27 namespace pni{
28 namespace io{
29 namespace nx{
30 
48  template<
49  template<nximp_code> class OTYPE,
50  nximp_code IMPID
51  >
52  typename nxobject_trait<IMPID>::object_type
53  get_parent(const OTYPE<IMPID> &o)
54  {
55  return o.parent();
56  }
57 
58  //------------------------------------------------------------------------
71  template<
72  typename GTYPE,
73  typename FTYPE,
74  typename ATYPE,
75  typename LTYPE
76  >
77  class get_parent_visitor : public boost::static_visitor<
78  nxobject<GTYPE,FTYPE,ATYPE,LTYPE>
79  >
80  {
81  public:
85  using group_type = GTYPE;
87  using field_type = FTYPE;
89  using attribute_type = ATYPE;
91  using link_type = LTYPE;
92 
93  //-----------------------------------------------------------------
107  {
108  return get_parent(g);
109  }
110 
111  //-----------------------------------------------------------------
125  {
126  return get_parent(f);
127  }
128 
129  //-----------------------------------------------------------------
143  {
144  return get_parent(a);
145  }
146 
148  {
149  return get_parent(l);
150  }
151  };
152 
153  //-------------------------------------------------------------------------
173  template<
174  typename GTYPE,
175  typename FTYPE,
176  typename ATYPE,
177  typename LTYPE
178  >
179  nxobject<GTYPE,FTYPE,ATYPE,LTYPE>
181  {
182  using visitor_type = get_parent_visitor<GTYPE,FTYPE,ATYPE,LTYPE>;
183  return boost::apply_visitor(visitor_type(),o);
184  }
185 
186 //end of namespace
187 }
188 }
189 }
GTYPE group_type
Nexus group type.
Definition: get_parent.hpp:85
result_type operator()(const group_type &g) const
process groups
Definition: get_parent.hpp:106
nxobject< GTYPE, FTYPE, ATYPE, LTYPE > result_type
result type
Definition: get_parent.hpp:83
Definition: cbf_reader.hpp:41
result_type operator()(const attribute_type &a) const
process attribute
Definition: get_parent.hpp:142
nximp_code
implementation codes
Definition: nximp_code.hpp:40
result_type operator()(const link_type &l) const
Definition: get_parent.hpp:147
nxobject_trait< IMPID >::object_type get_parent(const OTYPE< IMPID > &o)
return parent
Definition: get_parent.hpp:53
ATYPE attribute_type
Nexus attribute type.
Definition: get_parent.hpp:89
result_type operator()(const field_type &f) const
process fields
Definition: get_parent.hpp:124
boost::variant< GTYPE, FTYPE, ATYPE, LTYPE > nxobject
Definition: nxobject.hpp:44
LTYPE link_type
link type
Definition: get_parent.hpp:91
FTYPE field_type
Nexus field type.
Definition: get_parent.hpp:87
get parent visitor
Definition: get_parent.hpp:77