The Gaudi Framework  master (37c0b60a)
NamedRange.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 #ifndef GAUDI_NAMEDRANGE_H
12 #define GAUDI_NAMEDRANGE_H 1
13 // ============================================================================
14 // Include files
15 // ============================================================================
16 // STD & STL
17 // ============================================================================
18 #include <string>
19 // ============================================================================
20 // GaudiUtils
21 // ============================================================================
22 #include <GaudiKernel/Range.h>
23 // ============================================================================
39 // ============================================================================
40 namespace Gaudi {
41  // ==========================================================================
52  class NamedRange_ : public Gaudi::Range_<CONTAINER, ITERATOR> {
53  protected:
54  // ========================================================================
59  // ========================================================================
60  public:
61  // ========================================================================
63  NamedRange_() = default;
69  NamedRange_( typename Base::iterator ibegin, typename Base::iterator iend, std::string name = "" )
70  : Base( ibegin, iend ), m_name( std::move( name ) ) {}
75  NamedRange_( const Base& base, std::string name = "" ) : Base( base ), m_name( std::move( name ) ) {}
80  NamedRange_( const typename Base::Base& base, std::string name = "" ) : Base( base ), m_name( std::move( name ) ) {}
85  NamedRange_( const typename Base::Container& base, std::string name = "" )
86  : Base( base ), m_name( std::move( name ) ) {}
87  /* constructor of empty range/sequence
88  * @param ibegin iterator to begin of empty sequence
89  * @param name name of the range
90  */
91  NamedRange_( typename Base::iterator ibegin, std::string name = "" )
92  : Base( ibegin, ibegin ), m_name( std::move( name ) ) {}
94  ~NamedRange_() = default;
95  // ========================================================================
96  public:
97  // ========================================================================
99  NamedRange_ slice( long index1, long index2 ) const { return NamedRange_( Base::slice( index1, index2 ), m_name ); }
100  // ========================================================================
101  public:
102  // ========================================================================
104  const std::string& name() const { return m_name; }
106  void setName( std::string value ) { m_name = std::move( value ); }
107  // ========================================================================
108  using Base::operator==;
109 
110  private:
111  // ========================================================================
113  std::string m_name; // the name associated to the range
114  // ========================================================================
115  };
116  // ==========================================================================
127  template <class CONTAINER>
128  NamedRange_<CONTAINER> range( const CONTAINER& cnt, std::string name ) {
129  return NamedRange_<CONTAINER>( cnt.begin(), cnt.end(), std::move( name ) );
130  }
131  // ==========================================================================
132 } // end of namespace Gaudi
133 // ============================================================================
134 // The END
135 // ============================================================================
136 #endif // GAUDI_NAMEDRANGE_H
Gaudi::NamedRange_::name
const std::string & name() const
get the name of the range
Definition: NamedRange.h:104
Gaudi::NamedRange_::NamedRange_
NamedRange_(const Base &base, std::string name="")
constructor from the base class
Definition: NamedRange.h:75
Gaudi::NamedRange_::slice
NamedRange_ slice(long index1, long index2) const
get a "slice" of a range, in Python style
Definition: NamedRange.h:99
std::string
STL class.
Gaudi::Range_::Container
Gaudi::details::container< CONTAINER >::Container Container
type for actual contained iterator
Definition: Range.h:102
Gaudi::NamedRange_::NamedRange_
NamedRange_(const typename Base::Base &base, std::string name="")
constructor from the base class
Definition: NamedRange.h:80
Gaudi::NamedRange_
Definition: NamedRange.h:52
std::move
T move(T... args)
Gaudi::Range_< CONTAINER, typename Gaudi::details::container< CONTAINER >::Iterator >::base
const Base & base() const
conversion operator to the std::pair
Definition: Range.h:243
std::pair
Gaudi::NamedRange_::m_name
std::string m_name
the name, associated to the range
Definition: NamedRange.h:113
Range.h
Gaudi::NamedRange_::NamedRange_
NamedRange_(typename Base::iterator ibegin, std::string name="")
Definition: NamedRange.h:91
Gaudi::range
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range from arbitrary container
Definition: NamedRange.h:128
Gaudi::NamedRange_::Self
NamedRange_< CONTAINER, ITERATOR > Self
"self"-type
Definition: NamedRange.h:58
Gaudi::NamedRange_::NamedRange_
NamedRange_()=default
default constructor
Gaudi::NamedRange_::setName
void setName(std::string value)
set the name of the range
Definition: NamedRange.h:106
Gaudi::NamedRange_::~NamedRange_
~NamedRange_()=default
destructor
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
Gaudi::Range_
Definition: Range.h:94
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
Gaudi::NamedRange_::Base
Gaudi::Range_< CONTAINER, ITERATOR > Base
the base class
Definition: NamedRange.h:56
Gaudi::Range_::slice
Range_ slice(long index1, long index2) const
get a "slice" of a range, in Python style
Definition: Range.h:168
std
STL namespace.
Gaudi::NamedRange_::NamedRange_
NamedRange_(typename Base::iterator ibegin, typename Base::iterator iend, std::string name="")
Constructor.
Definition: NamedRange.h:69
Gaudi::Range_::iterator
ITERATOR iterator
Definition: Range.h:104
Gaudi::NamedRange_::NamedRange_
NamedRange_(const typename Base::Container &base, std::string name="")
constructor from the base class
Definition: NamedRange.h:85
Iterator
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:28