libpniio
get_name.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 <pni/core/types.hpp>
25 #include "../nximp_code.hpp"
26 #include "../nxobject.hpp"
27 
28 namespace pni{
29 namespace io{
30 namespace nx{
31 
55  template<
56  template<nximp_code> class OTYPE,
57  nximp_code IMPID
58  >
59  pni::core::string get_name(const OTYPE<IMPID> &o)
60  {
61  return o.name();
62  }
63 
64  //------------------------------------------------------------------------
78  template<
79  typename GTYPE,
80  typename FTYPE,
81  typename ATYPE,
82  typename LTYPE
83  >
84  class get_name_visitor : public boost::static_visitor<pni::core::string>
85  {
86  public:
88  using result_type = pni::core::string;
90  using group_type = GTYPE;
92  using field_type = FTYPE;
94  using attribute_type = ATYPE;
96  using link_type = LTYPE;
97 
98  //-----------------------------------------------------------------
113  {
114  return get_name(g);
115  }
116 
117  //-----------------------------------------------------------------
132  {
133  return get_name(f);
134  }
135 
136  //-----------------------------------------------------------------
151  {
152  return get_name(a);
153  }
154 
155  //-----------------------------------------------------------------
165  {
166  return a.name();
167  }
168  };
169 
190  template<
191  typename GTYPE,
192  typename FTYPE,
193  typename ATYPE,
194  typename LTYPE
195  >
196  pni::core::string get_name(const nxobject<GTYPE,FTYPE,ATYPE,LTYPE> &o)
197  {
198  using visitor_type = get_name_visitor<GTYPE,FTYPE,ATYPE,LTYPE>;
199  return boost::apply_visitor(visitor_type(),o);
200  }
201 
202 //end of namespace
203 }
204 }
205 }
get name visitor
Definition: get_name.hpp:84
result_type operator()(const field_type &f) const
process field instances
Definition: get_name.hpp:131
FTYPE field_type
Nexus field type.
Definition: get_name.hpp:92
ATYPE attribute_type
Nexus attribute type.
Definition: get_name.hpp:94
LTYPE link_type
NeXus link type.
Definition: get_name.hpp:96
Definition: cbf_reader.hpp:41
result_type operator()(const group_type &g) const
process group instances
Definition: get_name.hpp:112
pni::core::string get_name(const OTYPE< IMPID > &o)
get object name
Definition: get_name.hpp:59
nximp_code
implementation codes
Definition: nximp_code.hpp:40
GTYPE group_type
Nexus group type.
Definition: get_name.hpp:90
pni::core::string result_type
result type
Definition: get_name.hpp:88
result_type operator()(const link_type &a) const
process nxlink instances
Definition: get_name.hpp:164
boost::variant< GTYPE, FTYPE, ATYPE, LTYPE > nxobject
Definition: nxobject.hpp:44
result_type operator()(const attribute_type &a) const
process attribute instances
Definition: get_name.hpp:150