libpniio
get_root.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2014 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 4, 2014
20 // Author: Eugen Wintersberger <eugen.wintersberger@desy.de>
21 //
22 #pragma once
23 
24 #include <pni/core/types.hpp>
25 #include "get_parent.hpp"
26 
27 namespace pni{
28 namespace io{
29 namespace nx{
30 
46  template<typename OTYPE>
47  auto get_root(const OTYPE &p) -> decltype(get_parent(p))
48  {
49  decltype(get_parent(p)) root = p;
50  do
51  root = get_parent(root);
52  while(get_name(root)!="/");
53 
54  return root;
55 
56  }
57 
58 //end of namespace
59 }}}
Definition: cbf_reader.hpp:41
pni::core::string get_name(const OTYPE< IMPID > &o)
get object name
Definition: get_name.hpp:59
auto get_root(const OTYPE &p) -> decltype(get_parent(p))
get root
Definition: get_root.hpp:47
nxobject_trait< IMPID >::object_type get_parent(const OTYPE< IMPID > &o)
return parent
Definition: get_parent.hpp:53