Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:00:28

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 GAUDIKERNEL_BOOSTARRAYASPROPERTY_H
0012 #define GAUDIKERNEL_BOOSTARRAYASPROPERTY_H 1
0013 // ============================================================================
0014 // Include files
0015 // ============================================================================
0016 // STD & STL
0017 // ============================================================================
0018 #include <algorithm>
0019 // ============================================================================
0020 // Boost
0021 // ============================================================================
0022 #include "boost/array.hpp"
0023 // ============================================================================
0024 /** @file
0025  *  Collection of utilities, which allows to use class boost::array
0026  *  as property for Gaudi-components
0027  *
0028  *  @attention this file must be "included" before Gaudi/Property.h
0029  *
0030  *  @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
0031  *  @date 2009-09-16
0032  */
0033 // ============================================================================
0034 // 1) Streamers : value -> string
0035 // ============================================================================
0036 namespace Gaudi {
0037   // ==========================================================================
0038   namespace Utils {
0039     // ========================================================================
0040     template <class ITERATOR>
0041     inline std::ostream& toStream( ITERATOR           first,   // begin of the sequence
0042                                    ITERATOR           last,    //   end of the sequence
0043                                    std::ostream&      s,       //            the stream
0044                                    const std::string& open,    //               opening
0045                                    const std::string& close,   //               closing
0046                                    const std::string& delim ); //             delimiter
0047     // ========================================================================
0048     /** printout of class boost::array
0049      *  The format is "Python's tuple"
0050      *  @param  obj (INPUT)  the arary to be printed
0051      *  @param  s   (UPDATE) the actual stream
0052      *  @return the updated stream
0053      *  @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
0054      *  @date 2009-09-16
0055      */
0056     template <class TYPE, std::size_t N>
0057     inline std::ostream& toStream( const boost::array<TYPE, N>& obj, std::ostream& s ) {
0058       return toStream( obj.begin(), obj.end(), s, "( ", " )", " , " );
0059     }
0060     // ========================================================================
0061   } // namespace Utils
0062   // ==========================================================================
0063 } //                                                     end of namespace Gaudi
0064 // ============================================================================
0065 // 2) Parsers: string -> value
0066 // ============================================================================
0067 // GaudiKernel
0068 // ============================================================================
0069 #include <Gaudi/Parsers/CommonParsers.h>
0070 // ============================================================================
0071 namespace Gaudi {
0072   // ==========================================================================
0073   namespace Parsers {
0074     // ========================================================================
0075     /** parse class boost::array from the string
0076      *  @param result (OUTPUT) the actual result
0077      *  @param input  (INPUT)  the input string
0078      *  @return status code
0079      *  @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
0080      *  @date 2009-09-16
0081      */
0082     template <class TYPE, std::size_t N>
0083     StatusCode parse( boost::array<TYPE, N>& result, const std::string& input ) {
0084       typedef std::vector<TYPE> _Vct;
0085       // create the temporaty vector
0086       _Vct tmp;
0087       // parse the string
0088       StatusCode sc = parse( tmp, input );
0089       if ( sc.isFailure() ) { return sc; }
0090       if ( N != tmp.size() ) { return StatusCode::FAILURE; }
0091       // copy vector into array
0092       std::copy( tmp.begin(), tmp.end(), result.begin() );
0093       //
0094       return StatusCode::SUCCESS;
0095     }
0096     // ========================================================================
0097   } // namespace Parsers
0098   // ==========================================================================
0099 } //                                                     end of namespace Gaudi
0100 // ============================================================================
0101 // The END
0102 // ============================================================================
0103 #endif // GAUDIKERNEL_BOOSTARRAYASPROPERTY_H