Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 09:10:01

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #ifndef GAUDI_NAMEDRANGE_H
0012 #define GAUDI_NAMEDRANGE_H 1
0013 // ============================================================================
0014 // Include files
0015 // ============================================================================
0016 // STD & STL
0017 // ============================================================================
0018 #include <string>
0019 // ============================================================================
0020 // GaudiUtils
0021 // ============================================================================
0022 #include "GaudiKernel/Range.h"
0023 // ============================================================================
0024 /** @file
0025  *
0026  *  This file has been imported from
0027  *  <a href="http://savannah.cern.ch/projects/loki">LoKi project</a>
0028  *  <a href="http://cern.ch/lhcb-comp/Analysis/Loki">
0029  *  "C++ ToolKit  for Smart and Friendly Physics Analysis"</a>
0030  *
0031  *  The package has been designed with the kind help from
0032  *  Galina PAKHLOVA and Sergey BARSUK.  Many bright ideas,
0033  *  contributions and advices from G.Raven, J.van Tilburg,
0034  *  A.Golutvin, P.Koppenburg have been used in the design.
0035  *
0036  *  @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
0037  *  @date 2001-01-23
0038  */
0039 // ============================================================================
0040 namespace Gaudi {
0041   // ==========================================================================
0042   /** @class NamedRange NamedRange.h GaudiUtils/NamedRange.h
0043    *
0044    *  New concept of "named" range : range with name
0045    *
0046    *  @see Gaudi::Range_
0047    *
0048    *  @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
0049    *  @date   2004-11-19
0050    */
0051   template <class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>
0052   class NamedRange_ : public Gaudi::Range_<CONTAINER, ITERATOR> {
0053   protected:
0054     // ========================================================================
0055     /// the base class
0056     typedef Gaudi::Range_<CONTAINER, ITERATOR> Base;
0057     /// "self"-type
0058     typedef NamedRange_<CONTAINER, ITERATOR> Self;
0059     // ========================================================================
0060   public:
0061     // ========================================================================
0062     /// default constructor
0063     NamedRange_() = default;
0064     /** Constructor
0065      *  @param ibegin  iterator to begin of the sequence
0066      *  @param iend    iterator to end   of the sequence
0067      *  @param name    name of the range
0068      */
0069     NamedRange_( typename Base::iterator ibegin, typename Base::iterator iend, std::string name = "" )
0070         : Base( ibegin, iend ), m_name( std::move( name ) ){};
0071     /** constructor from the base class
0072      *  @param base base objects
0073      *  @param name name of the range
0074      */
0075     NamedRange_( const Base& base, std::string name = "" ) : Base( base ), m_name( std::move( name ) ){};
0076     /** constructor from the base class
0077      *  @param base base objects
0078      *  @param name name of the range
0079      */
0080     NamedRange_( const typename Base::Base& base, std::string name = "" ) : Base( base ), m_name( std::move( name ) ){};
0081     /** constructor from the base class
0082      *  @param base base objects
0083      *  @param name name of the range
0084      */
0085     NamedRange_( const typename Base::Container& base, std::string name = "" )
0086         : Base( base ), m_name( std::move( name ) ){};
0087     /* constructor of empty range/sequence
0088      * @param ibegin  iterator to begin of empty sequence
0089      *  @param name name of the range
0090      */
0091     NamedRange_( typename Base::iterator ibegin, std::string name = "" )
0092         : Base( ibegin, ibegin ), m_name( std::move( name ) ){};
0093     /// destructor
0094     ~NamedRange_() = default;
0095     // ========================================================================
0096   public:
0097     // ========================================================================
0098     /// get a "slice" of a range, in Python style
0099     NamedRange_ slice( long index1, long index2 ) const { return NamedRange_( Base::slice( index1, index2 ), m_name ); }
0100     // ========================================================================
0101   public:
0102     // ========================================================================
0103     /// get the name of the range
0104     const std::string& name() const { return m_name; }
0105     /// set the name of the range
0106     void setName( std::string value ) { m_name = std::move( value ); }
0107     // ========================================================================
0108     using Base::operator==;
0109 
0110   private:
0111     // ========================================================================
0112     /// the name, associated to the range
0113     std::string m_name; // the name associated to the range
0114     // ========================================================================
0115   };
0116   // ==========================================================================
0117   /** simple function to create the named range from arbitrary container
0118    *  @code
0119    *
0120    *    const CONTAINER& cnt = ... ;
0121    *    auto r = range ( cnt , "some name") ;
0122    *
0123    *  @endcode
0124    *  @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
0125    *  @date 2007-11-29
0126    */
0127   template <class CONTAINER>
0128   NamedRange_<CONTAINER> range( const CONTAINER& cnt, std::string name ) {
0129     return NamedRange_<CONTAINER>( cnt.begin(), cnt.end(), std::move( name ) );
0130   }
0131   // ==========================================================================
0132 } // end of namespace Gaudi
0133 // ============================================================================
0134 // The END
0135 // ============================================================================
0136 #endif // GAUDI_NAMEDRANGE_H