The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
NamedRange.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#pragma once
12
13#include <GaudiKernel/Range.h>
14#include <string>
15
31namespace Gaudi {
41 template <class CONTAINER, class ITERATOR = typename CONTAINER::const_iterator>
42 class NamedRange_ : public Gaudi::Range_<CONTAINER, ITERATOR> {
43 protected:
48
49 public:
51 NamedRange_() = default;
57 NamedRange_( typename Base::iterator ibegin, typename Base::iterator iend, std::string name = "" )
58 : Base( ibegin, iend ), m_name( std::move( name ) ) {}
59
63 NamedRange_( const Base& base, std::string name = "" ) : Base( base ), m_name( std::move( name ) ) {}
68 NamedRange_( const typename Base::Base& base, std::string name = "" ) : Base( base ), m_name( std::move( name ) ) {}
73 NamedRange_( const typename Base::Container& base, std::string name = "" )
74 : Base( base ), m_name( std::move( name ) ) {}
75 /* constructor of empty range/sequence
76 * @param ibegin iterator to begin of empty sequence
77 * @param name name of the range
78 */
79 NamedRange_( typename Base::iterator ibegin, std::string name = "" )
80 : Base( ibegin, ibegin ), m_name( std::move( name ) ) {}
81
82 ~NamedRange_() = default;
83
84 public:
86 NamedRange_ slice( long index1, long index2 ) const { return NamedRange_( Base::slice( index1, index2 ), m_name ); }
87
88 public:
90 const std::string& name() const { return m_name; }
92 void setName( std::string value ) { m_name = std::move( value ); }
93 using Base::operator==;
94
95 private:
97 std::string m_name; // the name associated to the range
98 };
99
110 template <class CONTAINER>
111 NamedRange_<CONTAINER> range( const CONTAINER& cnt, std::string name ) {
112 return NamedRange_<CONTAINER>( cnt.begin(), cnt.end(), std::move( name ) );
113 }
114} // namespace Gaudi
This file has been imported from LoKi project "C++ ToolKit for Smart and Friendly Physics Analysis"
const std::string & name() const
Definition NamedRange.h:90
NamedRange_(const Base &base, std::string name="")
constructor from the base class
Definition NamedRange.h:63
NamedRange_(typename Base::iterator ibegin, std::string name="")
Definition NamedRange.h:79
NamedRange_()=default
default constructor
NamedRange_(const typename Base::Container &base, std::string name="")
constructor from the base class
Definition NamedRange.h:73
NamedRange_< T, typename T::const_iterator > Self
Definition NamedRange.h:47
NamedRange_(const typename Base::Base &base, std::string name="")
constructor from the base class
Definition NamedRange.h:68
void setName(std::string value)
set the name of the range
Definition NamedRange.h:92
Gaudi::Range_< T, typename T::const_iterator > Base
Definition NamedRange.h:45
NamedRange_ slice(long index1, long index2) const
get a "slice" of a range, in Python style
Definition NamedRange.h:86
~NamedRange_()=default
NamedRange_(typename Base::iterator ibegin, typename Base::iterator iend, std::string name="")
Constructor.
Definition NamedRange.h:57
Useful class for representation of "sequence" of the objects through the range of valid iterators.
Definition Range.h:81
typename Gaudi::details::container< CONTAINER >::Container Container
type for actual contained iterator
Definition Range.h:87
const_iterator iterator
Definition Range.h:89
Range_ slice(long index1, long index2) const
get a "slice" of a range, in Python style
Definition Range.h:148
std::pair< iterator, iterator > Base
Definition Range.h:90
const Base & base() const
conversion operator to the std::pair
Definition Range.h:215
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range from arbitrary container
Definition NamedRange.h:111
STL namespace.