From 3bd4cd0f3d04f1727ed74990b4a4a93b57f005ff Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Mon, 24 Sep 2018 10:57:06 +0200 Subject: [PATCH 01/53] Enable ADL for Gaudi::Parsers::parse relieve the requirement of strict ordering of includes --- .../src/Properties/CustomPropertiesAlg.cpp | 5 ++--- GaudiKernel/GaudiKernel/Property.h | 13 +++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/GaudiExamples/src/Properties/CustomPropertiesAlg.cpp b/GaudiExamples/src/Properties/CustomPropertiesAlg.cpp index 073272387b..4c839792d6 100644 --- a/GaudiExamples/src/Properties/CustomPropertiesAlg.cpp +++ b/GaudiExamples/src/Properties/CustomPropertiesAlg.cpp @@ -1,3 +1,5 @@ +#include "CustomPropertiesAlg.h" + // ---------------------------------------------------------------------------- // Allow to use std::unordered_map as a property // ---------------------------------------------------------------------------- @@ -55,9 +57,6 @@ namespace std } } -// This must be included after the grammar definitions -#include "CustomPropertiesAlg.h" - // ---------------------------------------------------------------------------- // Implementation file for class: CustomPropertiesAlg // diff --git a/GaudiKernel/GaudiKernel/Property.h b/GaudiKernel/GaudiKernel/Property.h index 713468d02e..97e91d884a 100644 --- a/GaudiKernel/GaudiKernel/Property.h +++ b/GaudiKernel/GaudiKernel/Property.h @@ -19,6 +19,15 @@ namespace Gaudi { + namespace Parsers + { + /// Helper class to enable ADL for parsers + struct InputData : std::string { + InputData( const std::string& s ) : std::string{s} {} + using std::string::string; + using std::string::operator=; + }; + } namespace Details { // ============================================================================ @@ -188,8 +197,8 @@ namespace Gaudi protected: inline void fromStringImpl( TYPE& buffer, const std::string& s ) { - using Gaudi::Parsers::parse; - if ( !parse( buffer, s ).isSuccess() ) { + using Gaudi::Parsers::InputData; + if ( !parse( buffer, InputData{s} ).isSuccess() ) { throw std::invalid_argument( "cannot parse '" + s + "' to " + System::typeinfoName( typeid( TYPE ) ) ); } } -- GitLab From 639ebd7e7759223fc7b62869c47fd70669415884 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Mon, 24 Sep 2018 11:19:30 +0200 Subject: [PATCH 02/53] Reorganization of Gaudi::Parsers code - moved related headers to different hierarchy - Gaudi/Parsers/XYZ.h --- .../src/IncidentSvc/DODBasicMapper.cpp | 2 +- .../ExtendedProperties/ExtendedProperties.cpp | 2 +- .../src/Properties/CustomPropertiesAlg.cpp | 4 +- GaudiGSL/src/Lib/Interpolation.cpp | 2 +- GaudiKernel/CMakeLists.txt | 2 +- GaudiKernel/Gaudi/Parsers/CommonParsers.h | 541 +++++++++++++++ GaudiKernel/Gaudi/Parsers/Factory.h | 60 ++ GaudiKernel/Gaudi/Parsers/Grammars.h | 611 +++++++++++++++++ GaudiKernel/Gaudi/Parsers/InputData.h | 16 + .../GaudiKernel/BoostArrayAsProperty.h | 2 +- GaudiKernel/GaudiKernel/GrammarsV2.h | 615 +----------------- GaudiKernel/GaudiKernel/Parsers.h | 549 +--------------- GaudiKernel/GaudiKernel/ParsersFactory.h | 67 +- GaudiKernel/GaudiKernel/Property.h | 12 +- GaudiKernel/GaudiKernel/SVectorAsProperty.h | 2 +- GaudiKernel/GaudiKernel/StdArrayAsProperty.h | 2 +- GaudiKernel/src/Lib/DataObjID.cpp | 2 +- .../src/Lib/DataObjectHandleProperty.cpp | 2 +- GaudiKernel/src/Lib/ParsersCollections.cpp | 2 +- GaudiKernel/src/Lib/ParsersHistograms.cpp | 4 +- .../src/Lib/ParsersStandardListCommon.h | 4 +- .../src/Lib/ParsersStandardMiscCommon.h | 4 +- GaudiKernel/src/Lib/ParsersStandardSingle.cpp | 4 +- GaudiKernel/src/Lib/ParsersVct.cpp | 2 +- GaudiKernel/src/Lib/StringKey.cpp | 2 +- GaudiKernel/tests/src/parsers.cpp | 2 +- GaudiUtils/src/Lib/HistoParsers.cpp | 2 +- 27 files changed, 1261 insertions(+), 1258 deletions(-) create mode 100644 GaudiKernel/Gaudi/Parsers/CommonParsers.h create mode 100644 GaudiKernel/Gaudi/Parsers/Factory.h create mode 100644 GaudiKernel/Gaudi/Parsers/Grammars.h create mode 100644 GaudiKernel/Gaudi/Parsers/InputData.h diff --git a/GaudiCoreSvc/src/IncidentSvc/DODBasicMapper.cpp b/GaudiCoreSvc/src/IncidentSvc/DODBasicMapper.cpp index 74e3221f3c..49ce30b462 100644 --- a/GaudiCoreSvc/src/IncidentSvc/DODBasicMapper.cpp +++ b/GaudiCoreSvc/src/IncidentSvc/DODBasicMapper.cpp @@ -1,7 +1,7 @@ // Include files #include "GaudiKernel/HashMap.h" -#include "GaudiKernel/Parsers.h" +#include // Local implementation of parsers from HashMap namespace Gaudi { diff --git a/GaudiExamples/src/ExtendedProperties/ExtendedProperties.cpp b/GaudiExamples/src/ExtendedProperties/ExtendedProperties.cpp index 1e2cbfe61e..4586b96a20 100644 --- a/GaudiExamples/src/ExtendedProperties/ExtendedProperties.cpp +++ b/GaudiExamples/src/ExtendedProperties/ExtendedProperties.cpp @@ -15,8 +15,8 @@ // ============================================================================ // Include parsers for creating parser that handles tuple // ============================================================================ -#include "GaudiKernel/ParsersFactory.h" #include "GaudiKernel/StdArrayAsProperty.h" +#include // ============================================================================ // GaudiAlg diff --git a/GaudiExamples/src/Properties/CustomPropertiesAlg.cpp b/GaudiExamples/src/Properties/CustomPropertiesAlg.cpp index 4c839792d6..7c525037f1 100644 --- a/GaudiExamples/src/Properties/CustomPropertiesAlg.cpp +++ b/GaudiExamples/src/Properties/CustomPropertiesAlg.cpp @@ -10,7 +10,7 @@ typedef std::unordered_map MyCustomType; // Define the parser -#include "GaudiKernel/ParsersFactory.h" +#include namespace Gaudi { @@ -21,7 +21,7 @@ namespace Gaudi template struct Grammar_ { // In this case, the type is a mapping type, so it requires the MapGrammar. - // For other grammars see GaudiKernel/GrammarsV2.h + // For other grammars see Gaudi/Parsers/Grammars.h typedef MapGrammar Grammar; }; diff --git a/GaudiGSL/src/Lib/Interpolation.cpp b/GaudiGSL/src/Lib/Interpolation.cpp index f342953465..5552dea082 100644 --- a/GaudiGSL/src/Lib/Interpolation.cpp +++ b/GaudiGSL/src/Lib/Interpolation.cpp @@ -1,5 +1,5 @@ #include "GaudiMath/Interpolation.h" -#include "GaudiKernel/ParsersFactory.h" +#include #include #include diff --git a/GaudiKernel/CMakeLists.txt b/GaudiKernel/CMakeLists.txt index 649aa4d04a..76b96533d8 100644 --- a/GaudiKernel/CMakeLists.txt +++ b/GaudiKernel/CMakeLists.txt @@ -61,7 +61,7 @@ endif() gaudi_add_library(GaudiKernel src/Lib/*.cpp ${extra_sources} LINK_LIBRARIES ${CMAKE_DL_LIBS} Boost ROOT TBB GaudiPluginService ${extra_libraries} INCLUDE_DIRS Boost ROOT TBB - PUBLIC_HEADERS GaudiKernel) + PUBLIC_HEADERS Gaudi GaudiKernel) #---Tests------------------------------------------------------------------- if( CPPUNIT_FOUND ) diff --git a/GaudiKernel/Gaudi/Parsers/CommonParsers.h b/GaudiKernel/Gaudi/Parsers/CommonParsers.h new file mode 100644 index 0000000000..b0f6f58492 --- /dev/null +++ b/GaudiKernel/Gaudi/Parsers/CommonParsers.h @@ -0,0 +1,541 @@ +#pragma once +// ============================================================================ +// Include files +// ============================================================================ +// STD & STL +// ============================================================================ +#include +#include +#include +#include +#include + +// ============================================================================ +#include "GaudiKernel/HistoDef.h" +#include "GaudiKernel/Map.h" +#include "GaudiKernel/StatusCode.h" +// ============================================================================ +#define PARSERS_DECL_FOR_SINGLE( Type ) GAUDI_API StatusCode parse( Type& result, const std::string& input ); + +#define PARSERS_DECL_FOR_PAIR( FirstType, SecondType ) \ + GAUDI_API StatusCode parse( std::pair& result, const std::string& input ); + +#define PARSERS_DECL_FOR_LIST( InnerType ) \ + GAUDI_API StatusCode parse( std::vector& result, const std::string& input ); +// ============================================================================ +/** @file + * The declaration of major parsing functions used e.g + * for (re)implementation of new extended properties see class Property + * These function also could be used in a different, much wider contex. + * all of them have the semantic: + * StatusCode parse ( TYPE& result , const std::string& input ) + * where input is the input string to be parsed, + * and result is the the result of parsing + * + * @code + * + * const std::string input = ... ; + * std::vector result ; + * + * // parse the input + * StatusCode sc = parse ( result , input ) ; + * if ( sc.isFailure() ) + * { + * // error here ... + * } + * std::cout << "vector size " << result.size() << std::endl ; + * + * @endcode + * + * @see Gaudi::Parsers::parse + * @see Property + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-12 + */ +// ============================================================================ +namespace Gaudi +{ + // ========================================================================== + class Histo1DDef; + // ========================================================================== + namespace Parsers + { + // ======================================================================== + /** parse the bool value + * @see Gaudi::Parsers::BoolGrammar + * @param result (output) boolean result + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-12 + */ + PARSERS_DECL_FOR_SINGLE( bool ) + // ======================================================================== + /** parse the char value + * + * @see Gaudi::Parsers::CharGrammar + * @param result (output) boolean result + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-12 + */ + PARSERS_DECL_FOR_SINGLE( char ) + /// @see Gaudi::Parsers::parser( char&, const std::string& ) + PARSERS_DECL_FOR_SINGLE( unsigned char ) + /// @see Gaudi::Parsers::parser( char&, const std::string& ) + PARSERS_DECL_FOR_SINGLE( signed char ) + // ======================================================================== + /** parse the int value + * + * @see Gaudi::Parsers::IntGrammar + * @param result (output) integer result + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + PARSERS_DECL_FOR_SINGLE( int ) + /// @see Gaudi::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE( short ) + /// @see Gaudi::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE( unsigned short ) + /// @see Gaudi::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE( unsigned int ) + /// @see Gaudi::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE( long ) + /// @see Gaudi::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE( unsigned long ) + /// @see Gaudi::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE( long long ) + /// @see Gaudi::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE( unsigned long long ) + // ======================================================================== + /** parse the double value + * + * @see Gaudi::Parsers::RealGrammar + * @param result (output) double result + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + PARSERS_DECL_FOR_SINGLE( double ) + /// @see Gaudi::Parsers::parser( double&, const std::string& ) + PARSERS_DECL_FOR_SINGLE( float ) + /// @see Gaudi::Parsers::parser( double&, const std::string& ) + PARSERS_DECL_FOR_SINGLE( long double ) + // ======================================================================== + /** parse the std::string value + * + * @see Gaudi::Parsers::StringGrammar + * @param result (output) string result + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + PARSERS_DECL_FOR_SINGLE( std::string ) + // ======================================================================== + + PARSERS_DECL_FOR_LIST( bool ) + PARSERS_DECL_FOR_LIST( char ) + PARSERS_DECL_FOR_LIST( unsigned char ) + PARSERS_DECL_FOR_LIST( signed char ) + + PARSERS_DECL_FOR_LIST( int ) + PARSERS_DECL_FOR_LIST( short ) + PARSERS_DECL_FOR_LIST( unsigned short ) + PARSERS_DECL_FOR_LIST( unsigned int ) + PARSERS_DECL_FOR_LIST( long ) + PARSERS_DECL_FOR_LIST( unsigned long ) + PARSERS_DECL_FOR_LIST( long long ) + PARSERS_DECL_FOR_LIST( unsigned long long ) + + PARSERS_DECL_FOR_LIST( double ) + PARSERS_DECL_FOR_LIST( float ) + PARSERS_DECL_FOR_LIST( long double ) + + PARSERS_DECL_FOR_LIST( std::string ) + // ======================================================================== + // Advanced parses + // ======================================================================== + /** parse the std::pair\ value + * + * @see Gaudi::Parsers::PairGrammar + * @see Gaudi::Parsers::RealGrammar + * @param result (output) pair of doubles + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + PARSERS_DECL_FOR_PAIR( double, double ) + // ======================================================================== + /** parse the std::pair\ value + * + * @see Gaudi::Parsers::PairGrammar + * @see Gaudi::Parsers::IntGrammar + * @param result (output) pair of integers + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + PARSERS_DECL_FOR_PAIR( int, int ) + // ======================================================================== + /** parse the std::vector\ \> value + * + * @see Gaudi::Parsers::VectorGrammar + * @see Gaudi::Parsers::PairGrammar + * @see Gaudi::Parsers::RealGrammar + * @param result (output) vector with pairs of doubles + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + GAUDI_API StatusCode parse( std::vector>& result, const std::string& input ); + // ======================================================================== + /** parse the std::vector\ \> value + * + * @see Gaudi::Parsers::VectorGrammar + * @see Gaudi::Parsers::PairGrammar + * @see Gaudi::Parsers::IntGrammar + * @param result (output) vector with pairs of int + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + GAUDI_API StatusCode parse( std::vector>& result, const std::string& input ); + // ======================================================================== + // vector< vector< TYPE > > + // ======================================================================== + /** parse the std::vector\ \> value + * + * @see Gaudi::Parsers::VectorGrammar + * @see Gaudi::Parsers::StringGrammar + * @param result (output) vector with vectors of strings + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + GAUDI_API StatusCode parse( std::vector>& result, const std::string& input ); + // ======================================================================== + /** parse the std::vector\ \> value + * + * @see Gaudi::Parsers::VectorGrammar + * @see Gaudi::Parsers::RealGrammar + * @param result (output) vector with vectors of doubles + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + GAUDI_API StatusCode parse( std::vector>& result, const std::string& input ); + // ======================================================================== + // map< TYPE, TYPE > + // ======================================================================== + /** parse the std::map\ value + * + * @see Gaudi::Parsers::MapGrammar + * @see Gaudi::Parsers::IntGrammar + * @param result (output) map with integer key and double value + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + GAUDI_API StatusCode parse( std::map& result, const std::string& input ); + // ======================================================================== + /** parse the std::map\ value + * + * @see Gaudi::Parsers::MapGrammar + * @see Gaudi::Parsers::IntGrammar + * @see Gaudi::Parsers::RealGrammar + * @param result (output) map with integer key and double value + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + GAUDI_API StatusCode parse( std::map& result, const std::string& input ); + // ======================================================================== + /** parse the std::map\ value + * + * @see Gaudi::Parsers::MapGrammar + * @see Gaudi::Parsers::StringGrammar + * @param result (output) map with string key and value + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + GAUDI_API StatusCode parse( std::map& result, const std::string& input ); + // ======================================================================== + /** parse the std::map\ value + * + * @see Gaudi::Parsers::MapGrammar + * @see Gaudi::Parsers::StringGrammar + * @see Gaudi::Parsers::IntGrammar + * @param result (output) map with string key and integer value + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + GAUDI_API StatusCode parse( std::map& result, const std::string& input ); + // ======================================================================== + /** parse the std::map\ value + * + * @see Gaudi::Parsers::MapGrammar + * @see Gaudi::Parsers::StringGrammar + * @see Gaudi::Parsers::RealGrammar + * @param result (output) map with string key and integer value + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + GAUDI_API StatusCode parse( std::map& result, const std::string& input ); + // ======================================================================== + /** parse the std::map\ \> + * value + * + * @see Gaudi::Parsers::MapGrammar + * @see Gaudi::Parsers::StringGrammar + * @see Gaudi::Parsers::VectorGrammar + * @param result (output) map with string value and + * vector of strings as value + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + GAUDI_API StatusCode parse( std::map>& result, const std::string& input ); + // ======================================================================== + /** parse the std::map\ \> value + * + * @see Gaudi::Parsers::MapGrammar + * @see Gaudi::Parsers::StringGrammar + * @see Gaudi::Parsers::VectorGrammar + * @see Gaudi::Parsers::IntGrammar + * @param result (output) map with string value and + * vector of integers as value + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + GAUDI_API StatusCode parse( std::map>& result, const std::string& input ); + // ======================================================================== + /** parse the std::map\ \> value + * + * @see Gaudi::Parsers::MapGrammar + * @see Gaudi::Parsers::StringGrammar + * @see Gaudi::Parsers::VectorGrammar + * @see Gaudi::Parsers::RealGrammar + * @param result (output) map with string value and + * vector of doubles as value + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + GAUDI_API StatusCode parse( std::map>& result, const std::string& input ); + // ======================================================================== + /** parse the std::map\ \> objects + * + * @see Gaudi::Parsers::MapGrammar + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @date 2007-12-06 + */ + GAUDI_API StatusCode parse( std::map& result, const std::string& input ); + // ======================================================================== + /** parse the std::map\ \> objects + * + * @see Gaudi::Parsers::MapGrammar + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @date 2007-12-06 + */ + GAUDI_API StatusCode parse( std::map& result, const std::string& input ); + // ======================================================================== + /** parse the std::map\ \> objects + * + * @see Gaudi::Parsers::MapGrammar + */ + GAUDI_API StatusCode parse( std::map& result, const std::string& input ); + // ======================================================================== + /** parse the GaudiUtils::Map\ objects + * + * @see Gaudi::Parsers::MapGrammar + */ + template + GAUDI_API StatusCode parse( GaudiUtils::Map& result, const std::string& input ) + { + return parse( (M&)result, input ); + } + // ======================================================================== + /** parse the pair expression (map-component) " 'name' :value" + * + * @code + * + * const std::string input = "'PackageName':GaudiKernel" ; + * std::string name ; + * std::string value ; + * StatusCode sc = Gaudi::Parsers::parse ( name , value , input ) ; + * if ( sc.isFailure() ) { ... } + * std::cout << "\tParsed name is " << name + * << "\tParsed value is " << value << std::endl + * @endcode + * + * @param name (output) the parsed name of the component, defined + * as 'name' or "name" before the column symbol ":", + * the leading and trailing blans are omitted + * @param value (output) the parsed value of the component, + * defined as everything after the column symbol ":" + * till the end of the string + * @param input (input) string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-12 + */ + GAUDI_API StatusCode parse( std::string& name, std::string& value, const std::string& input ); + // ======================================================================== + /** helper function, needed for implementation of "Histogram Property" + * @param histo the histogram description (output) + * @param input the string to be parsed + * @return status code + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @date 2007-09-17 + */ + GAUDI_API StatusCode parse( Gaudi::Histo1DDef& histo, const std::string& input ); + // ======================================================================== + /** helper function, needed for implementation of "Histogram Property" + * @param histos the map of the histogram descriptions (output) + * @param input the string to be parsed + * @return status code + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @date 2007-09-17 + */ + GAUDI_API StatusCode parse( std::map& histos, const std::string& input ); + // ======================================================================== + /** helper function, needed for implementation of map of pairs + * It is very useful construction for monitoring to + * represent the value and error or the allowed range for + * some parameter + * @param params the map of pair + * @param input the string to be parsed + * @return status code + * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @date 2009-05-19 + */ + GAUDI_API StatusCode parse( std::map>& params, const std::string& input ); + // ======================================================================== + /** parser function for C-arrays + * @param params C-array + * @param input the string to be parsed + * @return status code + * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl + * @date 2009-09-15 + */ + template + StatusCode parse( T ( &result )[N], const std::string& input ) + { + typedef std::vector _Vct; + // create the temporary vector + _Vct tmp; + StatusCode sc = parse( tmp, input ); + if ( sc.isFailure() ) { + return sc; + } // RETURN + if ( N != tmp.size() ) { + return StatusCode::FAILURE; + } // RETURN + // + std::copy( tmp.begin(), tmp.end(), result ); + // + return StatusCode::SUCCESS; // RETURN + } + // ======================================================================== + /** parser function for C-strings + * @param params C-string + * @param input the string to be parsed + * @return status code + * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl + * @date 2009-09-15 + */ + template + StatusCode parse( char ( &result )[N], const std::string& input ) + { + // clear the string + std::fill_n( result, N, ' ' ); + // create the temporary string + std::string tmp; + StatusCode sc = parse( tmp, input ); + if ( sc.isFailure() ) { + return sc; + } // RETURN + if ( N == tmp.size() ) { + std::copy( tmp.begin(), tmp.end(), result ); + } else if ( N + 2 == tmp.size() && ( '\'' == tmp[0] || '\"' == tmp[0] ) && ( tmp[0] == tmp[tmp.size() - 1] ) ) { + std::copy( tmp.begin() + 1, tmp.end() - 1, result ); + } else { + return StatusCode::FAILURE; + } + // + return StatusCode::SUCCESS; // RETURN + } + // ======================================================================== + } // end of namespace Gaudi::Parsers + // ========================================================================== +} // end of namespace Gaudi diff --git a/GaudiKernel/Gaudi/Parsers/Factory.h b/GaudiKernel/Gaudi/Parsers/Factory.h new file mode 100644 index 0000000000..c86982937f --- /dev/null +++ b/GaudiKernel/Gaudi/Parsers/Factory.h @@ -0,0 +1,60 @@ +#pragma once +// ============================================================================ +// Include files +// ============================================================================ +// STD & STL +// ============================================================================ +#include +#include +#include +// ============================================================================ +// Boost: +// ============================================================================ +#include +#include +// ============================================================================ +// Gaudi +// ============================================================================ +#include +#include +// ============================================================================ +namespace Gaudi +{ + namespace Parsers + { + // ======================================================================== + typedef std::string::const_iterator IteratorT; + // typedef boost::spirit::ascii::space_type Skipper; + typedef SkipperGrammar Skipper; + // ======================================================================== + template + inline StatusCode parse_( ResultT& result, const std::string& input ) + { + Skipper skipper; + typename Grammar_::Grammar g; + IteratorT iter = input.begin(), end = input.end(); + return ( qi::phrase_parse( iter, end, g, skipper, result ) && ( iter == end ) ? StatusCode::SUCCESS + : StatusCode::FAILURE ); + } + //========================================================================= + template <> + inline StatusCode parse_( std::string& result, const std::string& input ) + { + Skipper skipper; + Grammar_::Grammar g; + IteratorT iter = input.begin(), end = input.end(); + if ( !( qi::phrase_parse( iter, end, g, skipper, result ) && ( iter == end ) ) ) { + result = input; + } + //@attention always + return StatusCode::SUCCESS; + } + //========================================================================= + template + inline StatusCode parse( ResultT& result, const std::string& input ) + { + return parse_( result, input ); + } + //========================================================================= + } /* Parsers */ +} /* Gaudi */ diff --git a/GaudiKernel/Gaudi/Parsers/Grammars.h b/GaudiKernel/Gaudi/Parsers/Grammars.h new file mode 100644 index 0000000000..c4c104c5f6 --- /dev/null +++ b/GaudiKernel/Gaudi/Parsers/Grammars.h @@ -0,0 +1,611 @@ +#pragma once + +#ifdef __GNUC__ +#pragma GCC system_header +#endif +// ============================================================================ +// Include files +// ============================================================================ +// STD: +//============================================================================== +#include +#include +#include +#include +#include +#include +#include +#include +//============================================================================== +// Boost: +//============================================================================== +#include +#include +#include + +#include +#include + +#include +#include + +#include +//============================================================================== +// Gaudi: +//============================================================================== +#include "GaudiKernel/HashMap.h" +#include "GaudiKernel/HistoDef.h" +#include "GaudiKernel/Point3DTypes.h" +#include "GaudiKernel/Point4DTypes.h" +#include "GaudiKernel/StringKey.h" +#include "GaudiKernel/VectorMap.h" +//============================================================================== +namespace Gaudi +{ + namespace Parsers + { + //============================================================================== + // Namespace aliases: + //============================================================================== + namespace sp = boost::spirit; + namespace ph = boost::phoenix; + namespace qi = sp::qi; + namespace enc = sp::ascii; + namespace rep = sp::repository; + //============================================================================== + // Grammars + //============================================================================== + typedef std::string::const_iterator DefaultIterator; + typedef enc::space_type DefaultSkipper; + //============================================================================== + template + struct Grammar_ { + /* READ THIS IF YOUR COMPILE BREAKS ON THE FOLLOWING LINE + * + * To users: You have to ask developers to implement parser for your type T + * To developer: You have to implement and register Grammar for type T + * + */ + BOOST_MPL_ASSERT_MSG( false, GRAMMAR_FOR_TYPE_DOES_NOT_EXISTS, ( T ) ); + }; + +#define REGISTER_GRAMMAR( ResultType, GrammarName ) \ + template \ + struct Grammar_ { \ + typedef GrammarName Grammar; \ + } + //============================================================================== + template + struct SkipperGrammar : qi::grammar { + SkipperGrammar() : SkipperGrammar::base_type( comments ) + { + comments = enc::space | rep::confix( "/*", "*/" )[*( qi::char_ - "*/" )] | + rep::confix( "//", ( sp::eol | sp::eoi ) )[*( qi::char_ - ( sp::eol | sp::eoi ) )]; + } + qi::rule comments; + }; + //============================================================================== + template + struct StringGrammar : qi::grammar, Skipper> { + //------------------------------------------------------------------------------ + typedef std::string ResultT; + //------------------------------------------------------------------------------ + StringGrammar() : StringGrammar::base_type( str ) + { + begin_quote = enc::char_( "\"'" ); + quote = enc::char_( qi::_r1 ); + + str = qi::lexeme[begin_quote[qi::_a = qi::_1] > + *( ( enc::char_( '\\' ) >> quote( qi::_a ) )[qi::_val += qi::_a] | + ( enc::char_[qi::_val += qi::_1] - quote( qi::_a ) ) ) > quote( qi::_a )]; + } + //------------------------------------------------------------------------------ + qi::rule, Skipper> str; + qi::rule begin_quote; + qi::rule quote; + //------------------------------------------------------------------------------ + }; + REGISTER_GRAMMAR( std::string, StringGrammar ); + REGISTER_GRAMMAR( Gaudi::StringKey, StringGrammar ); + //============================================================================== + template + struct CharGrammar : qi::grammar { + typedef char ResultT; + CharGrammar() : CharGrammar::base_type( ch ) + { + ch = qi::int_parser() | '\'' >> ( qi::char_ - '\'' ) >> '\''; + } + qi::rule ch; + }; + REGISTER_GRAMMAR( char, CharGrammar ); + //============================================================================== + template + struct BoolGrammar : qi::grammar { + typedef bool ResultT; + BoolGrammar() : BoolGrammar::base_type( boolean_literal ) + { + boolean_literal = ( qi::lit( "true" ) | "True" | "TRUE" | "1" )[qi::_val = true] | + ( qi::lit( "false" ) | "False" | "FALSE" | "0" )[qi::_val = false]; + } + qi::rule boolean_literal; + }; + REGISTER_GRAMMAR( bool, BoolGrammar ); + //============================================================================== + template + struct IntGrammar : qi::grammar { + typedef RT ResultT; + IntGrammar() : IntGrammar::base_type( integer ) + { + integer = qi::int_parser()[qi::_val = qi::_1] >> -qi::no_case[qi::char_( 'L' )]; + } + qi::rule integer; + }; + // ---------------------------------------------------------------------------- + // Register IntGrammar: + // ---------------------------------------------------------------------------- + template + struct Grammar_>::type> { + typedef IntGrammar Grammar; + }; + //============================================================================== + template + struct RealGrammar : qi::grammar { + typedef RT ResultT; + RealGrammar() : RealGrammar::base_type( real ) { real = qi::real_parser(); } + qi::rule real; + }; + // ---------------------------------------------------------------------------- + // Register RealGrammar: + // ---------------------------------------------------------------------------- + template + struct Grammar_>::type> { + typedef RealGrammar Grammar; + }; + //============================================================================== + // Grammar for std::tuples + //============================================================================== + template + struct tuple_remove_first_type { + }; + + template + struct tuple_get_first_type { + }; + + template + struct tuple_remove_first_type> { + typedef std::tuple type; + }; + + template + struct tuple_get_first_type> { + typedef T type; + }; + + // ---------------------------------------------------------------------------- + + template + struct TupleInnerGrammar + : qi::grammar::type>, Skipper> { + //--------------------------------------------------------------------------- + typedef TupleT ResultT; + typedef typename tuple_remove_first_type::type TailT; + typedef typename tuple_get_first_type::type HeadT; + //--------------------------------------------------------------------------- + struct Operations { + //---------------------------------------------------------------------- + + void operator()( ResultT& res, HeadT& head, TailT& tail ) const + { + res = std::tuple_cat( std::tuple( head ), tail ); + } + //---------------------------------------------------------------------- + }; + //--------------------------------------------------------------------------- + TupleInnerGrammar() : TupleInnerGrammar::base_type( tup ) + { + tup = grHead[qi::_a = qi::_1] >> ',' >> grLast[op( qi::_val, qi::_a, qi::_1 )]; + } + + TupleInnerGrammar grLast; + typename Grammar_::Grammar grHead; + + qi::rule, Skipper> tup; + ph::function op; + }; + + template + struct TupleInnerGrammar : qi::grammar { + //--------------------------------------------------------------------------- + typedef TupleT ResultT; + // typedef typename ResultT::value_type Tuple1T; + //--------------------------------------------------------------------------- + struct Operations { + //--------------------------------------------------------------------- + void operator()( ResultT& res, const typename std::tuple_element<0, ResultT>::type& val ) const + { + res = ResultT(); + std::get<0>( res ) = val; + } + //---------------------------------------------------------------------- + }; + //--------------------------------------------------------------------------- + TupleInnerGrammar() : TupleInnerGrammar::base_type( tup ) { tup = grFirst[op( qi::_val, qi::_1 )]; } + + typename Grammar_::type, Skipper>::Grammar grFirst; + + qi::rule tup; + ph::function op; + }; + + // ---------------------------------------------------------------------------- + template + struct TupleGrammar : qi::grammar, Skipper> { + typedef TupleT ResultT; + TupleGrammar() : TupleGrammar::base_type( tup ) + { + begin = enc::char_( '[' )[qi::_val = ']'] | enc::char_( '(' )[qi::_val = ')']; + end = enc::char_( qi::_r1 ); + + tup = begin[qi::_a = qi::_1] >> grTuple[qi::_val = qi::_1] >> end( qi::_a ); + } + + qi::rule begin; + qi::rule end; + qi::rule, Skipper> tup; + TupleInnerGrammar grTuple; + }; + + // ----------------------------------------------------------------------------- + // Register TupleGrammar for std::tuple: + // ---------------------------------------------------------------------------- + template + struct Grammar_, Skipper> { + typedef TupleGrammar, sizeof...( Args ), Skipper> Grammar; + }; + //============================================================================== + template + struct VectorGrammar : qi::grammar, Skipper> { + //------------------------------------------------------------------------------ + typedef VectorT ResultT; + //------------------------------------------------------------------------------ + VectorGrammar() : VectorGrammar::base_type( vec ) + { + begin = + enc::char_( '[' )[qi::_val = ']'] | enc::char_( '{' )[qi::_val = '}'] | enc::char_( '(' )[qi::_val = ')']; + end = enc::char_( qi::_r1 ); + list = elementGrammar % ','; + vec = begin[qi::_a = qi::_1] >> -list[qi::_val = qi::_1] >> end( qi::_a ); + } + // ---------------------------------------------------------------------------- + typename Grammar_::Grammar elementGrammar; + qi::rule begin; + qi::rule end; + + qi::rule, Skipper> vec; + qi::rule list; + // ---------------------------------------------------------------------------- + }; + // ---------------------------------------------------------------------------- + // Register VectorGrammar for std::vector: + // ---------------------------------------------------------------------------- + template + struct Grammar_, Skipper> { + typedef VectorGrammar, Skipper> Grammar; + }; + // ---------------------------------------------------------------------------- + // Register VectorGrammar for std::list: + // ---------------------------------------------------------------------------- + template + struct Grammar_, Skipper> { + typedef VectorGrammar, Skipper> Grammar; + }; + // ---------------------------------------------------------------------------- + // Register VectorGrammar for std::set: + // ---------------------------------------------------------------------------- + template + struct Grammar_, Skipper> { + typedef VectorGrammar, Skipper> Grammar; + }; + // ---------------------------------------------------------------------------- + // Register VectorGrammar for std::unordered_set: + // ---------------------------------------------------------------------------- + template + struct Grammar_, Skipper> { + typedef VectorGrammar, Skipper> Grammar; + }; + + //============================================================================== + template + struct PairGrammar : qi::grammar, Skipper> { + //------------------------------------------------------------------------------ + typedef PairT ResultT; + typedef typename PairT::first_type first_type; + typedef typename PairT::second_type second_type; + //------------------------------------------------------------------------------ + struct first { + }; + struct second { + }; + //------------------------------------------------------------------------------ + PairGrammar() : PairGrammar( "," ) {} + PairGrammar( const std::string& delimeter ) : PairGrammar::base_type( pair ) + { + begin = enc::char_( '(' )[qi::_val = ')'] | enc::char_( '[' )[qi::_val = ']']; + end = qi::char_( qi::_r1 ); + pair = begin[qi::_a = qi::_1] >> pair_in[qi::_val = qi::_1] >> end( qi::_a ); + pair_in = key >> qi::lit( delimeter ) >> value; + } + // ---------------------------------------------------------------------------- + typename Grammar_::Grammar key; + typename Grammar_::Grammar value; + qi::rule begin; + qi::rule end; + qi::rule, Skipper> pair; + qi::rule pair_in; + // ph::function op; + // ---------------------------------------------------------------------------- + }; // END PairGrammar + // ---------------------------------------------------------------------------- + // Register PairGrammar: + // ---------------------------------------------------------------------------- + template + struct Grammar_, Skipper> { + typedef PairGrammar, Skipper> Grammar; + }; + // ============================================================================ + template + struct MapGrammar : qi::grammar { + //------------------------------------------------------------------------------ + typedef MapT ResultT; + typedef typename MapT::key_type KeyT; + typedef typename MapT::mapped_type MappedT; + typedef std::pair PairT; + + typedef std::vector VectorPairT; + //------------------------------------------------------------------------------ + struct tag_key { + }; + struct tag_mapped { + }; + struct Operations { + //---------------------------------------------------------------------- + void operator()( ResultT& res, const VectorPairT& vec ) const + { + for ( auto cur = vec.begin(); cur != vec.end(); ++cur ) { + res.insert( *cur ); + } + } + void operator()( PairT& res, const KeyT& key, tag_key ) const { res.first = key; } + void operator()( PairT& res, const MappedT& value, tag_mapped ) const { res.second = value; } + //---------------------------------------------------------------------- + }; + //------------------------------------------------------------------------------ + MapGrammar() : MapGrammar::base_type( map ) + { + pair = key[op( qi::_val, qi::_1, tag_key() )] > ( qi::lit( ':' ) | '=' ) > + value[op( qi::_val, qi::_1, tag_mapped() )]; + list = -( pair % enc::char_( ',' ) ); + map = ( ( '[' >> list >> ']' ) | ( '{' >> list >> '}' ) )[op( qi::_val, qi::_1 )]; + } + // ---------------------------------------------------------------------------- + typename Grammar_::Grammar key; + typename Grammar_::Grammar value; + qi::rule pair; + qi::rule list; + qi::rule map; + ph::function op; + // ---------------------------------------------------------------------------- + }; + // ---------------------------------------------------------------------------- + // Register MapGrammar for std::map: + // ---------------------------------------------------------------------------- + template + struct Grammar_, Skipper> { + typedef MapGrammar, Skipper> Grammar; + }; + // ---------------------------------------------------------------------------- + // Register MapGrammar for std::unordered_map: + // ---------------------------------------------------------------------------- + template + struct Grammar_, Skipper> { + typedef MapGrammar, Skipper> Grammar; + }; + // ---------------------------------------------------------------------------- + // Register MapGrammar for GaudiUtils::VectorMap: + // ---------------------------------------------------------------------------- + template + struct Grammar_, Skipper> { + typedef MapGrammar, Skipper> Grammar; + }; + // ============================================================================ + template + struct Pnt3DGrammar : qi::grammar { + typedef PointT ResultT; + typedef typename PointT::Scalar Scalar; + // ---------------------------------------------------------------------------- + struct Operations { + void operator()( ResultT& res, const Scalar& scalar, const char xyz ) const + { + switch ( xyz ) { + case 'x': + res.SetX( scalar ); + break; + case 'y': + res.SetY( scalar ); + break; + case 'z': + res.SetZ( scalar ); + break; + default: + break; + } + } + }; // Operations + // ---------------------------------------------------------------------------- + Pnt3DGrammar() : Pnt3DGrammar::base_type( point ) + { + point = list | ( '(' >> list >> ')' ) | ( '[' >> list >> ']' ); + list = -( enc::no_case[qi::lit( "x" ) | qi::lit( "px" )] >> ':' ) >> scalar[op( qi::_val, qi::_1, 'x' )] >> + ',' >> -( enc::no_case[qi::lit( "y" ) | qi::lit( "py" )] >> ':' ) >> + scalar[op( qi::_val, qi::_1, 'y' )] >> ',' >> + -( enc::no_case[qi::lit( "z" ) | qi::lit( "pz" )] >> ':' ) >> scalar[op( qi::_val, qi::_1, 'z' )]; + } + // ---------------------------------------------------------------------------- + qi::rule point, list; + typename Grammar_::Grammar scalar; + ph::function op; + // ---------------------------------------------------------------------------- + }; // Pnt3DGrammar + // ---------------------------------------------------------------------------- + // Register Pnt3DGrammar for ROOT::Math::PositionVector3D: + // ---------------------------------------------------------------------------- + template + struct Grammar_, Skipper> { + typedef Pnt3DGrammar, Skipper> Grammar; + }; + // ---------------------------------------------------------------------------- + // Register Pnt3DGrammar for ROOT::Math::DisplacementVector3D: + // ---------------------------------------------------------------------------- + template + struct Grammar_, Skipper> { + typedef Pnt3DGrammar, Skipper> Grammar; + }; + // ============================================================================ + template + struct Pnt4DGrammar : qi::grammar { + typedef PointT ResultT; + typedef typename PointT::Scalar ScalarT; + //----------------------------------------------------------------------------- + struct Operations { + + void operator()( ResultT& res, const ScalarT& scalar, const char xyz ) const + { + switch ( xyz ) { + case 'x': + res.SetPx( scalar ); + break; + case 'y': + res.SetPy( scalar ); + break; + case 'z': + res.SetPz( scalar ); + break; + case 'e': + res.SetE( scalar ); + break; + default: + break; + } + } + void operator()( ResultT& res, const ResultT& xyz ) const + { + res.SetPx( xyz.Px() ); + res.SetPy( xyz.Py() ); + res.SetPz( xyz.Pz() ); + } + }; // Operations + // ---------------------------------------------------------------------------- + Pnt4DGrammar() : Pnt4DGrammar::base_type( point4d ) + { + point4d = list4d | ( '(' >> list4d >> ')' ) | ( '[' >> list4d >> ']' ); + list4d = ( point3d[op( qi::_val, qi::_1 )] >> enc::char_( ";," ) >> e[op( qi::_val, qi::_1, 'e' )] ) | + ( e[op( qi::_val, qi::_1, 'e' )] >> enc::char_( ";," ) >> point3d[op( qi::_val, qi::_1 )] ); + e = -( enc::no_case[enc::char_( "te" )] >> ':' ) >> scalar[qi::_val = qi::_1]; + + point3d = list3d | ( '(' >> list3d >> ')' ) | ( '[' >> list3d >> ']' ); + list3d = -( enc::no_case[qi::lit( "x" ) | qi::lit( "px" )] >> ':' ) >> scalar[op( qi::_val, qi::_1, 'x' )] >> + ',' >> -( enc::no_case[qi::lit( "y" ) | qi::lit( "py" )] >> ':' ) >> + scalar[op( qi::_val, qi::_1, 'y' )] >> ',' >> + -( enc::no_case[qi::lit( "z" ) | qi::lit( "pz" )] >> ':' ) >> scalar[op( qi::_val, qi::_1, 'z' )]; + } + // ---------------------------------------------------------------------------- + qi::rule point3d, point4d, list3d, list4d; + qi::rule e; + typename Grammar_::Grammar scalar; + ph::function op; + // ---------------------------------------------------------------------------- + }; // Pnt4DGrammar + // ---------------------------------------------------------------------------- + // Register Pnt4DGrammar for ROOT::Math::LorentzVector: + // ---------------------------------------------------------------------------- + template + struct Grammar_, Skipper> { + typedef Pnt4DGrammar, Skipper> Grammar; + }; + // ============================================================================ + template + struct Histo1DGrammar : qi::grammar, Skipper> { + typedef Gaudi::Histo1DDef ResultT; + // ---------------------------------------------------------------------------- + struct Operations { + void operator()( ResultT& res, const std::string& title ) const { res.setTitle( title ); } + void operator()( ResultT& res, const double& val, const char lh ) const + { + switch ( lh ) { + case 'l': + res.setLowEdge( val ); + break; + case 'h': + res.setHighEdge( val ); + break; + default: + break; + } + } + void operator()( ResultT& res, int val ) const { res.setBins( val ); } + void operator()( ResultT& res ) const {} + }; // Operations + // ---------------------------------------------------------------------------- + Histo1DGrammar() : Histo1DGrammar::base_type( hist ) + { + val1 = title[op( qi::_val, qi::_1 )] >> ',' >> qi::double_[op( qi::_val, qi::_1, 'l' )] >> ',' >> + qi::double_[op( qi::_val, qi::_1, 'h' )] >> -( ',' >> qi::int_[op( qi::_val, qi::_1 )] ); + val2 = qi::double_[op( qi::_val, qi::_1, 'l' )] >> ',' >> qi::double_[op( qi::_val, qi::_1, 'h' )] >> ',' >> + title[op( qi::_val, qi::_1 )] >> -( ',' >> qi::int_[op( qi::_val, qi::_1 )] ); + val3 = qi::double_[op( qi::_val, qi::_1, 'l' )] >> ',' >> qi::double_[op( qi::_val, qi::_1, 'h' )] >> + -( ',' >> title[op( qi::_val, qi::_1 )] ) >> -( ',' >> qi::int_[op( qi::_val, qi::_1 )] ); + begin = enc::char_( '[' )[qi::_val = ']'] | enc::char_( '(' )[qi::_val = ')']; + end = enc::char_( qi::_r1 ); + hist = begin[qi::_a = qi::_1] >> ( val1 | val2 | val3 )[qi::_val = qi::_1] >> end( qi::_a ); + } + // ---------------------------------------------------------------------------- + qi::rule, Skipper> hist; + qi::rule val1, val2, val3; + qi::rule begin; + qi::rule end; + StringGrammar title; + ph::function op; + // ---------------------------------------------------------------------------- + }; // Histo1DGrammar + // ---------------------------------------------------------------------------- + REGISTER_GRAMMAR( Gaudi::Histo1DDef, Histo1DGrammar ); + // ============================================================================ + template + struct KeyValueGrammar : qi::grammar(), Skipper> { + //------------------------------------------------------------------------------ + typedef std::pair ResultT; + //------------------------------------------------------------------------------ + struct first { + }; + struct second { + }; + + KeyValueGrammar() : KeyValueGrammar::base_type( pair ) + { + //------------------------------------------------------------------------------ + pair = gstring >> ":" >> +enc::char_; + } + // ---------------------------------------------------------------------------- + StringGrammar gstring; + qi::rule pair; + // ---------------------------------------------------------------------------- + }; // END KeyValueGrammar + // We don't register KeyalueGrammar because it's a special parser + // ============================================================================ + } +} // Gaudi::Parsers diff --git a/GaudiKernel/Gaudi/Parsers/InputData.h b/GaudiKernel/Gaudi/Parsers/InputData.h new file mode 100644 index 0000000000..08816fc164 --- /dev/null +++ b/GaudiKernel/Gaudi/Parsers/InputData.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +namespace Gaudi +{ + namespace Parsers + { + /// Helper class to enable ADL for parsers + struct InputData : std::string { + InputData( const std::string& s ) : std::string{s} {} + using std::string::string; + using std::string::operator=; + }; + } +} diff --git a/GaudiKernel/GaudiKernel/BoostArrayAsProperty.h b/GaudiKernel/GaudiKernel/BoostArrayAsProperty.h index 873d19446c..6a2f02a3cf 100644 --- a/GaudiKernel/GaudiKernel/BoostArrayAsProperty.h +++ b/GaudiKernel/GaudiKernel/BoostArrayAsProperty.h @@ -59,7 +59,7 @@ namespace Gaudi // ============================================================================ // GaudiKernel // ============================================================================ -#include "GaudiKernel/Parsers.h" +#include // ============================================================================ namespace Gaudi { diff --git a/GaudiKernel/GaudiKernel/GrammarsV2.h b/GaudiKernel/GaudiKernel/GrammarsV2.h index f93594b0e4..c6eaa02b4e 100644 --- a/GaudiKernel/GaudiKernel/GrammarsV2.h +++ b/GaudiKernel/GaudiKernel/GrammarsV2.h @@ -1,614 +1,3 @@ -// ============================================================================ -#ifndef GAUDIKERNEL_GRAMMARSV2_H -#define GAUDIKERNEL_GRAMMARSV2_H 1 -#ifdef __GNUC__ -#pragma GCC system_header -#endif -// ============================================================================ -// Include files -// ============================================================================ -// STD: -//============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -//============================================================================== -// Boost: -//============================================================================== -#include -#include -#include +#pragma once -#include -#include - -#include -#include - -#include -//============================================================================== -// Gaudi: -//============================================================================== -#include "GaudiKernel/HashMap.h" -#include "GaudiKernel/HistoDef.h" -#include "GaudiKernel/Point3DTypes.h" -#include "GaudiKernel/Point4DTypes.h" -#include "GaudiKernel/StringKey.h" -#include "GaudiKernel/VectorMap.h" -//============================================================================== -namespace Gaudi -{ - namespace Parsers - { - //============================================================================== - // Namespace aliases: - //============================================================================== - namespace sp = boost::spirit; - namespace ph = boost::phoenix; - namespace qi = sp::qi; - namespace enc = sp::ascii; - namespace rep = sp::repository; - //============================================================================== - // Grammars - //============================================================================== - typedef std::string::const_iterator DefaultIterator; - typedef enc::space_type DefaultSkipper; - //============================================================================== - template - struct Grammar_ { - /* READ THIS IF YOUR COMPILE BREAKS ON THE FOLLOWING LINE - * - * To users: You have to ask developers to implement parser for your type T - * To developer: You have to implement and register Grammar for type T - * - */ - BOOST_MPL_ASSERT_MSG( false, GRAMMAR_FOR_TYPE_DOES_NOT_EXISTS, ( T ) ); - }; - -#define REGISTER_GRAMMAR( ResultType, GrammarName ) \ - template \ - struct Grammar_ { \ - typedef GrammarName Grammar; \ - } - //============================================================================== - template - struct SkipperGrammar : qi::grammar { - SkipperGrammar() : SkipperGrammar::base_type( comments ) - { - comments = enc::space | rep::confix( "/*", "*/" )[*( qi::char_ - "*/" )] | - rep::confix( "//", ( sp::eol | sp::eoi ) )[*( qi::char_ - ( sp::eol | sp::eoi ) )]; - } - qi::rule comments; - }; - //============================================================================== - template - struct StringGrammar : qi::grammar, Skipper> { - //------------------------------------------------------------------------------ - typedef std::string ResultT; - //------------------------------------------------------------------------------ - StringGrammar() : StringGrammar::base_type( str ) - { - begin_quote = enc::char_( "\"'" ); - quote = enc::char_( qi::_r1 ); - - str = qi::lexeme[begin_quote[qi::_a = qi::_1] > - *( ( enc::char_( '\\' ) >> quote( qi::_a ) )[qi::_val += qi::_a] | - ( enc::char_[qi::_val += qi::_1] - quote( qi::_a ) ) ) > quote( qi::_a )]; - } - //------------------------------------------------------------------------------ - qi::rule, Skipper> str; - qi::rule begin_quote; - qi::rule quote; - //------------------------------------------------------------------------------ - }; - REGISTER_GRAMMAR( std::string, StringGrammar ); - REGISTER_GRAMMAR( Gaudi::StringKey, StringGrammar ); - //============================================================================== - template - struct CharGrammar : qi::grammar { - typedef char ResultT; - CharGrammar() : CharGrammar::base_type( ch ) - { - ch = qi::int_parser() | '\'' >> ( qi::char_ - '\'' ) >> '\''; - } - qi::rule ch; - }; - REGISTER_GRAMMAR( char, CharGrammar ); - //============================================================================== - template - struct BoolGrammar : qi::grammar { - typedef bool ResultT; - BoolGrammar() : BoolGrammar::base_type( boolean_literal ) - { - boolean_literal = ( qi::lit( "true" ) | "True" | "TRUE" | "1" )[qi::_val = true] | - ( qi::lit( "false" ) | "False" | "FALSE" | "0" )[qi::_val = false]; - } - qi::rule boolean_literal; - }; - REGISTER_GRAMMAR( bool, BoolGrammar ); - //============================================================================== - template - struct IntGrammar : qi::grammar { - typedef RT ResultT; - IntGrammar() : IntGrammar::base_type( integer ) - { - integer = qi::int_parser()[qi::_val = qi::_1] >> -qi::no_case[qi::char_( 'L' )]; - } - qi::rule integer; - }; - // ---------------------------------------------------------------------------- - // Register IntGrammar: - // ---------------------------------------------------------------------------- - template - struct Grammar_>::type> { - typedef IntGrammar Grammar; - }; - //============================================================================== - template - struct RealGrammar : qi::grammar { - typedef RT ResultT; - RealGrammar() : RealGrammar::base_type( real ) { real = qi::real_parser(); } - qi::rule real; - }; - // ---------------------------------------------------------------------------- - // Register RealGrammar: - // ---------------------------------------------------------------------------- - template - struct Grammar_>::type> { - typedef RealGrammar Grammar; - }; - //============================================================================== - // Grammar for std::tuples - //============================================================================== - template - struct tuple_remove_first_type { - }; - - template - struct tuple_get_first_type { - }; - - template - struct tuple_remove_first_type> { - typedef std::tuple type; - }; - - template - struct tuple_get_first_type> { - typedef T type; - }; - - // ---------------------------------------------------------------------------- - - template - struct TupleInnerGrammar - : qi::grammar::type>, Skipper> { - //--------------------------------------------------------------------------- - typedef TupleT ResultT; - typedef typename tuple_remove_first_type::type TailT; - typedef typename tuple_get_first_type::type HeadT; - //--------------------------------------------------------------------------- - struct Operations { - //---------------------------------------------------------------------- - - void operator()( ResultT& res, HeadT& head, TailT& tail ) const - { - res = std::tuple_cat( std::tuple( head ), tail ); - } - //---------------------------------------------------------------------- - }; - //--------------------------------------------------------------------------- - TupleInnerGrammar() : TupleInnerGrammar::base_type( tup ) - { - tup = grHead[qi::_a = qi::_1] >> ',' >> grLast[op( qi::_val, qi::_a, qi::_1 )]; - } - - TupleInnerGrammar grLast; - typename Grammar_::Grammar grHead; - - qi::rule, Skipper> tup; - ph::function op; - }; - - template - struct TupleInnerGrammar : qi::grammar { - //--------------------------------------------------------------------------- - typedef TupleT ResultT; - // typedef typename ResultT::value_type Tuple1T; - //--------------------------------------------------------------------------- - struct Operations { - //--------------------------------------------------------------------- - void operator()( ResultT& res, const typename std::tuple_element<0, ResultT>::type& val ) const - { - res = ResultT(); - std::get<0>( res ) = val; - } - //---------------------------------------------------------------------- - }; - //--------------------------------------------------------------------------- - TupleInnerGrammar() : TupleInnerGrammar::base_type( tup ) { tup = grFirst[op( qi::_val, qi::_1 )]; } - - typename Grammar_::type, Skipper>::Grammar grFirst; - - qi::rule tup; - ph::function op; - }; - - // ---------------------------------------------------------------------------- - template - struct TupleGrammar : qi::grammar, Skipper> { - typedef TupleT ResultT; - TupleGrammar() : TupleGrammar::base_type( tup ) - { - begin = enc::char_( '[' )[qi::_val = ']'] | enc::char_( '(' )[qi::_val = ')']; - end = enc::char_( qi::_r1 ); - - tup = begin[qi::_a = qi::_1] >> grTuple[qi::_val = qi::_1] >> end( qi::_a ); - } - - qi::rule begin; - qi::rule end; - qi::rule, Skipper> tup; - TupleInnerGrammar grTuple; - }; - - // ----------------------------------------------------------------------------- - // Register TupleGrammar for std::tuple: - // ---------------------------------------------------------------------------- - template - struct Grammar_, Skipper> { - typedef TupleGrammar, sizeof...( Args ), Skipper> Grammar; - }; - //============================================================================== - template - struct VectorGrammar : qi::grammar, Skipper> { - //------------------------------------------------------------------------------ - typedef VectorT ResultT; - //------------------------------------------------------------------------------ - VectorGrammar() : VectorGrammar::base_type( vec ) - { - begin = - enc::char_( '[' )[qi::_val = ']'] | enc::char_( '{' )[qi::_val = '}'] | enc::char_( '(' )[qi::_val = ')']; - end = enc::char_( qi::_r1 ); - list = elementGrammar % ','; - vec = begin[qi::_a = qi::_1] >> -list[qi::_val = qi::_1] >> end( qi::_a ); - } - // ---------------------------------------------------------------------------- - typename Grammar_::Grammar elementGrammar; - qi::rule begin; - qi::rule end; - - qi::rule, Skipper> vec; - qi::rule list; - // ---------------------------------------------------------------------------- - }; - // ---------------------------------------------------------------------------- - // Register VectorGrammar for std::vector: - // ---------------------------------------------------------------------------- - template - struct Grammar_, Skipper> { - typedef VectorGrammar, Skipper> Grammar; - }; - // ---------------------------------------------------------------------------- - // Register VectorGrammar for std::list: - // ---------------------------------------------------------------------------- - template - struct Grammar_, Skipper> { - typedef VectorGrammar, Skipper> Grammar; - }; - // ---------------------------------------------------------------------------- - // Register VectorGrammar for std::set: - // ---------------------------------------------------------------------------- - template - struct Grammar_, Skipper> { - typedef VectorGrammar, Skipper> Grammar; - }; - // ---------------------------------------------------------------------------- - // Register VectorGrammar for std::unordered_set: - // ---------------------------------------------------------------------------- - template - struct Grammar_, Skipper> { - typedef VectorGrammar, Skipper> Grammar; - }; - - //============================================================================== - template - struct PairGrammar : qi::grammar, Skipper> { - //------------------------------------------------------------------------------ - typedef PairT ResultT; - typedef typename PairT::first_type first_type; - typedef typename PairT::second_type second_type; - //------------------------------------------------------------------------------ - struct first { - }; - struct second { - }; - //------------------------------------------------------------------------------ - PairGrammar() : PairGrammar( "," ) {} - PairGrammar( const std::string& delimeter ) : PairGrammar::base_type( pair ) - { - begin = enc::char_( '(' )[qi::_val = ')'] | enc::char_( '[' )[qi::_val = ']']; - end = qi::char_( qi::_r1 ); - pair = begin[qi::_a = qi::_1] >> pair_in[qi::_val = qi::_1] >> end( qi::_a ); - pair_in = key >> qi::lit( delimeter ) >> value; - } - // ---------------------------------------------------------------------------- - typename Grammar_::Grammar key; - typename Grammar_::Grammar value; - qi::rule begin; - qi::rule end; - qi::rule, Skipper> pair; - qi::rule pair_in; - // ph::function op; - // ---------------------------------------------------------------------------- - }; // END PairGrammar - // ---------------------------------------------------------------------------- - // Register PairGrammar: - // ---------------------------------------------------------------------------- - template - struct Grammar_, Skipper> { - typedef PairGrammar, Skipper> Grammar; - }; - // ============================================================================ - template - struct MapGrammar : qi::grammar { - //------------------------------------------------------------------------------ - typedef MapT ResultT; - typedef typename MapT::key_type KeyT; - typedef typename MapT::mapped_type MappedT; - typedef std::pair PairT; - - typedef std::vector VectorPairT; - //------------------------------------------------------------------------------ - struct tag_key { - }; - struct tag_mapped { - }; - struct Operations { - //---------------------------------------------------------------------- - void operator()( ResultT& res, const VectorPairT& vec ) const - { - for ( auto cur = vec.begin(); cur != vec.end(); ++cur ) { - res.insert( *cur ); - } - } - void operator()( PairT& res, const KeyT& key, tag_key ) const { res.first = key; } - void operator()( PairT& res, const MappedT& value, tag_mapped ) const { res.second = value; } - //---------------------------------------------------------------------- - }; - //------------------------------------------------------------------------------ - MapGrammar() : MapGrammar::base_type( map ) - { - pair = key[op( qi::_val, qi::_1, tag_key() )] > ( qi::lit( ':' ) | '=' ) > - value[op( qi::_val, qi::_1, tag_mapped() )]; - list = -( pair % enc::char_( ',' ) ); - map = ( ( '[' >> list >> ']' ) | ( '{' >> list >> '}' ) )[op( qi::_val, qi::_1 )]; - } - // ---------------------------------------------------------------------------- - typename Grammar_::Grammar key; - typename Grammar_::Grammar value; - qi::rule pair; - qi::rule list; - qi::rule map; - ph::function op; - // ---------------------------------------------------------------------------- - }; - // ---------------------------------------------------------------------------- - // Register MapGrammar for std::map: - // ---------------------------------------------------------------------------- - template - struct Grammar_, Skipper> { - typedef MapGrammar, Skipper> Grammar; - }; - // ---------------------------------------------------------------------------- - // Register MapGrammar for std::unordered_map: - // ---------------------------------------------------------------------------- - template - struct Grammar_, Skipper> { - typedef MapGrammar, Skipper> Grammar; - }; - // ---------------------------------------------------------------------------- - // Register MapGrammar for GaudiUtils::VectorMap: - // ---------------------------------------------------------------------------- - template - struct Grammar_, Skipper> { - typedef MapGrammar, Skipper> Grammar; - }; - // ============================================================================ - template - struct Pnt3DGrammar : qi::grammar { - typedef PointT ResultT; - typedef typename PointT::Scalar Scalar; - // ---------------------------------------------------------------------------- - struct Operations { - void operator()( ResultT& res, const Scalar& scalar, const char xyz ) const - { - switch ( xyz ) { - case 'x': - res.SetX( scalar ); - break; - case 'y': - res.SetY( scalar ); - break; - case 'z': - res.SetZ( scalar ); - break; - default: - break; - } - } - }; // Operations - // ---------------------------------------------------------------------------- - Pnt3DGrammar() : Pnt3DGrammar::base_type( point ) - { - point = list | ( '(' >> list >> ')' ) | ( '[' >> list >> ']' ); - list = -( enc::no_case[qi::lit( "x" ) | qi::lit( "px" )] >> ':' ) >> scalar[op( qi::_val, qi::_1, 'x' )] >> - ',' >> -( enc::no_case[qi::lit( "y" ) | qi::lit( "py" )] >> ':' ) >> - scalar[op( qi::_val, qi::_1, 'y' )] >> ',' >> - -( enc::no_case[qi::lit( "z" ) | qi::lit( "pz" )] >> ':' ) >> scalar[op( qi::_val, qi::_1, 'z' )]; - } - // ---------------------------------------------------------------------------- - qi::rule point, list; - typename Grammar_::Grammar scalar; - ph::function op; - // ---------------------------------------------------------------------------- - }; // Pnt3DGrammar - // ---------------------------------------------------------------------------- - // Register Pnt3DGrammar for ROOT::Math::PositionVector3D: - // ---------------------------------------------------------------------------- - template - struct Grammar_, Skipper> { - typedef Pnt3DGrammar, Skipper> Grammar; - }; - // ---------------------------------------------------------------------------- - // Register Pnt3DGrammar for ROOT::Math::DisplacementVector3D: - // ---------------------------------------------------------------------------- - template - struct Grammar_, Skipper> { - typedef Pnt3DGrammar, Skipper> Grammar; - }; - // ============================================================================ - template - struct Pnt4DGrammar : qi::grammar { - typedef PointT ResultT; - typedef typename PointT::Scalar ScalarT; - //----------------------------------------------------------------------------- - struct Operations { - - void operator()( ResultT& res, const ScalarT& scalar, const char xyz ) const - { - switch ( xyz ) { - case 'x': - res.SetPx( scalar ); - break; - case 'y': - res.SetPy( scalar ); - break; - case 'z': - res.SetPz( scalar ); - break; - case 'e': - res.SetE( scalar ); - break; - default: - break; - } - } - void operator()( ResultT& res, const ResultT& xyz ) const - { - res.SetPx( xyz.Px() ); - res.SetPy( xyz.Py() ); - res.SetPz( xyz.Pz() ); - } - }; // Operations - // ---------------------------------------------------------------------------- - Pnt4DGrammar() : Pnt4DGrammar::base_type( point4d ) - { - point4d = list4d | ( '(' >> list4d >> ')' ) | ( '[' >> list4d >> ']' ); - list4d = ( point3d[op( qi::_val, qi::_1 )] >> enc::char_( ";," ) >> e[op( qi::_val, qi::_1, 'e' )] ) | - ( e[op( qi::_val, qi::_1, 'e' )] >> enc::char_( ";," ) >> point3d[op( qi::_val, qi::_1 )] ); - e = -( enc::no_case[enc::char_( "te" )] >> ':' ) >> scalar[qi::_val = qi::_1]; - - point3d = list3d | ( '(' >> list3d >> ')' ) | ( '[' >> list3d >> ']' ); - list3d = -( enc::no_case[qi::lit( "x" ) | qi::lit( "px" )] >> ':' ) >> scalar[op( qi::_val, qi::_1, 'x' )] >> - ',' >> -( enc::no_case[qi::lit( "y" ) | qi::lit( "py" )] >> ':' ) >> - scalar[op( qi::_val, qi::_1, 'y' )] >> ',' >> - -( enc::no_case[qi::lit( "z" ) | qi::lit( "pz" )] >> ':' ) >> scalar[op( qi::_val, qi::_1, 'z' )]; - } - // ---------------------------------------------------------------------------- - qi::rule point3d, point4d, list3d, list4d; - qi::rule e; - typename Grammar_::Grammar scalar; - ph::function op; - // ---------------------------------------------------------------------------- - }; // Pnt4DGrammar - // ---------------------------------------------------------------------------- - // Register Pnt4DGrammar for ROOT::Math::LorentzVector: - // ---------------------------------------------------------------------------- - template - struct Grammar_, Skipper> { - typedef Pnt4DGrammar, Skipper> Grammar; - }; - // ============================================================================ - template - struct Histo1DGrammar : qi::grammar, Skipper> { - typedef Gaudi::Histo1DDef ResultT; - // ---------------------------------------------------------------------------- - struct Operations { - void operator()( ResultT& res, const std::string& title ) const { res.setTitle( title ); } - void operator()( ResultT& res, const double& val, const char lh ) const - { - switch ( lh ) { - case 'l': - res.setLowEdge( val ); - break; - case 'h': - res.setHighEdge( val ); - break; - default: - break; - } - } - void operator()( ResultT& res, int val ) const { res.setBins( val ); } - void operator()( ResultT& res ) const {} - }; // Operations - // ---------------------------------------------------------------------------- - Histo1DGrammar() : Histo1DGrammar::base_type( hist ) - { - val1 = title[op( qi::_val, qi::_1 )] >> ',' >> qi::double_[op( qi::_val, qi::_1, 'l' )] >> ',' >> - qi::double_[op( qi::_val, qi::_1, 'h' )] >> -( ',' >> qi::int_[op( qi::_val, qi::_1 )] ); - val2 = qi::double_[op( qi::_val, qi::_1, 'l' )] >> ',' >> qi::double_[op( qi::_val, qi::_1, 'h' )] >> ',' >> - title[op( qi::_val, qi::_1 )] >> -( ',' >> qi::int_[op( qi::_val, qi::_1 )] ); - val3 = qi::double_[op( qi::_val, qi::_1, 'l' )] >> ',' >> qi::double_[op( qi::_val, qi::_1, 'h' )] >> - -( ',' >> title[op( qi::_val, qi::_1 )] ) >> -( ',' >> qi::int_[op( qi::_val, qi::_1 )] ); - begin = enc::char_( '[' )[qi::_val = ']'] | enc::char_( '(' )[qi::_val = ')']; - end = enc::char_( qi::_r1 ); - hist = begin[qi::_a = qi::_1] >> ( val1 | val2 | val3 )[qi::_val = qi::_1] >> end( qi::_a ); - } - // ---------------------------------------------------------------------------- - qi::rule, Skipper> hist; - qi::rule val1, val2, val3; - qi::rule begin; - qi::rule end; - StringGrammar title; - ph::function op; - // ---------------------------------------------------------------------------- - }; // Histo1DGrammar - // ---------------------------------------------------------------------------- - REGISTER_GRAMMAR( Gaudi::Histo1DDef, Histo1DGrammar ); - // ============================================================================ - template - struct KeyValueGrammar : qi::grammar(), Skipper> { - //------------------------------------------------------------------------------ - typedef std::pair ResultT; - //------------------------------------------------------------------------------ - struct first { - }; - struct second { - }; - - KeyValueGrammar() : KeyValueGrammar::base_type( pair ) - { - //------------------------------------------------------------------------------ - pair = gstring >> ":" >> +enc::char_; - } - // ---------------------------------------------------------------------------- - StringGrammar gstring; - qi::rule pair; - // ---------------------------------------------------------------------------- - }; // END KeyValueGrammar - // We don't register KeyalueGrammar because it's a special parser - // ============================================================================ - } -} // Gaudi::Parsers -//============================================================================ -#endif +#include diff --git a/GaudiKernel/GaudiKernel/Parsers.h b/GaudiKernel/GaudiKernel/Parsers.h index 01e6694729..bd7c5a92ef 100644 --- a/GaudiKernel/GaudiKernel/Parsers.h +++ b/GaudiKernel/GaudiKernel/Parsers.h @@ -1,548 +1,3 @@ -// ============================================================================ -#ifndef GAUDIPROPERTYPARSERS_PARSERS_H -#define GAUDIPROPERTYPARSERS_PARSERS_H 1 -// ============================================================================ -// Include files -// ============================================================================ -// STD & STL -// ============================================================================ -#include -#include -#include -#include -#include +#pragma once -// ============================================================================ -#include "GaudiKernel/HistoDef.h" -#include "GaudiKernel/Map.h" -#include "GaudiKernel/StatusCode.h" -// ============================================================================ -#define PARSERS_DECL_FOR_SINGLE( Type ) GAUDI_API StatusCode parse( Type& result, const std::string& input ); - -#define PARSERS_DECL_FOR_PAIR( FirstType, SecondType ) \ - GAUDI_API StatusCode parse( std::pair& result, const std::string& input ); - -#define PARSERS_DECL_FOR_LIST( InnerType ) \ - GAUDI_API StatusCode parse( std::vector& result, const std::string& input ); -// ============================================================================ -/** @file - * The declaration of major parsing functions used e.g - * for (re)implementation of new extended properties see class Property - * These function also could be used in a different, much wider contex. - * all of them have the semantic: - * StatusCode parse ( TYPE& result , const std::string& input ) - * where input is the input string to be parsed, - * and result is the the result of parsing - * - * @code - * - * const std::string input = ... ; - * std::vector result ; - * - * // parse the input - * StatusCode sc = parse ( result , input ) ; - * if ( sc.isFailure() ) - * { - * // error here ... - * } - * std::cout << "vector size " << result.size() << std::endl ; - * - * @endcode - * - * @see Gaudi::Parsers::parse - * @see Property - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-12 - */ -// ============================================================================ -namespace Gaudi -{ - // ========================================================================== - class Histo1DDef; - // ========================================================================== - namespace Parsers - { - // ======================================================================== - /** parse the bool value - * @see Gaudi::Parsers::BoolGrammar - * @param result (output) boolean result - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-12 - */ - PARSERS_DECL_FOR_SINGLE( bool ) - // ======================================================================== - /** parse the char value - * - * @see Gaudi::Parsers::CharGrammar - * @param result (output) boolean result - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-12 - */ - PARSERS_DECL_FOR_SINGLE( char ) - /// @see Gaudi::Parsers::parser(char&,std::string&) - PARSERS_DECL_FOR_SINGLE( unsigned char ) - /// @see Gaudi::Parsers::parser(char&,std::string&) - PARSERS_DECL_FOR_SINGLE( signed char ) - // ======================================================================== - /** parse the int value - * - * @see Gaudi::Parsers::IntGrammar - * @param result (output) integer result - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - PARSERS_DECL_FOR_SINGLE( int ) - /// @see Gaudi::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE( short ) - /// @see Gaudi::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE( unsigned short ) - /// @see Gaudi::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE( unsigned int ) - /// @see Gaudi::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE( long ) - /// @see Gaudi::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE( unsigned long ) - /// @see Gaudi::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE( long long ) - /// @see Gaudi::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE( unsigned long long ) - // ======================================================================== - /** parse the double value - * - * @see Gaudi::Parsers::RealGrammar - * @param result (output) double result - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - PARSERS_DECL_FOR_SINGLE( double ) - /// @see Gaudi::Parsers::parser( double&, const std::string& ) - PARSERS_DECL_FOR_SINGLE( float ) - /// @see Gaudi::Parsers::parser( double&, const std::string& ) - PARSERS_DECL_FOR_SINGLE( long double ) - // ======================================================================== - /** parse the std::string value - * - * @see Gaudi::Parsers::StringGrammar - * @param result (output) string result - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - PARSERS_DECL_FOR_SINGLE( std::string ) - // ======================================================================== - - PARSERS_DECL_FOR_LIST( bool ) - PARSERS_DECL_FOR_LIST( char ) - PARSERS_DECL_FOR_LIST( unsigned char ) - PARSERS_DECL_FOR_LIST( signed char ) - - PARSERS_DECL_FOR_LIST( int ) - PARSERS_DECL_FOR_LIST( short ) - PARSERS_DECL_FOR_LIST( unsigned short ) - PARSERS_DECL_FOR_LIST( unsigned int ) - PARSERS_DECL_FOR_LIST( long ) - PARSERS_DECL_FOR_LIST( unsigned long ) - PARSERS_DECL_FOR_LIST( long long ) - PARSERS_DECL_FOR_LIST( unsigned long long ) - - PARSERS_DECL_FOR_LIST( double ) - PARSERS_DECL_FOR_LIST( float ) - PARSERS_DECL_FOR_LIST( long double ) - - PARSERS_DECL_FOR_LIST( std::string ) - // ======================================================================== - // Advanced parses - // ======================================================================== - /** parse the std::pair\ value - * - * @see Gaudi::Parsers::PairGrammar - * @see Gaudi::Parsers::RealGrammar - * @param result (output) pair of doubles - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - PARSERS_DECL_FOR_PAIR( double, double ) - // ======================================================================== - /** parse the std::pair\ value - * - * @see Gaudi::Parsers::PairGrammar - * @see Gaudi::Parsers::IntGrammar - * @param result (output) pair of integers - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - PARSERS_DECL_FOR_PAIR( int, int ) - // ======================================================================== - /** parse the std::vector\ \> value - * - * @see Gaudi::Parsers::VectorGrammar - * @see Gaudi::Parsers::PairGrammar - * @see Gaudi::Parsers::RealGrammar - * @param result (output) vector with pairs of doubles - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - GAUDI_API StatusCode parse( std::vector>& result, const std::string& input ); - // ======================================================================== - /** parse the std::vector\ \> value - * - * @see Gaudi::Parsers::VectorGrammar - * @see Gaudi::Parsers::PairGrammar - * @see Gaudi::Parsers::IntGrammar - * @param result (output) vector with pairs of int - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - GAUDI_API StatusCode parse( std::vector>& result, const std::string& input ); - // ======================================================================== - // vector< vector< TYPE > > - // ======================================================================== - /** parse the std::vector\ \> value - * - * @see Gaudi::Parsers::VectorGrammar - * @see Gaudi::Parsers::StringGrammar - * @param result (output) vector with vectors of strings - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - GAUDI_API StatusCode parse( std::vector>& result, const std::string& input ); - // ======================================================================== - /** parse the std::vector\ \> value - * - * @see Gaudi::Parsers::VectorGrammar - * @see Gaudi::Parsers::RealGrammar - * @param result (output) vector with vectors of doubles - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - GAUDI_API StatusCode parse( std::vector>& result, const std::string& input ); - // ======================================================================== - // map< TYPE, TYPE > - // ======================================================================== - /** parse the std::map\ value - * - * @see Gaudi::Parsers::MapGrammar - * @see Gaudi::Parsers::IntGrammar - * @param result (output) map with integer key and double value - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - GAUDI_API StatusCode parse( std::map& result, const std::string& input ); - // ======================================================================== - /** parse the std::map\ value - * - * @see Gaudi::Parsers::MapGrammar - * @see Gaudi::Parsers::IntGrammar - * @see Gaudi::Parsers::RealGrammar - * @param result (output) map with integer key and double value - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - GAUDI_API StatusCode parse( std::map& result, const std::string& input ); - // ======================================================================== - /** parse the std::map\ value - * - * @see Gaudi::Parsers::MapGrammar - * @see Gaudi::Parsers::StringGrammar - * @param result (output) map with string key and value - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - GAUDI_API StatusCode parse( std::map& result, const std::string& input ); - // ======================================================================== - /** parse the std::map\ value - * - * @see Gaudi::Parsers::MapGrammar - * @see Gaudi::Parsers::StringGrammar - * @see Gaudi::Parsers::IntGrammar - * @param result (output) map with string key and integer value - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - GAUDI_API StatusCode parse( std::map& result, const std::string& input ); - // ======================================================================== - /** parse the std::map\ value - * - * @see Gaudi::Parsers::MapGrammar - * @see Gaudi::Parsers::StringGrammar - * @see Gaudi::Parsers::RealGrammar - * @param result (output) map with string key and integer value - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - GAUDI_API StatusCode parse( std::map& result, const std::string& input ); - // ======================================================================== - /** parse the std::map\ \> - * value - * - * @see Gaudi::Parsers::MapGrammar - * @see Gaudi::Parsers::StringGrammar - * @see Gaudi::Parsers::VectorGrammar - * @param result (output) map with string value and - * vector of strings as value - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - GAUDI_API StatusCode parse( std::map>& result, const std::string& input ); - // ======================================================================== - /** parse the std::map\ \> value - * - * @see Gaudi::Parsers::MapGrammar - * @see Gaudi::Parsers::StringGrammar - * @see Gaudi::Parsers::VectorGrammar - * @see Gaudi::Parsers::IntGrammar - * @param result (output) map with string value and - * vector of integers as value - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - GAUDI_API StatusCode parse( std::map>& result, const std::string& input ); - // ======================================================================== - /** parse the std::map\ \> value - * - * @see Gaudi::Parsers::MapGrammar - * @see Gaudi::Parsers::StringGrammar - * @see Gaudi::Parsers::VectorGrammar - * @see Gaudi::Parsers::RealGrammar - * @param result (output) map with string value and - * vector of doubles as value - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - GAUDI_API StatusCode parse( std::map>& result, const std::string& input ); - // ======================================================================== - /** parse the std::map\ \> objects - * - * @see Gaudi::Parsers::MapGrammar - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @date 2007-12-06 - */ - GAUDI_API StatusCode parse( std::map& result, const std::string& input ); - // ======================================================================== - /** parse the std::map\ \> objects - * - * @see Gaudi::Parsers::MapGrammar - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @date 2007-12-06 - */ - GAUDI_API StatusCode parse( std::map& result, const std::string& input ); - // ======================================================================== - /** parse the std::map\ \> objects - * - * @see Gaudi::Parsers::MapGrammar - */ - GAUDI_API StatusCode parse( std::map& result, const std::string& input ); - // ======================================================================== - /** parse the GaudiUtils::Map\ objects - * - * @see Gaudi::Parsers::MapGrammar - */ - template - GAUDI_API StatusCode parse( GaudiUtils::Map& result, const std::string& input ) - { - return parse( (M&)result, input ); - } - // ======================================================================== - /** parse the pair expression (map-component) " 'name' :value" - * - * @code - * - * const std::string input = "'PackageName':GaudiKernel" ; - * std::string name ; - * std::string value ; - * StatusCode sc = Gaudi::Parsers::parse ( name , value , input ) ; - * if ( sc.isFailure() ) { ... } - * std::cout << "\tParsed name is " << name - * << "\tParsed value is " << value << std::endl - * @endcode - * - * @param name (output) the parsed name of the component, defined - * as 'name' or "name" before the column symbol ":", - * the leading and trailing blans are omitted - * @param value (output) the parsed value of the component, - * defined as everything after the column symbol ":" - * till the end of the string - * @param input (input) string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-12 - */ - GAUDI_API StatusCode parse( std::string& name, std::string& value, const std::string& input ); - // ======================================================================== - /** helper function, needed for implementation of "Histogram Property" - * @param histo the histogram description (output) - * @param input the string to be parsed - * @return status code - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @date 2007-09-17 - */ - GAUDI_API StatusCode parse( Gaudi::Histo1DDef& histo, const std::string& input ); - // ======================================================================== - /** helper function, needed for implementation of "Histogram Property" - * @param histos the map of the histogram descriptions (output) - * @param input the string to be parsed - * @return status code - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @date 2007-09-17 - */ - GAUDI_API StatusCode parse( std::map& histos, const std::string& input ); - // ======================================================================== - /** helper function, needed for implementation of map of pairs - * It is very useful construction for monitoring to - * represent the value and error or the allowed range for - * some parameter - * @param params the map of pair - * @param input the string to be parsed - * @return status code - * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @date 2009-05-19 - */ - GAUDI_API StatusCode parse( std::map>& params, const std::string& input ); - // ======================================================================== - /** parser function for C-arrays - * @param params C-array - * @param input the string to be parsed - * @return status code - * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl - * @date 2009-09-15 - */ - template - StatusCode parse( T ( &result )[N], const std::string& input ) - { - typedef std::vector _Vct; - // create the temporary vector - _Vct tmp; - StatusCode sc = parse( tmp, input ); - if ( sc.isFailure() ) { - return sc; - } // RETURN - if ( N != tmp.size() ) { - return StatusCode::FAILURE; - } // RETURN - // - std::copy( tmp.begin(), tmp.end(), result ); - // - return StatusCode::SUCCESS; // RETURN - } - // ======================================================================== - /** parser function for C-strings - * @param params C-string - * @param input the string to be parsed - * @return status code - * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl - * @date 2009-09-15 - */ - template - StatusCode parse( char ( &result )[N], const std::string& input ) - { - // clear the string - std::fill_n( result, N, ' ' ); - // create the temporary string - std::string tmp; - StatusCode sc = parse( tmp, input ); - if ( sc.isFailure() ) { - return sc; - } // RETURN - if ( N == tmp.size() ) { - std::copy( tmp.begin(), tmp.end(), result ); - } else if ( N + 2 == tmp.size() && ( '\'' == tmp[0] || '\"' == tmp[0] ) && ( tmp[0] == tmp[tmp.size() - 1] ) ) { - std::copy( tmp.begin() + 1, tmp.end() - 1, result ); - } else { - return StatusCode::FAILURE; - } - // - return StatusCode::SUCCESS; // RETURN - } - // ======================================================================== - } // end of namespace Gaudi::Parsers - // ========================================================================== -} // end of namespace Gaudi -// ============================================================================ -// The END -// ============================================================================ -#endif // GAUDIPROPERTYPARSERS_PARSERS_H -// ============================================================================ +#include diff --git a/GaudiKernel/GaudiKernel/ParsersFactory.h b/GaudiKernel/GaudiKernel/ParsersFactory.h index 9aef45037d..c9ccaa1ff9 100644 --- a/GaudiKernel/GaudiKernel/ParsersFactory.h +++ b/GaudiKernel/GaudiKernel/ParsersFactory.h @@ -1,64 +1,3 @@ -// ============================================================================ -#ifndef GAUDIPROPERTYPARSERS_PARSERSGENERATOR_H -#define GAUDIPROPERTYPARSERS_PARSERSGENERATOR_H 1 -// ============================================================================ -// Include files -// ============================================================================ -// STD & STL -// ============================================================================ -#include -#include -#include -// ============================================================================ -// Boost: -// ============================================================================ -#include -#include -// ============================================================================ -// Gaudi -// ============================================================================ -#include "GaudiKernel/GrammarsV2.h" -#include "GaudiKernel/StatusCode.h" -// ============================================================================ -namespace Gaudi -{ - namespace Parsers - { - // ======================================================================== - typedef std::string::const_iterator IteratorT; - // typedef boost::spirit::ascii::space_type Skipper; - typedef SkipperGrammar Skipper; - // ======================================================================== - template - inline StatusCode parse_( ResultT& result, const std::string& input ) - { - Skipper skipper; - typename Grammar_::Grammar g; - IteratorT iter = input.begin(), end = input.end(); - return ( qi::phrase_parse( iter, end, g, skipper, result ) && ( iter == end ) ? StatusCode::SUCCESS - : StatusCode::FAILURE ); - } - //========================================================================= - template <> - inline StatusCode parse_( std::string& result, const std::string& input ) - { - Skipper skipper; - Grammar_::Grammar g; - IteratorT iter = input.begin(), end = input.end(); - if ( !( qi::phrase_parse( iter, end, g, skipper, result ) && ( iter == end ) ) ) { - result = input; - } - //@attention always - return StatusCode::SUCCESS; - } - //========================================================================= - template - inline StatusCode parse( ResultT& result, const std::string& input ) - { - return parse_( result, input ); - } - //========================================================================= - } /* Parsers */ -} /* Gaudi */ -//============================================================================= -#endif // GAUDIPROPERTYPARSERS_PARSERSGENERATOR_H +#pragma once + +#include diff --git a/GaudiKernel/GaudiKernel/Property.h b/GaudiKernel/GaudiKernel/Property.h index 97e91d884a..f7c543de5e 100644 --- a/GaudiKernel/GaudiKernel/Property.h +++ b/GaudiKernel/GaudiKernel/Property.h @@ -12,22 +12,14 @@ // ============================================================================ #include "GaudiKernel/IProperty.h" #include "GaudiKernel/Kernel.h" -#include "GaudiKernel/Parsers.h" #include "GaudiKernel/PropertyFwd.h" #include "GaudiKernel/SmartIF.h" #include "GaudiKernel/ToStream.h" +#include +#include namespace Gaudi { - namespace Parsers - { - /// Helper class to enable ADL for parsers - struct InputData : std::string { - InputData( const std::string& s ) : std::string{s} {} - using std::string::string; - using std::string::operator=; - }; - } namespace Details { // ============================================================================ diff --git a/GaudiKernel/GaudiKernel/SVectorAsProperty.h b/GaudiKernel/GaudiKernel/SVectorAsProperty.h index 57112d0da5..1c06d54475 100644 --- a/GaudiKernel/GaudiKernel/SVectorAsProperty.h +++ b/GaudiKernel/GaudiKernel/SVectorAsProperty.h @@ -10,7 +10,7 @@ // ============================================================================ // GaudiKernel // ============================================================================ -#include "GaudiKernel/Parsers.h" +#include // ============================================================================ // ROOT/SVector // ============================================================================ diff --git a/GaudiKernel/GaudiKernel/StdArrayAsProperty.h b/GaudiKernel/GaudiKernel/StdArrayAsProperty.h index f5c443383a..2b10a5d7d9 100644 --- a/GaudiKernel/GaudiKernel/StdArrayAsProperty.h +++ b/GaudiKernel/GaudiKernel/StdArrayAsProperty.h @@ -45,7 +45,7 @@ namespace Gaudi // ============================================================================ // GaudiKernel // ============================================================================ -#include "GaudiKernel/Parsers.h" +#include // ============================================================================ namespace Gaudi { diff --git a/GaudiKernel/src/Lib/DataObjID.cpp b/GaudiKernel/src/Lib/DataObjID.cpp index aac9c008eb..ff02be010a 100644 --- a/GaudiKernel/src/Lib/DataObjID.cpp +++ b/GaudiKernel/src/Lib/DataObjID.cpp @@ -2,7 +2,7 @@ #include "GaudiKernel/Bootstrap.h" #include "GaudiKernel/IClassIDSvc.h" #include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/ParsersFactory.h" +#include #include #include #include diff --git a/GaudiKernel/src/Lib/DataObjectHandleProperty.cpp b/GaudiKernel/src/Lib/DataObjectHandleProperty.cpp index 6267276c36..c5cebb4c54 100644 --- a/GaudiKernel/src/Lib/DataObjectHandleProperty.cpp +++ b/GaudiKernel/src/Lib/DataObjectHandleProperty.cpp @@ -1,8 +1,8 @@ #include "GaudiKernel/DataObjectHandleProperty.h" #include "GaudiKernel/DataObjectHandleBase.h" -#include "GaudiKernel/Parsers.h" #include "GaudiKernel/System.h" +#include #include diff --git a/GaudiKernel/src/Lib/ParsersCollections.cpp b/GaudiKernel/src/Lib/ParsersCollections.cpp index 07c9cb49d1..e43cb524f4 100644 --- a/GaudiKernel/src/Lib/ParsersCollections.cpp +++ b/GaudiKernel/src/Lib/ParsersCollections.cpp @@ -3,7 +3,7 @@ // ============================================================================ #include "GaudiKernel/VectorMap.h" // ============================================================================ -#include "GaudiKernel/ParsersFactory.h" +#include // ============================================================================ StatusCode Gaudi::Parsers::parse( GaudiUtils::VectorMap& result, const std::string& input ) diff --git a/GaudiKernel/src/Lib/ParsersHistograms.cpp b/GaudiKernel/src/Lib/ParsersHistograms.cpp index 9ec0595606..17af82a110 100644 --- a/GaudiKernel/src/Lib/ParsersHistograms.cpp +++ b/GaudiKernel/src/Lib/ParsersHistograms.cpp @@ -1,9 +1,9 @@ // ============================================================================ // Include files // ============================================================================ -#include "GaudiKernel/Parsers.h" +#include // ============================================================================ -#include "GaudiKernel/ParsersFactory.h" +#include // ============================================================================ StatusCode Gaudi::Parsers::parse( Gaudi::Histo1DDef& result, const std::string& input ) { diff --git a/GaudiKernel/src/Lib/ParsersStandardListCommon.h b/GaudiKernel/src/Lib/ParsersStandardListCommon.h index 7457c1226b..0474f2dd48 100644 --- a/GaudiKernel/src/Lib/ParsersStandardListCommon.h +++ b/GaudiKernel/src/Lib/ParsersStandardListCommon.h @@ -3,8 +3,8 @@ // ============================================================================ // Include files // ============================================================================ -#include "GaudiKernel/Parsers.h" -#include "GaudiKernel/ParsersFactory.h" +#include +#include // ============================================================================ // STD & STL // ============================================================================ diff --git a/GaudiKernel/src/Lib/ParsersStandardMiscCommon.h b/GaudiKernel/src/Lib/ParsersStandardMiscCommon.h index 17cbf68690..7b7f9d16fe 100644 --- a/GaudiKernel/src/Lib/ParsersStandardMiscCommon.h +++ b/GaudiKernel/src/Lib/ParsersStandardMiscCommon.h @@ -3,8 +3,8 @@ // ============================================================================ // Include files // ============================================================================ -#include "GaudiKernel/Parsers.h" -#include "GaudiKernel/ParsersFactory.h" +#include +#include // ============================================================================ // STD & STL // ============================================================================ diff --git a/GaudiKernel/src/Lib/ParsersStandardSingle.cpp b/GaudiKernel/src/Lib/ParsersStandardSingle.cpp index 429afc6375..e514854da6 100644 --- a/GaudiKernel/src/Lib/ParsersStandardSingle.cpp +++ b/GaudiKernel/src/Lib/ParsersStandardSingle.cpp @@ -1,8 +1,8 @@ // ============================================================================ // Include files // ============================================================================ -#include "GaudiKernel/Parsers.h" -#include "GaudiKernel/ParsersFactory.h" +#include +#include // ============================================================================ // STD & STL // ============================================================================ diff --git a/GaudiKernel/src/Lib/ParsersVct.cpp b/GaudiKernel/src/Lib/ParsersVct.cpp index 5b6ff2e50f..5674e90c81 100644 --- a/GaudiKernel/src/Lib/ParsersVct.cpp +++ b/GaudiKernel/src/Lib/ParsersVct.cpp @@ -3,8 +3,8 @@ // ============================================================================ #include "GaudiKernel/VectorsAsProperty.h" // ============================================================================ -#include "GaudiKernel/ParsersFactory.h" #include "GaudiKernel/ToStream.h" +#include // ============================================================================ namespace { diff --git a/GaudiKernel/src/Lib/StringKey.cpp b/GaudiKernel/src/Lib/StringKey.cpp index c9c8028e65..0c296c14ea 100644 --- a/GaudiKernel/src/Lib/StringKey.cpp +++ b/GaudiKernel/src/Lib/StringKey.cpp @@ -4,8 +4,8 @@ // GaudiKernel // ============================================================================ #include "GaudiKernel/StringKey.h" -#include "GaudiKernel/Parsers.h" #include "GaudiKernel/ToStream.h" +#include // ============================================================================ /** @file * Implementation file for class Gaudi::StringKey diff --git a/GaudiKernel/tests/src/parsers.cpp b/GaudiKernel/tests/src/parsers.cpp index d1b703f8c1..c45781270a 100644 --- a/GaudiKernel/tests/src/parsers.cpp +++ b/GaudiKernel/tests/src/parsers.cpp @@ -4,8 +4,8 @@ #include "GaudiKernel/VectorsAsProperty.h" #include -#include "GaudiKernel/ParsersFactory.h" #include "GaudiKernel/ToStream.h" +#include using namespace Gaudi::Parsers; diff --git a/GaudiUtils/src/Lib/HistoParsers.cpp b/GaudiUtils/src/Lib/HistoParsers.cpp index 7a00534125..c960fc7b7c 100644 --- a/GaudiUtils/src/Lib/HistoParsers.cpp +++ b/GaudiUtils/src/Lib/HistoParsers.cpp @@ -23,7 +23,7 @@ // ============================================================================ // GaudiKernel // ============================================================================ -#include "GaudiKernel/ParsersFactory.h" +#include // ============================================================================ // local // ============================================================================ -- GitLab From f0401f8f030435b92895e6adfa0a48bf4ddf3a7d Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Thu, 7 Dec 2017 15:08:24 +0100 Subject: [PATCH 03/53] Rewired JobOptionsSvc in terms of a simple map string->string - added minimal interface `Gaudi::Interfaces::IOptionsSvc` - reimplemented `IJobOptionsSvc` methods using the new interface methods (`set`, `get` and `has`) - deprecated `IJobOptionsSvc` methods --- .../src/JobOptionsSvc/JobOptionsSvc.cpp | 70 ++++++--- .../src/JobOptionsSvc/JobOptionsSvc.h | 30 +++- .../src/JobOptionsSvc/PythonConfig.cpp | 9 +- GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.h | 18 +-- GaudiCoreSvc/src/JobOptionsSvc/SvcCatalog.cpp | 137 ------------------ GaudiCoreSvc/src/JobOptionsSvc/SvcCatalog.h | 60 -------- .../tests/qmtest/refs/Properties.ref | 2 +- .../tests/qmtest/refs/Properties2.ref | 4 +- .../tests/qmtest/refs/Properties_py.ref | 4 +- GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h | 20 +++ GaudiKernel/GaudiKernel/IJobOptionsSvc.h | 20 +-- GaudiKernel/GaudiKernel/JobHistory.h | 5 +- GaudiKernel/GaudiKernel/PropertyHolder.h | 8 +- GaudiKernel/src/Lib/JobHistory.cpp | 11 +- GaudiKernel/src/Lib/Property.cpp | 13 +- GaudiMonitor/src/HistorySvc.cpp | 8 +- RootHistCnv/src/RFileCnv.cpp | 3 + 17 files changed, 162 insertions(+), 260 deletions(-) delete mode 100644 GaudiCoreSvc/src/JobOptionsSvc/SvcCatalog.cpp delete mode 100644 GaudiCoreSvc/src/JobOptionsSvc/SvcCatalog.h create mode 100644 GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp index d3543958ba..20c7d2cf78 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp @@ -2,6 +2,7 @@ // Local: // ============================================================================ #include "JobOptionsSvc.h" + #include "Analyzer.h" #include "Catalog.h" #include "Messages.h" @@ -14,6 +15,9 @@ // ============================================================================ #include "GaudiKernel/MsgStream.h" #include "GaudiKernel/System.h" + +#include + // ============================================================================ DECLARE_COMPONENT( JobOptionsSvc ) // ============================================================================ @@ -49,42 +53,73 @@ StatusCode JobOptionsSvc::initialize() StatusCode JobOptionsSvc::addPropertyToCatalogue( const std::string& client, const Gaudi::Details::PropertyBase& property ) { - auto p = std::make_unique>( property.name(), "" ); - return property.load( *p ) ? m_svc_catalog.addProperty( client, p.release() ) : StatusCode::FAILURE; + set( client + '.' + property.name(), property.toString() ); + return StatusCode::SUCCESS; } // ============================================================================ StatusCode JobOptionsSvc::removePropertyFromCatalogue( const std::string& client, const std::string& name ) { - return m_svc_catalog.removeProperty( client, name ); + m_options.erase( client + '.' + name ); + return StatusCode::SUCCESS; } // ============================================================================ const JobOptionsSvc::PropertiesT* JobOptionsSvc::getProperties( const std::string& client ) const { - return m_svc_catalog.getProperties( client ); + PropertiesT props; + + const std::string key_base = client + '.'; + const auto key_base_size = key_base.size(); + for ( const auto& elem : m_options ) { + boost::string_ref key = elem.first; + // for keys that are 'client.name' (and name does not contain '.') + // we add an entry to the vector + if ( key.starts_with( key_base ) ) { + boost::string_ref name = key.substr( key_base_size ); + if ( name.find( '.' ) == std::string::npos ) { + props.push_back( getClientProperty( client, static_cast( name ) ) ); + } + } + } + // we are supposed to be the owner of the vector, so we need to keep it safe + return &( m_old_iface_compat_2[client] = std::move( props ) ); } // ============================================================================ StatusCode JobOptionsSvc::setMyProperties( const std::string& client, IProperty* myInt ) { - const auto* props = m_svc_catalog.getProperties( client ); - if ( !props ) { - return StatusCode::SUCCESS; - } + const std::string key_base = client + '.'; + const auto key_base_size = key_base.size(); bool fail = false; - for ( const auto& cur : *props ) { - StatusCode sc = myInt->setProperty( *cur ); - if ( sc.isFailure() ) { - error() << "Unable to set the property '" << cur->name() << "'" - << " of '" << client << "'. " - << "Check option and algorithm names, type and bounds." << endmsg; - fail = true; + for ( const auto& elem : m_options ) { + boost::string_ref key = elem.first; + if ( key.starts_with( key_base ) ) { + const auto name = static_cast( key.substr( key_base_size ) ); + // \fixme this has to change if we want nested properties + // if ( myInt->hasProperty( name ) ) { + if ( name.find( '.' ) == std::string::npos ) { + if ( !myInt->setProperty( name, elem.second ) ) { + error() << "Unable to set the property '" << name << "'" + << " of '" << client << "'. " + << "Check option and algorithm names, type and bounds." << endmsg; + fail = true; + // throw std::invalid_argument( "cannot set " + name + " of " + client + " to " + elem.second ); + } + } } } return fail ? StatusCode::FAILURE : StatusCode::SUCCESS; } /// Get the list of clients -std::vector JobOptionsSvc::getClients() const { return m_svc_catalog.getClients(); } +std::vector JobOptionsSvc::getClients() const +{ + std::set clients; + for ( const auto& elem : m_options ) { + const auto pos = elem.first.rfind( '.' ); + if ( pos != std::string::npos ) clients.emplace( elem.first, 0, pos ); + } + return {begin( clients ), end( clients )}; +} void JobOptionsSvc::dump( const std::string& file, const gp::Catalog& catalog ) const { @@ -102,8 +137,7 @@ void JobOptionsSvc::fillServiceCatalog( const gp::Catalog& catalog ) { for ( const auto& client : catalog ) { for ( const auto& current : client.second ) { - addPropertyToCatalogue( client.first, - Gaudi::Property{current.NameInClient(), current.ValueAsString()} ); + set( client.first + '.' + current.NameInClient(), current.ValueAsString() ); } } } diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h index 2a8358487f..31329f2806 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h @@ -8,8 +8,9 @@ #include "GaudiKernel/Service.h" #include "GaudiKernel/StatusCode.h" -#include "SvcCatalog.h" +#include "Gaudi/Interfaces/IOptionsSvc.h" +#include #include namespace Gaudi @@ -20,10 +21,26 @@ namespace Gaudi } } -class JobOptionsSvc : public extends +class JobOptionsSvc : public extends, virtual public Gaudi::Interfaces::IOptionsSvc { public: typedef std::vector PropertiesT; + +private: + std::map m_options; + mutable std::map> m_old_iface_compat; + mutable std::map m_old_iface_compat_2; + +protected: + void set( const std::string& key, const std::string& value ) override { m_options[key] = value; } + std::string get( const std::string& key ) const override + { + auto item = m_options.find( key ); + return item != m_options.end() ? item->second : std::string{}; + } + bool has( const std::string& key ) const override { return m_options.find( key ) != m_options.end(); } + +public: // Constructor JobOptionsSvc( const std::string& name, ISvcLocator* svc ); @@ -50,7 +67,12 @@ public: const Gaudi::Details::PropertyBase* getClientProperty( const std::string& client, const std::string& name ) const override { - return m_svc_catalog.getProperty( client, name ); + const std::string key = client + '.' + name; + + auto value = get( key ); + + auto p = std::make_unique>( name, std::move( value ) ); + return ( m_old_iface_compat[key] = std::move( p ) ).get(); } /// Get the list of clients std::vector getClients() const override; @@ -75,7 +97,5 @@ private: Gaudi::Property m_dump{this, "DUMPFILE"}; Gaudi::Property m_pythonAction{this, "PYTHONACTION"}; Gaudi::Property m_pythonParams{this, "PYTHONPARAMS"}; - - SvcCatalog m_svc_catalog; }; #endif /* JOBOPTIONSSVC_H_ */ diff --git a/GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.cpp b/GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.cpp index a396ca74c2..07ea6130d5 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.cpp +++ b/GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.cpp @@ -1,5 +1,7 @@ #include "PythonConfig.h" +#include + // boost includes #include "boost/python.hpp" using namespace boost::python; @@ -15,11 +17,12 @@ StatusCode PythonConfig::evaluateConfig( const std::string& filename, const std: object main_namespace = main_module.attr( "__dict__" ); // make the translator class known to Python - main_namespace["PythonAdaptor"] = class_( "PythonAdaptor", boost::python::init() ) - .def( "addPropertyToJobOptions", &PythonAdaptor::addPropertyToJobOptions ); + main_namespace["PythonAdaptor"] = + class_( "PythonAdaptor", boost::python::init() ) + .def( "addPropertyToJobOptions", &PythonAdaptor::addPropertyToJobOptions ); // create an instance of it and pass it to Python - PythonAdaptor adaptor( m_IJobOptionsSvc ); + PythonAdaptor adaptor( m_optsSvc ); main_namespace["adaptor"] = ptr( &adaptor ); // some python helper diff --git a/GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.h b/GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.h index 2a6603bb2b..1452347a0a 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.h +++ b/GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.h @@ -1,9 +1,9 @@ #ifndef GAUDISVC_PYTHONCONFIG_H #define GAUDISVC_PYTHONCONFIG_H -#include "GaudiKernel/IJobOptionsSvc.h" -#include "GaudiKernel/IProperty.h" -#include "GaudiKernel/Property.h" -#include "GaudiKernel/SmartIF.h" +#include "Gaudi/Interfaces/IOptionsSvc.h" + +#include "GaudiKernel/StatusCode.h" + #include // Class to translate between Python and C++ worlds @@ -11,25 +11,25 @@ class PythonAdaptor { public: - PythonAdaptor( IJobOptionsSvc* jos ) : m_IJobOptionsSvc( jos ) {} + PythonAdaptor( Gaudi::Interfaces::IOptionsSvc* optsSvc ) : m_optsSvc( optsSvc ) {} void addPropertyToJobOptions( const std::string& client, const std::string& name, const std::string& value ) { - m_IJobOptionsSvc->addPropertyToCatalogue( client, Gaudi::Property( name, value ) ); + m_optsSvc->set( client + '.' + name, value ); } private: - SmartIF m_IJobOptionsSvc; + Gaudi::Interfaces::IOptionsSvc* m_optsSvc; }; // Helper class to be invoked by JobOptionsSvc class PythonConfig { public: - PythonConfig( IJobOptionsSvc* jos ) : m_IJobOptionsSvc( jos ){}; + PythonConfig( Gaudi::Interfaces::IOptionsSvc* optsSvc ) : m_optsSvc( optsSvc ) {} StatusCode evaluateConfig( const std::string& filename, const std::string& preAction, const std::string& postAction ); private: - SmartIF m_IJobOptionsSvc; + Gaudi::Interfaces::IOptionsSvc* m_optsSvc; }; #endif diff --git a/GaudiCoreSvc/src/JobOptionsSvc/SvcCatalog.cpp b/GaudiCoreSvc/src/JobOptionsSvc/SvcCatalog.cpp deleted file mode 100644 index a9b329d2f4..0000000000 --- a/GaudiCoreSvc/src/JobOptionsSvc/SvcCatalog.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// ============================================================================ -// Include files -// =========================================================================== -// STD & STL: -// =========================================================================== -#include -#include -// =========================================================================== -// Boost: -// =========================================================================== -#include "boost/algorithm/string.hpp" -// =========================================================================== -// Local -// =========================================================================== -#include "SvcCatalog.h" -// =========================================================================== -namespace -{ - constexpr struct select1st_t { - template - const S& operator()( const std::pair& p ) const - { - return p.first; - } - template - S& operator()( std::pair& p ) const - { - return p.first; - } - } select1st{}; -} -// =========================================================================== -SvcCatalog::~SvcCatalog() -{ - for ( const auto& cur : m_catalog ) { - for ( auto& prop : cur.second ) delete prop; - } -} -// ============================================================================ -StatusCode SvcCatalog::addProperty( const std::string& client, const Gaudi::Details::PropertyBase* property ) -{ - auto props = findProperties( client ); - if ( props ) { - removeProperty( client, property->name() ).ignore(); - props->push_back( property ); - } else { - m_catalog.emplace( client, PropertiesT{property} ); - } - return StatusCode::SUCCESS; -} -// ============================================================================ -StatusCode SvcCatalog::removeProperty( const std::string& client, const std::string& name ) -{ - auto props = findProperties( client ); - if ( props ) { - auto res = findProperty( *props, name ); - if ( res.first ) { - delete *res.second; - props->erase( res.second ); - } - } - return StatusCode::SUCCESS; -} -// ============================================================================ -const SvcCatalog::PropertiesT* SvcCatalog::getProperties( const std::string& client ) const -{ - return findProperties( client ); -} -// ============================================================================ -std::vector SvcCatalog::getClients() const -{ - std::vector result; - result.reserve( m_catalog.size() ); - std::transform( std::begin( m_catalog ), std::end( m_catalog ), std::back_inserter( result ), select1st ); - return result; -} -// ============================================================================ -const SvcCatalog::PropertiesT* SvcCatalog::findProperties( const std::string& client ) const -{ - auto result = m_catalog.find( client ); - return ( result != m_catalog.end() ) ? &result->second : nullptr; -} -// ============================================================================ -SvcCatalog::PropertiesT* SvcCatalog::findProperties( const std::string& client ) -{ - auto result = m_catalog.find( client ); - return ( result != m_catalog.end() ) ? &result->second : nullptr; -} -// ============================================================================ -std::pair SvcCatalog::findProperty( const SvcCatalog::PropertiesT& props, - const std::string& name ) const -{ - auto p = std::find_if( std::begin( props ), std::end( props ), [&]( const Gaudi::Details::PropertyBase* prop ) { - return boost::iequals( name, prop->name() ); - } ); - return {p != std::end( props ), p}; -} -// ============================================================================ -std::pair SvcCatalog::findProperty( SvcCatalog::PropertiesT& props, - const std::string& name ) -{ - auto p = std::find_if( std::begin( props ), std::end( props ), [&]( const Gaudi::Details::PropertyBase* prop ) { - return boost::iequals( name, prop->name() ); - } ); - return {p != std::end( props ), p}; -} -// ============================================================================ -std::ostream& SvcCatalog::fillStream( std::ostream& o ) const -{ - // loop over the clients: - for ( const auto& iclient : m_catalog ) { - o << "Client '" << iclient.first << "'" << std::endl; - for ( const auto& p : iclient.second ) { - if ( p ) o << "\t" << ( *p ) << std::endl; - } - } - // - return o; // RETURN -} -const Gaudi::Details::PropertyBase* SvcCatalog::getProperty( const std::string& client, const std::string& name ) const -{ - auto props = findProperties( client ); - if ( props ) { - const auto res = findProperty( *props, name ); - if ( res.first ) { - return *res.second; - } - } - return nullptr; -} -// ============================================================================ -// printoput operator -// ============================================================================ -std::ostream& operator<<( std::ostream& o, const SvcCatalog& c ) { return c.fillStream( o ); } -// ============================================================================ -// The END -// ============================================================================ diff --git a/GaudiCoreSvc/src/JobOptionsSvc/SvcCatalog.h b/GaudiCoreSvc/src/JobOptionsSvc/SvcCatalog.h deleted file mode 100644 index bd5ceabb1f..0000000000 --- a/GaudiCoreSvc/src/JobOptionsSvc/SvcCatalog.h +++ /dev/null @@ -1,60 +0,0 @@ -// ============================================================================ -#ifndef JOBOPTIONSSVC_SVCCATALOG_H -#define JOBOPTIONSSVC_SVCCATALOG_H 1 -// ============================================================================ -// Include files -// ============================================================================ -// STD & STL -// ============================================================================ -#include -#include -#include -// ============================================================================ -// GaudiKernel -// ============================================================================ -#include "GaudiKernel/Property.h" -#include "GaudiKernel/StatusCode.h" -// =========================================================================== - -/** @class SvcCatalog - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-13 - */ -class SvcCatalog final -{ -public: - typedef std::vector PropertiesT; - SvcCatalog() = default; - ~SvcCatalog(); - - StatusCode addProperty( const std::string& client, const Gaudi::Details::PropertyBase* property ); - - StatusCode removeProperty( const std::string& client, const std::string& name ); - const PropertiesT* getProperties( const std::string& client ) const; - std::vector getClients() const; - const Gaudi::Details::PropertyBase* getProperty( const std::string& client, const std::string& name ) const; - -public: - /// dump the content of catalog to std::ostream - std::ostream& fillStream( std::ostream& o ) const; - -private: - const PropertiesT* findProperties( const std::string& client ) const; - PropertiesT* findProperties( const std::string& client ); - std::pair findProperty( const PropertiesT& props, const std::string& name ) const; - std::pair findProperty( PropertiesT& props, const std::string& name ); - std::map m_catalog; -}; -// ============================================================================ -/// printoput operator -// ============================================================================ -std::ostream& operator<<( std::ostream& o, const SvcCatalog& c ); -// ============================================================================ - -// ============================================================================ -// The END -// ============================================================================ -#endif // JOBOPTIONSSVC_SVCCATALOG_H -// =========================================================================== diff --git a/GaudiExamples/tests/qmtest/refs/Properties.ref b/GaudiExamples/tests/qmtest/refs/Properties.ref index f271f7f5cc..05cb395188 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties.ref @@ -156,9 +156,9 @@ PropertyAlg INFO Properties of PropertyAlg: Bool, BoolArray, Double, D PropertyAlg INFO Properties of PropertyProxy: String PropertyAlg INFO ================================================= PropertyAlg INFO Changed property DoubleArray in catalogue +JobOptionsSvc ERROR Unable to set the property 'DoubleArray' of 'PropertyAlg'. Check option and algorithm names, type and bounds. PropertyAlg INFO Read handler called for property: 'PDouble':10100000. PropertyAlg INFO Update handler called for property: 'PDouble':10100000. -JobOptionsSvc ERROR Unable to set the property 'DoubleArray' of 'PropertyAlg'. Check option and algorithm names, type and bounds. PropertyAlg INFO DoubleArray = [-11, 2, 3.3, 0.0004] PropertyAlg INFO ================================================= PropertyProxy INFO Got property this.RInt = 101; diff --git a/GaudiExamples/tests/qmtest/refs/Properties2.ref b/GaudiExamples/tests/qmtest/refs/Properties2.ref index 54a147057c..35f4a128e2 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties2.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties2.ref @@ -152,13 +152,13 @@ PropertyAlg INFO Dump of the property catalogue.... PropertyAlg INFO Properties of AuditorSvc: Auditors PropertyAlg INFO Properties of Dummy1: Property PropertyAlg INFO Properties of Dummy2: Property -PropertyAlg INFO Properties of PropertyAlg: DoubleArray, Int64Array, EmptyArray, Bool, UInt64Array, StringArray, String, DoublePairArray, PDoubleArray, PDouble, PInt, BoolArray, Double, PStringArray, OutputLevel, Int64, PBoolArray, IntArray, PBool, UInt64, IntPairArray, PIntArray, Int, DoubleArrayWithUnits, PString, DoubleArrayWithoutUnits +PropertyAlg INFO Properties of PropertyAlg: Bool, BoolArray, Double, DoubleArray, DoubleArrayWithUnits, DoubleArrayWithoutUnits, DoublePairArray, EmptyArray, Int, Int64, Int64Array, IntArray, IntPairArray, OutputLevel, PBool, PBoolArray, PDouble, PDoubleArray, PInt, PIntArray, PString, PStringArray, String, StringArray, UInt64, UInt64Array PropertyAlg INFO Properties of PropertyProxy: String PropertyAlg INFO ================================================= PropertyAlg INFO Changed property DoubleArray in catalogue +JobOptionsSvc ERROR Unable to set the property 'DoubleArray' of 'PropertyAlg'. Check option and algorithm names, type and bounds. PropertyAlg INFO Read handler called for property: 'PDouble':10100000. PropertyAlg INFO Update handler called for property: 'PDouble':10100000. -JobOptionsSvc ERROR Unable to set the property 'DoubleArray' of 'PropertyAlg'. Check option and algorithm names, type and bounds. PropertyAlg INFO DoubleArray = [-11, 2, 3.3, 0.0004] PropertyAlg INFO ================================================= PropertyProxy INFO Got property this.RInt = 101; diff --git a/GaudiExamples/tests/qmtest/refs/Properties_py.ref b/GaudiExamples/tests/qmtest/refs/Properties_py.ref index a4a987f2a6..1806009bba 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties_py.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties_py.ref @@ -112,12 +112,12 @@ PropertyAlg INFO Dump of the property catalogue.... PropertyAlg INFO Properties of AuditorSvc: Auditors PropertyAlg INFO Properties of Dummy1: Property PropertyAlg INFO Properties of Dummy2: Property -PropertyAlg INFO Properties of PropertyAlg: DoubleArray, Int64Array, Bool, UInt64Array, StringArray, PBool, DoublePairArray, PDoubleArray, PDouble, PInt, BoolArray, Double, PStringArray, OutputLevel, Int64, PBoolArray, IntArray, String, UInt64, IntPairArray, PIntArray, Int, DoubleArrayWithUnits, PString, DoubleArrayWithoutUnits +PropertyAlg INFO Properties of PropertyAlg: Bool, BoolArray, Double, DoubleArray, DoubleArrayWithUnits, DoubleArrayWithoutUnits, DoublePairArray, Int, Int64, Int64Array, IntArray, IntPairArray, OutputLevel, PBool, PBoolArray, PDouble, PDoubleArray, PInt, PIntArray, PString, PStringArray, String, StringArray, UInt64, UInt64Array PropertyAlg INFO ================================================= PropertyAlg INFO Changed property DoubleArray in catalogue +JobOptionsSvc ERROR Unable to set the property 'DoubleArray' of 'PropertyAlg'. Check option and algorithm names, type and bounds. PropertyAlg INFO Read handler called for property: 'PDouble':10100000. PropertyAlg INFO Update handler called for property: 'PDouble':10100000. -JobOptionsSvc ERROR Unable to set the property 'DoubleArray' of 'PropertyAlg'. Check option and algorithm names, type and bounds. PropertyAlg INFO DoubleArray = [-11, 2, 3.3, 0.0004, 1e-20, 1e+20] PropertyAlg INFO ================================================= PropertyProxy INFO Got property this.RInt = 101; diff --git a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h new file mode 100644 index 0000000000..84f6c365ca --- /dev/null +++ b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h @@ -0,0 +1,20 @@ +#pragma once + +#include + +namespace Gaudi +{ + namespace Interfaces + { + class IOptionsSvc + { + public: + virtual void set( const std::string& key, const std::string& value ) = 0; + virtual std::string get( const std::string& key ) const = 0; + virtual bool has( const std::string& key ) const = 0; + + protected: + virtual ~IOptionsSvc() = default; + }; + } +} diff --git a/GaudiKernel/GaudiKernel/IJobOptionsSvc.h b/GaudiKernel/GaudiKernel/IJobOptionsSvc.h index 4d7b854471..77f77e98c0 100644 --- a/GaudiKernel/GaudiKernel/IJobOptionsSvc.h +++ b/GaudiKernel/GaudiKernel/IJobOptionsSvc.h @@ -27,22 +27,24 @@ public: @param client Name of the client algorithm or service @param me Address of the interface IProperty of the client */ - virtual StatusCode setMyProperties( const std::string& client, IProperty* me ) = 0; + [[deprecated]] virtual StatusCode setMyProperties( const std::string& client, IProperty* me ) = 0; /// Add a property into the JobOptions catalog - virtual StatusCode addPropertyToCatalogue( const std::string& client, - const Gaudi::Details::PropertyBase& property ) = 0; + [[deprecated]] virtual StatusCode addPropertyToCatalogue( const std::string& client, + const Gaudi::Details::PropertyBase& property ) = 0; /// Remove a property from the JobOptions catalog - virtual StatusCode removePropertyFromCatalogue( const std::string& client, const std::string& name ) = 0; + [[deprecated]] virtual StatusCode removePropertyFromCatalogue( const std::string& client, + const std::string& name ) = 0; /// Get the properties associated to a given client - virtual const std::vector* getProperties( const std::string& client ) const = 0; + [[deprecated]] virtual const std::vector* + getProperties( const std::string& client ) const = 0; /// Get a property for a client - virtual const Gaudi::Details::PropertyBase* getClientProperty( const std::string& client, - const std::string& name ) const = 0; + [[deprecated]] virtual const Gaudi::Details::PropertyBase* getClientProperty( const std::string& client, + const std::string& name ) const = 0; /// Get the list of clients - virtual std::vector getClients() const = 0; + [[deprecated]] virtual std::vector getClients() const = 0; /** look for file 'File' into search path 'Path' * and read it to update existing JobOptionsCatalogue @@ -50,7 +52,7 @@ public: * @param Path search path * @return status code */ - virtual StatusCode readOptions( const std::string& file, const std::string& path = "" ) = 0; + [[deprecated]] virtual StatusCode readOptions( const std::string& file, const std::string& path = "" ) = 0; }; #endif // KERNEL_IJOBOPTIONSSVC_H diff --git a/GaudiKernel/GaudiKernel/JobHistory.h b/GaudiKernel/GaudiKernel/JobHistory.h index 74aadd4a6c..32531aac42 100644 --- a/GaudiKernel/GaudiKernel/JobHistory.h +++ b/GaudiKernel/GaudiKernel/JobHistory.h @@ -4,10 +4,11 @@ #include "GaudiKernel/HistoryObj.h" #include "GaudiKernel/IVersHistoryObj.h" -#include "GaudiKernel/PropertyFwd.h" +#include "GaudiKernel/Property.h" #include #include +#include #include #include #include @@ -23,7 +24,7 @@ class GAUDI_API JobHistory : public HistoryObj, virtual public IVersHistoryObj { public: - typedef std::vector> PropertyPairList; + typedef std::vector>>> PropertyPairList; private: // data std::string m_release_version; diff --git a/GaudiKernel/GaudiKernel/PropertyHolder.h b/GaudiKernel/GaudiKernel/PropertyHolder.h index c463957f25..dddbd87024 100644 --- a/GaudiKernel/GaudiKernel/PropertyHolder.h +++ b/GaudiKernel/GaudiKernel/PropertyHolder.h @@ -179,8 +179,12 @@ public: */ StatusCode setProperty( const std::string& n, const std::string& v ) override { - Gaudi::Details::PropertyBase* p = property( n ); - return ( p && p->fromString( v ) ) ? StatusCode::SUCCESS : StatusCode::FAILURE; + try { + Gaudi::Details::PropertyBase* p = property( n ); + return ( p && p->fromString( v ) ) ? StatusCode::SUCCESS : StatusCode::FAILURE; + } catch ( ... ) { + return StatusCode::FAILURE; + } } /** set the property form the value * diff --git a/GaudiKernel/src/Lib/JobHistory.cpp b/GaudiKernel/src/Lib/JobHistory.cpp index 3553a6afc7..1bfc79d0f9 100644 --- a/GaudiKernel/src/Lib/JobHistory.cpp +++ b/GaudiKernel/src/Lib/JobHistory.cpp @@ -84,8 +84,11 @@ const CLID& JobHistory::classID() void JobHistory::addProperty( const std::string& client, const PropertyBase* prop ) { - // if (m_props.find(prop) == m_props.end()) - m_ppl.emplace_back( client, prop ); + /// \fixme strip optional quotes around the string + std::string prop_value = prop->toString(); + if ( !prop_value.empty() && prop_value[0] == '"' && prop_value[prop_value.size() - 1] == '"' ) + prop_value = prop_value.substr( 1, prop_value.size() - 2 ); + m_ppl.emplace_back( client, std::make_unique>( prop->name(), prop_value ) ); } void JobHistory::dump( std::ostream& ost, const bool isXML, int /*ind*/ ) const @@ -103,8 +106,8 @@ void JobHistory::dump( std::ostream& ost, const bool isXML, int /*ind*/ ) const ost << "Properties: [" << endl; ; for ( const auto& ipprop : propertyPairs() ) { - const std::string& client = ipprop.first; - const PropertyBase* prop = ipprop.second; + const auto& client = ipprop.first; + const auto& prop = ipprop.second; ost << client << ": "; prop->fillStream( ost ); ost << endl; diff --git a/GaudiKernel/src/Lib/Property.cpp b/GaudiKernel/src/Lib/Property.cpp index 11a7c70d91..22272091e7 100644 --- a/GaudiKernel/src/Lib/Property.cpp +++ b/GaudiKernel/src/Lib/Property.cpp @@ -21,7 +21,8 @@ // ============================================================================ // Boost // ============================================================================ -#include "boost/algorithm/string/compare.hpp" +#include +#include // ============================================================================ namespace { @@ -132,7 +133,15 @@ void GaudiHandleProperty::toStream( std::ostream& out ) const StatusCode GaudiHandleProperty::fromString( const std::string& s ) { - m_pValue->setTypeAndName( s ); + boost::string_ref tn = s; + /// \fixme strip optional quotes around the string + if ( ( tn.starts_with( '"' ) && tn.ends_with( '"' ) ) || ( tn.starts_with( '\'' ) && tn.ends_with( '\'' ) ) ) { + tn.remove_prefix( 1 ); + tn.remove_suffix( 1 ); + m_pValue->setTypeAndName( static_cast( tn ) ); + } else { + m_pValue->setTypeAndName( s ); + } useUpdateHandler(); return StatusCode::SUCCESS; } diff --git a/GaudiMonitor/src/HistorySvc.cpp b/GaudiMonitor/src/HistorySvc.cpp index eba7923c28..54b96acfb4 100644 --- a/GaudiMonitor/src/HistorySvc.cpp +++ b/GaudiMonitor/src/HistorySvc.cpp @@ -413,7 +413,7 @@ void HistorySvc::dumpProperties( std::ofstream& ofs ) const ofs << "GLOBAL" << std::endl; for ( const auto& prop : m_jobHistory->propertyPairs() ) { - ofs << prop.first << " " << dumpProp( prop.second ) << std::endl; + ofs << prop.first << " " << dumpProp( prop.second.get() ) << std::endl; } ofs << std::endl << "SERVICES" << std::endl; @@ -744,8 +744,8 @@ void HistorySvc::dumpState( std::ofstream& ofs ) const std::string client_currently_open = "start"; for ( auto& item : m_jobHistory->propertyPairs() ) { // client is the name of the component of the current property - const std::string& client = item.first; - const Gaudi::Details::PropertyBase* prp = item.second; + const auto& client = item.first; + const auto& prp = item.second; if ( m_outputFileTypeXML ) { @@ -757,7 +757,7 @@ void HistorySvc::dumpState( std::ofstream& ofs ) const ofs << client << " "; } - ofs << dumpProp( prp, m_outputFileTypeXML, 6 ) << endl; + ofs << dumpProp( prp.get(), m_outputFileTypeXML, 6 ) << endl; client_currently_open = client; diff --git a/RootHistCnv/src/RFileCnv.cpp b/RootHistCnv/src/RFileCnv.cpp index 1742fb4e1b..511d1a8872 100644 --- a/RootHistCnv/src/RFileCnv.cpp +++ b/RootHistCnv/src/RFileCnv.cpp @@ -32,6 +32,9 @@ StatusCode RootHistCnv::RFileCnv::initialize() auto jobSvc = svcLoc->service( "JobOptionsSvc" ); auto prop = jobSvc->getClientProperty( "RFileCnv", "GlobalCompression" ); if ( prop ) m_compLevel = prop->toString(); + /// \fixme strip optional quotes around the string + if ( !m_compLevel.empty() && m_compLevel[0] == '"' && m_compLevel[m_compLevel.size() - 1] == '"' ) + m_compLevel = m_compLevel.substr( 1, m_compLevel.size() - 2 ); // initialise base class return RDirectoryCnv::initialize(); -- GitLab From 5de18da754d272fe1da35559aed8c6b52957a540 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Fri, 8 Dec 2017 12:08:56 +0100 Subject: [PATCH 04/53] Made IOptionsSvc lookup case insensitive for backward compatibility, but issuing a warning in case the wrong case is used --- GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp | 14 ++++++++++++++ GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h | 10 +++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp index 20c7d2cf78..7db46303f2 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp @@ -110,6 +110,20 @@ StatusCode JobOptionsSvc::setMyProperties( const std::string& client, IProperty* return fail ? StatusCode::FAILURE : StatusCode::SUCCESS; } +JobOptionsSvc::StorageType::const_iterator JobOptionsSvc::find( const std::string& key, bool warn ) const +{ + StorageType::const_iterator iter = m_options.find( key ); + if ( iter == m_options.end() ) { // try case insensitive lookup + iter = std::find_if( m_options.begin(), m_options.end(), + [&key]( auto& item ) { return Gaudi::Utils::iequal( item.first, key ); } ); + if ( warn && iter != m_options.end() ) { + warning() << "mismatching case for property name: actual name is " << key << " but " << iter->first + << " is in the option files" << endmsg; + } + } + return iter; +} + /// Get the list of clients std::vector JobOptionsSvc::getClients() const { diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h index 31329f2806..4bb0509503 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h @@ -27,18 +27,22 @@ public: typedef std::vector PropertiesT; private: - std::map m_options; + using StorageType = std::map; + + StorageType m_options; mutable std::map> m_old_iface_compat; mutable std::map m_old_iface_compat_2; + StorageType::const_iterator find( const std::string& key, bool warn ) const; + protected: void set( const std::string& key, const std::string& value ) override { m_options[key] = value; } std::string get( const std::string& key ) const override { - auto item = m_options.find( key ); + auto item = find( key, true ); return item != m_options.end() ? item->second : std::string{}; } - bool has( const std::string& key ) const override { return m_options.find( key ) != m_options.end(); } + bool has( const std::string& key ) const override { return find( key, false ) != m_options.end(); } public: // Constructor -- GitLab From 1f476ee43e0af4942b66133b98a6a81d4494ca74 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Wed, 13 Dec 2017 10:41:23 +0100 Subject: [PATCH 05/53] Added easy access to IOptionsSvc implementation --- GaudiKernel/CMakeLists.txt | 2 +- GaudiKernel/GaudiKernel/ISvcLocator.h | 12 ++++++++++++ GaudiKernel/src/Lib/ISvcLocator.cpp | 11 +++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 GaudiKernel/src/Lib/ISvcLocator.cpp diff --git a/GaudiKernel/CMakeLists.txt b/GaudiKernel/CMakeLists.txt index 76b96533d8..480ffbc2f9 100644 --- a/GaudiKernel/CMakeLists.txt +++ b/GaudiKernel/CMakeLists.txt @@ -60,7 +60,7 @@ endif() #---Libraries--------------------------------------------------------------- gaudi_add_library(GaudiKernel src/Lib/*.cpp ${extra_sources} LINK_LIBRARIES ${CMAKE_DL_LIBS} Boost ROOT TBB GaudiPluginService ${extra_libraries} - INCLUDE_DIRS Boost ROOT TBB + INCLUDE_DIRS Boost ROOT TBB cppgsl PUBLIC_HEADERS Gaudi GaudiKernel) #---Tests------------------------------------------------------------------- diff --git a/GaudiKernel/GaudiKernel/ISvcLocator.h b/GaudiKernel/GaudiKernel/ISvcLocator.h index f1754b7ada..a20a8a5f8a 100644 --- a/GaudiKernel/GaudiKernel/ISvcLocator.h +++ b/GaudiKernel/GaudiKernel/ISvcLocator.h @@ -6,12 +6,21 @@ #include "GaudiKernel/ISvcManager.h" #include "GaudiKernel/SmartIF.h" #include "GaudiKernel/TypeNameString.h" + #include #include // Forward class declaration class IService; +namespace Gaudi +{ + namespace Interfaces + { + class IOptionsSvc; + } +} + /** @class ISvcLocator ISvcLocator.h GaudiKernel/ISvcLocator.h The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to locate services in the framework. Clients use this @@ -110,6 +119,9 @@ public: { return SmartIF{this}; } + + /// Direct access to Gaudi::Interfaces::IOptionsSvc implementation. + Gaudi::Interfaces::IOptionsSvc& getOptsSvc(); }; #endif // GAUDI_ISVCLOCATOR_H diff --git a/GaudiKernel/src/Lib/ISvcLocator.cpp b/GaudiKernel/src/Lib/ISvcLocator.cpp new file mode 100644 index 0000000000..e6950eb1e5 --- /dev/null +++ b/GaudiKernel/src/Lib/ISvcLocator.cpp @@ -0,0 +1,11 @@ +#include "GaudiKernel/ISvcLocator.h" + +#include "Gaudi/Interfaces/IOptionsSvc.h" + +#include + +Gaudi::Interfaces::IOptionsSvc& ISvcLocator::getOptsSvc() +{ + using namespace Gaudi::Interfaces; + return *gsl::not_null( dynamic_cast( service( "JobOptionsSvc" ).get() ) ); +} -- GitLab From fb93fd9e0f7a92bebff3468293e1a71cfa1a06b6 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Mon, 18 Dec 2017 00:19:49 +0100 Subject: [PATCH 06/53] Improve IOptionsSvc interface - added default value to return for `get` - added `pop` method - added `item` method to get all options --- .../src/JobOptionsSvc/JobOptionsSvc.cpp | 2 +- .../src/JobOptionsSvc/JobOptionsSvc.h | 22 +++++++++++++++++-- GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h | 9 ++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp index 7db46303f2..ae8d5cfe79 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp @@ -59,7 +59,7 @@ StatusCode JobOptionsSvc::addPropertyToCatalogue( const std::string& // ============================================================================ StatusCode JobOptionsSvc::removePropertyFromCatalogue( const std::string& client, const std::string& name ) { - m_options.erase( client + '.' + name ); + pop( client + '.' + name ); return StatusCode::SUCCESS; } // ============================================================================ diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h index 4bb0509503..b3386aa0f8 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h @@ -37,12 +37,30 @@ private: protected: void set( const std::string& key, const std::string& value ) override { m_options[key] = value; } - std::string get( const std::string& key ) const override + std::string get( const std::string& key, const std::string& default_ = {} ) const override { auto item = find( key, true ); - return item != m_options.end() ? item->second : std::string{}; + return item != m_options.end() ? item->second : default_; + } + std::string pop( const std::string& key, const std::string& default_ = {} ) override + { + std::string result = default_; + + auto item = find( key, true ); + if ( item != m_options.end() ) { + m_options.erase( item ); + result = std::move( item->second ); + } + return result; } bool has( const std::string& key ) const override { return find( key, false ) != m_options.end(); } + std::vector> items() const override + { + std::vector> v; + v.reserve( m_options.size() ); + std::for_each( begin( m_options ), end( m_options ), [&v]( const auto& item ) { v.emplace_back( item ); } ); + return v; + } public: // Constructor diff --git a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h index 84f6c365ca..8b9f60a979 100644 --- a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h +++ b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h @@ -1,6 +1,8 @@ #pragma once #include +#include +#include namespace Gaudi { @@ -10,8 +12,11 @@ namespace Gaudi { public: virtual void set( const std::string& key, const std::string& value ) = 0; - virtual std::string get( const std::string& key ) const = 0; - virtual bool has( const std::string& key ) const = 0; + virtual std::string get( const std::string& key, const std::string& default_ = {} ) const = 0; + virtual std::string pop( const std::string& key, const std::string& default_ = {} ) = 0; + virtual bool has( const std::string& key ) const = 0; + + virtual std::vector> items() const = 0; protected: virtual ~IOptionsSvc() = default; -- GitLab From 01549619380b879c91dccfa761c4c8447ef7cdf9 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Wed, 13 Dec 2017 11:18:38 +0100 Subject: [PATCH 07/53] Replaced Alg/Tool/Svc setProperties with PropertyHolder method --- Gaudi/python/Gaudi/Main.py | 18 +++++---- GaudiCommonSvc/src/ChronoStatSvc.cpp | 8 ---- .../PersistencySvc/EvtCollectionStream.cpp | 2 - .../src/ApplicationMgr/ApplicationMgr.cpp | 9 +---- GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp | 28 +------------- GaudiCoreSvc/src/ApplicationMgr/ToolSvc.h | 2 - GaudiCoreSvc/src/IncidentSvc/IncidentSvc.cpp | 19 ---------- GaudiCoreSvc/src/IncidentSvc/IncidentSvc.h | 2 - GaudiExamples/options/FileMgrTest.opts | 2 +- GaudiExamples/options/THistRead.opts | 2 +- GaudiExamples/options/THistWrite.opts | 2 +- .../src/RandomNumber/RandomNumberAlg.cpp | 5 ++- GaudiKernel/GaudiKernel/AlgTool.h | 10 ++--- GaudiKernel/GaudiKernel/Algorithm.h | 9 ----- GaudiKernel/GaudiKernel/Auditor.h | 7 ---- GaudiKernel/GaudiKernel/PropertyHolder.h | 31 +++++++++++++--- GaudiKernel/GaudiKernel/Service.h | 5 --- GaudiKernel/src/Lib/AlgTool.cpp | 11 ------ GaudiKernel/src/Lib/Algorithm.cpp | 20 +++------- GaudiKernel/src/Lib/Auditor.cpp | 23 ++++-------- GaudiKernel/src/Lib/Bootstrap.cpp | 9 +++-- GaudiKernel/src/Lib/Service.cpp | 29 ++++----------- GaudiPartProp/src/ParticlePropertySvc.cpp | 6 --- GaudiSvc/options/MultiStore.opts | 2 +- GaudiSvc/options/StoreExplorer.opts | 4 +- GaudiSvc/src/NTupleSvc/NTupleSvc.cpp | 23 +++++------- GaudiSvc/src/RndmGenSvc/RndmEngine.cpp | 8 ---- GaudiSvc/src/RndmGenSvc/RndmEngine.h | 2 - GaudiSvc/src/RndmGenSvc/RndmGenSvc.cpp | 37 +++++++++---------- RootHistCnv/src/PersSvc.cpp | 5 --- 30 files changed, 103 insertions(+), 237 deletions(-) diff --git a/Gaudi/python/Gaudi/Main.py b/Gaudi/python/Gaudi/Main.py index 85b6884636..35cf194e5d 100644 --- a/Gaudi/python/Gaudi/Main.py +++ b/Gaudi/python/Gaudi/Main.py @@ -63,6 +63,9 @@ class BootstrapHelper(object): def getService(self, name): return self.lib.py_bootstrap_getService(self.ptr, name) + def getOptionsSvc(self): + return self.lib.py_bootstrap_getOptionsSvc(self.ptr) + def setProperty(self, name, value): return BootstrapHelper.StatusCode(self.lib.py_bootstrap_setProperty(self.ptr, name, value)) @@ -92,11 +95,11 @@ class BootstrapHelper(object): functions = [('createApplicationMgr', IInterface_p, []), ('getService', IInterface_p, [IInterface_p, c_char_p]), + ('getOptionsSvc', c_void_p, [IInterface_p]), ('setProperty', c_bool, [ IInterface_p, c_char_p, c_char_p]), ('getProperty', c_char_p, [IInterface_p, c_char_p]), - ('addPropertyToCatalogue', c_bool, [ - IInterface_p, c_char_p, c_char_p, c_char_p]), + ('setOption', None, [c_void_p, c_char_p, c_char_p]), ('ROOT_VERSION_CODE', c_int, []), ] @@ -342,11 +345,10 @@ class gaudimain(object): self.log.error('Cannot set property %s.%s to %s', comp, p, v) sys.exit(10) - # feed JobOptionsSvc - comp = 'JobOptionsSvc' - jos = self.g.getService(comp) - if not jos: - self.log.error('Cannot get service %s', comp) + # feed options service + optssvc = self.g.getOptionsSvc() + if not optssvc: + self.log.error('Cannot get options service') sys.exit(10) for n in getNeededConfigurables(): c = Configurable.allConfigurables[n] @@ -363,7 +365,7 @@ class gaudimain(object): v = '"%s"' % v # need double quotes elif type(v) == long: v = '%d' % v # prevent pending 'L' - _bootstrap.addPropertyToCatalogue(jos, n, p, str(v)) + _bootstrap.setOption(optssvc, '.'.join((n, p)), str(v)) if hasattr(Configurable, "_configurationLocked"): Configurable._configurationLocked = True self.log.debug('basicInit: done') diff --git a/GaudiCommonSvc/src/ChronoStatSvc.cpp b/GaudiCommonSvc/src/ChronoStatSvc.cpp index d4b1aab54a..9b0c09e6a5 100644 --- a/GaudiCommonSvc/src/ChronoStatSvc.cpp +++ b/GaudiCommonSvc/src/ChronoStatSvc.cpp @@ -98,14 +98,6 @@ StatusCode ChronoStatSvc::initialize() { StatusCode sc = Service::initialize(); if ( sc.isFailure() ) return sc; - /// - // Set my own properties - sc = setProperties(); - - if ( sc.isFailure() ) { - error() << "setting my properties" << endmsg; - return StatusCode::FAILURE; - } // only add an EndEvent listener if per-event output requested if ( !m_perEventFile.empty() ) { diff --git a/GaudiCommonSvc/src/PersistencySvc/EvtCollectionStream.cpp b/GaudiCommonSvc/src/PersistencySvc/EvtCollectionStream.cpp index 304e60850b..f96d7a4821 100644 --- a/GaudiCommonSvc/src/PersistencySvc/EvtCollectionStream.cpp +++ b/GaudiCommonSvc/src/PersistencySvc/EvtCollectionStream.cpp @@ -23,8 +23,6 @@ DECLARE_COMPONENT( EvtCollectionStream ) // initialize data writer StatusCode EvtCollectionStream::initialize() { - // Use the Job options service to set the Algorithm's parameters - setProperties(); // Get access to the DataManagerSvc m_pTupleSvc = serviceLocator()->service( m_storeName ); if ( !m_pTupleSvc ) { diff --git a/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp b/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp index 2ec2241b3b..5df568cf36 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp @@ -157,13 +157,12 @@ StatusCode ApplicationMgr::i_startup() log << MSG::FATAL << "Error creating JobOptionsSvc" << endmsg; return StatusCode::FAILURE; } - // Get the useful interface from Message services + // Get the useful interface from JobOptionsSvc services m_jobOptionsSvc = m_svcLocator->service( "JobOptionsSvc" ); if ( !m_jobOptionsSvc ) { log << MSG::FATAL << "Error retrieving JobOptionsSvc." << endmsg; return StatusCode::FAILURE; } - auto jobOptsIProp = jobsvc.as(); if ( !jobOptsIProp ) { log << MSG::FATAL << "Error locating JobOptionsSvc" << endmsg; @@ -266,11 +265,7 @@ StatusCode ApplicationMgr::configure() MsgStream log( m_messageSvc, name() ); // Get my own options using the Job options service if ( log.level() <= MSG::DEBUG ) log << MSG::DEBUG << "Getting my own properties" << endmsg; - sc = m_jobOptionsSvc->setMyProperties( name(), this ); - if ( !sc.isSuccess() ) { - log << MSG::WARNING << "Problems getting my properties from JobOptionsSvc" << endmsg; - return sc; - } + setPropertiesFrom( serviceLocator()->getOptsSvc() ); } // Make sure that the OutputLevel is in sync diff --git a/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp b/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp index c2337e5b18..881a191dd3 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp @@ -51,26 +51,6 @@ ToolSvc::~ToolSvc() std::for_each( std::begin( m_observers ), std::end( m_observers ), [&]( IToolSvc::Observer* obs ) { obs->setUnregister( {} ); } ); } -//------------------------------------------------------------------------------ -StatusCode ToolSvc::initialize() -//------------------------------------------------------------------------------ -{ - - // initialize the Service Base class - StatusCode status = Service::initialize(); - if ( UNLIKELY( status.isFailure() ) ) { - error() << "Unable to initialize the Service" << endmsg; - return status; - } - - // set my own (ToolSvc) properties via the jobOptionService - if ( UNLIKELY( setProperties().isFailure() ) ) { - error() << "Unable to set base properties" << endmsg; - return StatusCode::FAILURE; - } - - return status; -} //------------------------------------------------------------------------------ StatusCode ToolSvc::finalize() @@ -522,13 +502,7 @@ StatusCode ToolSvc::create( const std::string& tooltype, const std::string& tool // to downcast IAlgTool to AlgTool in order to set the properties via the JobOptions // service AlgTool* mytool = dynamic_cast( toolguard.get() ); - if ( mytool ) { - StatusCode sc = mytool->setProperties(); - if ( UNLIKELY( sc.isFailure() ) ) { - error() << "Error setting properties for tool '" << fullname << "'" << endmsg; - return sc; - } - } + if ( mytool ) mytool->setPropertiesFrom( serviceLocator()->getOptsSvc() ); // Initialize the Tool StatusCode sc( StatusCode::FAILURE, true ); diff --git a/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.h b/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.h index 8369fa0cfc..423663eaa3 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.h +++ b/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.h @@ -30,8 +30,6 @@ public: /// Destructor. ~ToolSvc() override; - /// Initialize the service. - StatusCode initialize() override; /// Finalize the service. StatusCode finalize() override; diff --git a/GaudiCoreSvc/src/IncidentSvc/IncidentSvc.cpp b/GaudiCoreSvc/src/IncidentSvc/IncidentSvc.cpp index 2e74d2d212..d6b644e341 100644 --- a/GaudiCoreSvc/src/IncidentSvc/IncidentSvc.cpp +++ b/GaudiCoreSvc/src/IncidentSvc/IncidentSvc.cpp @@ -52,25 +52,6 @@ IncidentSvc::IncidentSvc( const std::string& name, ISvcLocator* svc ) : base_cla // ============================================================================ IncidentSvc::~IncidentSvc() { std::unique_lock lock( m_listenerMapMutex ); } // ============================================================================ -// Inherited Service overrides: -// ============================================================================ -StatusCode IncidentSvc::initialize() -{ - // initialize the Service Base class - StatusCode sc = Service::initialize(); - if ( sc.isFailure() ) return sc; - - m_currentIncidentType = nullptr; - - // set my own (IncidentSvc) properties via the jobOptionService - sc = setProperties(); - if ( UNLIKELY( sc.isFailure() ) ) { - error() << "Could not set my properties" << endmsg; - return sc; - } - return sc; -} -// ============================================================================ StatusCode IncidentSvc::finalize() { DEBMSG << m_timer.outputUserTime( "Incident timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] ", System::milliSec ) diff --git a/GaudiCoreSvc/src/IncidentSvc/IncidentSvc.h b/GaudiCoreSvc/src/IncidentSvc/IncidentSvc.h index bd53a49065..c8e940946e 100644 --- a/GaudiCoreSvc/src/IncidentSvc/IncidentSvc.h +++ b/GaudiCoreSvc/src/IncidentSvc/IncidentSvc.h @@ -59,8 +59,6 @@ private: public: // Inherited Service overrides: - // - StatusCode initialize() override; StatusCode finalize() override; // IIncidentSvc interfaces overwrite diff --git a/GaudiExamples/options/FileMgrTest.opts b/GaudiExamples/options/FileMgrTest.opts index 5502d8f6df..5e2c4b0d77 100644 --- a/GaudiExamples/options/FileMgrTest.opts +++ b/GaudiExamples/options/FileMgrTest.opts @@ -13,7 +13,7 @@ ApplicationMgr.TopAlg = { "FileMgrTest" }; // Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL ) MessageSvc.OutputLevel = 3; -MessageSvc.UseColors = true; +MessageSvc.useColors = true; FileMgrTest.OutputLevel = 2; FileMgr.OutputLevel = 2; FileMgr.LogFile = "filemgr.log"; diff --git a/GaudiExamples/options/THistRead.opts b/GaudiExamples/options/THistRead.opts index a3d208430f..9a5ffad2c9 100644 --- a/GaudiExamples/options/THistRead.opts +++ b/GaudiExamples/options/THistRead.opts @@ -13,7 +13,7 @@ ApplicationMgr.TopAlg = { "THistRead" }; // Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL ) MessageSvc.OutputLevel = 3; -MessageSvc.UseColors = true; +MessageSvc.useColors = true; THistSvc.OutputLevel = 2; ApplicationMgr.OutputLevel = 1; ServiceManager.OutputLevel = 2; diff --git a/GaudiExamples/options/THistWrite.opts b/GaudiExamples/options/THistWrite.opts index a56efac6d7..fbfa5d5ef5 100644 --- a/GaudiExamples/options/THistWrite.opts +++ b/GaudiExamples/options/THistWrite.opts @@ -13,7 +13,7 @@ ApplicationMgr.TopAlg = { "THistWrite" }; // Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL ) MessageSvc.OutputLevel = 3; -MessageSvc.UseColors = true; +MessageSvc.useColors = true; THistSvc.OutputLevel = 2; ApplicationMgr.OutputLevel = 1; ServiceManager.OutputLevel = 2; diff --git a/GaudiExamples/src/RandomNumber/RandomNumberAlg.cpp b/GaudiExamples/src/RandomNumber/RandomNumberAlg.cpp index 813c873db3..7af1e17ddd 100644 --- a/GaudiExamples/src/RandomNumber/RandomNumberAlg.cpp +++ b/GaudiExamples/src/RandomNumber/RandomNumberAlg.cpp @@ -46,8 +46,9 @@ RandomNumberAlg::~RandomNumberAlg() // nothing apart from print out info messages. StatusCode RandomNumberAlg::initialize() { - // Use the Job options service to set the Algorithm's parameters - StatusCode status = setProperties(); + StatusCode status = Algorithm::initialize(); + if ( !status ) return status; + // // The first example is for purists: // Every step is done by hand....tends to become complicated, diff --git a/GaudiKernel/GaudiKernel/AlgTool.h b/GaudiKernel/GaudiKernel/AlgTool.h index 328d3d49d1..38de517807 100644 --- a/GaudiKernel/GaudiKernel/AlgTool.h +++ b/GaudiKernel/GaudiKernel/AlgTool.h @@ -31,6 +31,7 @@ class ToolHandleInfo; #include // Forward declarations +class ToolSvc; /** @class AlgTool AlgTool.h GaudiKernel/AlgTool.h * @@ -48,6 +49,8 @@ class GAUDI_API AlgTool : public DataHandleHolderBase< PropertyHolder>>> { + friend ToolSvc; + public: using Factory = Gaudi::PluginService::Factory; @@ -115,13 +118,6 @@ public: /// The standard ToolSvc service, Return a pointer to the service if present IToolSvc* toolSvc() const; - /** Method for setting declared properties to the values specified in the - * jobOptions via the job option service. This method is called by the - * ToolSvc after creating the concrete tool, before passing it to the - * requesting parent and does not need to be called explicitly. - */ - StatusCode setProperties(); - /** Access a service by name, * creating it if it doesn't already exist. */ diff --git a/GaudiKernel/GaudiKernel/Algorithm.h b/GaudiKernel/GaudiKernel/Algorithm.h index a873f0c67c..74dfc044de 100644 --- a/GaudiKernel/GaudiKernel/Algorithm.h +++ b/GaudiKernel/GaudiKernel/Algorithm.h @@ -353,15 +353,6 @@ public: /// List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms std::vector* subAlgorithms(); - /** Set the algorithm's properties. - * This method requests the job options service - * to set the values of any declared properties. - * The method is invoked from within sysInitialize() by the framework - * and does not need to be explicitly - * called by a concrete algorithm. - */ - StatusCode setProperties(); - // ========================================================================== using PropertyHolderImpl::declareProperty; diff --git a/GaudiKernel/GaudiKernel/Auditor.h b/GaudiKernel/GaudiKernel/Auditor.h index 4d859c47cd..17c0b33fee 100644 --- a/GaudiKernel/GaudiKernel/Auditor.h +++ b/GaudiKernel/GaudiKernel/Auditor.h @@ -122,13 +122,6 @@ public: return serviceLocator()->service( name, createIf ); } - /** Set the auditor's properties. This method requests the job options service - to set the values of any declared properties. The method is invoked from - within sysInitialize() by the framework and does not need to be explicitly - called by a concrete auditor. - */ - StatusCode setProperties(); - private: std::string m_name; ///< Auditor's name for identification diff --git a/GaudiKernel/GaudiKernel/PropertyHolder.h b/GaudiKernel/GaudiKernel/PropertyHolder.h index dddbd87024..aaa069f5c8 100644 --- a/GaudiKernel/GaudiKernel/PropertyHolder.h +++ b/GaudiKernel/GaudiKernel/PropertyHolder.h @@ -24,6 +24,7 @@ #include "GaudiKernel/Property.h" #include "GaudiKernel/detected.h" +#include "Gaudi/Interfaces/IOptionsSvc.h" // ============================================================================ namespace Gaudi { @@ -140,7 +141,7 @@ public: if ( !rsvc ) return nullptr; const std::string& nam = rname.empty() ? name : rname; Gaudi::Details::PropertyBase* p = property( nam, rsvc->getProperties() ); - m_remoteProperties.emplace_back( name, std::make_pair( rsvc, nam ) ); + m_remoteProperties.emplace_back( RemProperty{name, rsvc, nam} ); return p; } @@ -186,6 +187,7 @@ public: return StatusCode::FAILURE; } } + inline StatusCode setProperty( const std::string& n, const char* v ) { return setProperty( n, std::string{v} ); } /** set the property form the value * * @code @@ -292,14 +294,29 @@ protected: if ( lp ) return lp; // look for remote property for ( const auto& it : m_remoteProperties ) { - if ( !Gaudi::Utils::iequal( it.first, name ) ) continue; - const IProperty* p = it.second.first; + if ( !Gaudi::Utils::iequal( it.name, name ) ) continue; + const IProperty* p = it.owner; if ( !p ) continue; - return property( it.second.second, p->getProperties() ); + return property( it.remName, p->getProperties() ); } return nullptr; // RETURN } + void setPropertiesFrom( const Gaudi::Interfaces::IOptionsSvc& optsSvc ) + { + auto set_prop = [&optsSvc, this]( auto prop ) { + const std::string prop_full_name = this->name() + '.' + prop->name(); + if ( optsSvc.has( prop_full_name ) ) { + if ( !prop->fromString( optsSvc.get( prop_full_name ) ) ) + throw std::invalid_argument( "cannot set " + prop->name() + " of " + this->name() ); + } + }; + std::for_each( begin( m_properties ), end( m_properties ), set_prop ); + std::for_each( begin( m_remoteProperties ), end( m_remoteProperties ), [&set_prop, this]( auto& rem ) { + if ( rem.owner ) set_prop( this->property( rem.remName, rem.owner->getProperties() ) ); + } ); + } + private: /// get the property by name form the proposed list Gaudi::Details::PropertyBase* property( const std::string& name, @@ -325,7 +342,11 @@ private: } typedef std::vector Properties; - typedef std::pair> RemProperty; + struct RemProperty { + std::string name; + IProperty* owner = nullptr; + std::string remName; + }; typedef std::vector RemoteProperties; /// Collection of all declared properties. diff --git a/GaudiKernel/GaudiKernel/Service.h b/GaudiKernel/GaudiKernel/Service.h index 511ed7ddac..c778ac3ac7 100644 --- a/GaudiKernel/GaudiKernel/Service.h +++ b/GaudiKernel/GaudiKernel/Service.h @@ -73,11 +73,6 @@ public: /** Retrieve pointer to service locator */ SmartIF& serviceLocator() const override; - /** Method for setting declared properties to the values - specified for the job. - */ - StatusCode setProperties(); - /** Access a service by name, creating it if it doesn't already exist. */ template diff --git a/GaudiKernel/src/Lib/AlgTool.cpp b/GaudiKernel/src/Lib/AlgTool.cpp index 4ee6fc7b13..bc3724be0d 100644 --- a/GaudiKernel/src/Lib/AlgTool.cpp +++ b/GaudiKernel/src/Lib/AlgTool.cpp @@ -112,17 +112,6 @@ IToolSvc* AlgTool::toolSvc() const return m_ptoolSvc.get(); } -//------------------------------------------------------------------------------ -StatusCode AlgTool::setProperties() -//------------------------------------------------------------------------------ -{ - if ( !m_svcLocator ) return StatusCode::FAILURE; - auto jos = m_svcLocator->service( "JobOptionsSvc" ); - if ( !jos ) return StatusCode::FAILURE; - - return jos->setMyProperties( name(), this ); -} - //------------------------------------------------------------------------------ AlgTool::AlgTool( const std::string& type, const std::string& name, const IInterface* parent ) //------------------------------------------------------------------------------ diff --git a/GaudiKernel/src/Lib/Algorithm.cpp b/GaudiKernel/src/Lib/Algorithm.cpp index 87d2acb669..12ccf40521 100644 --- a/GaudiKernel/src/Lib/Algorithm.cpp +++ b/GaudiKernel/src/Lib/Algorithm.cpp @@ -86,8 +86,12 @@ StatusCode Algorithm::sysInitialize() // has already been initialized. if ( Gaudi::StateMachine::INITIALIZED <= FSMState() ) return StatusCode::SUCCESS; + // this initializes the messaging, in case property update handlers need to print + // and update the property value bypassing the update handler + m_outputLevel.value() = setUpMessaging(); + // Set the Algorithm's properties - if ( !setProperties() ) return StatusCode::FAILURE; + setPropertiesFrom( serviceLocator()->getOptsSvc() ); // Bypass the initialization if the algorithm is disabled. // Need to do this after setProperties. @@ -833,20 +837,6 @@ SmartIF& Algorithm::whiteboard() const { return get_svc_( m_WB SmartIF& Algorithm::serviceLocator() const { return *const_cast*>( &m_pSvcLocator ); } -// Use the job options service to set declared properties -StatusCode Algorithm::setProperties() -{ - if ( !m_pSvcLocator ) return StatusCode::FAILURE; - auto jos = m_pSvcLocator->service( "JobOptionsSvc" ); - if ( !jos ) return StatusCode::FAILURE; - - // this initializes the messaging, in case property update handlers need to print - // and update the property value bypassing the update handler - m_outputLevel.value() = setUpMessaging(); - - return jos->setMyProperties( name(), this ); -} - StatusCode Algorithm::createSubAlgorithm( const std::string& type, const std::string& name, Algorithm*& pSubAlgorithm ) { if ( !m_pSvcLocator ) return StatusCode::FAILURE; diff --git a/GaudiKernel/src/Lib/Auditor.cpp b/GaudiKernel/src/Lib/Auditor.cpp index 860278a844..5da920d99f 100644 --- a/GaudiKernel/src/Lib/Auditor.cpp +++ b/GaudiKernel/src/Lib/Auditor.cpp @@ -28,8 +28,13 @@ StatusCode Auditor::sysInitialize() // Setup the default service ... this should be upgraded so as to be configurable. if ( !m_pSvcLocator ) return StatusCode::FAILURE; - // Set the Auditor's properties - sc = setProperties(); + // this initializes the messaging, in case property update handlers need to print + // and update the property value bypassing the update handler + m_outputLevel.value() = setUpMessaging(); + + // Set the Algorithm's properties + setPropertiesFrom( serviceLocator()->getOptsSvc() ); + if ( !sc.isSuccess() ) return StatusCode::FAILURE; { @@ -204,17 +209,3 @@ const std::string& Auditor::name() const { return m_name; } bool Auditor::isEnabled() const { return m_isEnabled; } SmartIF& Auditor::serviceLocator() const { return m_pSvcLocator; } - -// Use the job options service to set declared properties -StatusCode Auditor::setProperties() -{ - if ( !m_pSvcLocator ) return StatusCode::FAILURE; - auto jos = service( "JobOptionsSvc" ); - if ( !jos ) return StatusCode::FAILURE; - - // this initializes the messaging, in case property update handlers need to print - // and update the property value bypassing the update handler - m_outputLevel.value() = setUpMessaging(); - - return jos->setMyProperties( name(), this ); -} diff --git a/GaudiKernel/src/Lib/Bootstrap.cpp b/GaudiKernel/src/Lib/Bootstrap.cpp index 60ce0b1444..5212607cbf 100644 --- a/GaudiKernel/src/Lib/Bootstrap.cpp +++ b/GaudiKernel/src/Lib/Bootstrap.cpp @@ -240,6 +240,10 @@ IInterface* PyHelper( getService )( IInterface* app, char* name ) auto svcloc = SmartIF( app ); return svcloc ? svcloc->service( name ).get() : nullptr; } +Gaudi::Interfaces::IOptionsSvc* PyHelper( getOptionsSvc )( IInterface* app ) +{ + return &( SmartIF( app )->getOptsSvc() ); +} bool PyHelper( setProperty )( IInterface* p, char* name, char* value ) { auto prop = SmartIF( p ); @@ -255,10 +259,9 @@ bool PyHelper( configureApp )( IInterface* app ) auto ui = SmartIF( app ); return ui && ui->configure().isSuccess(); } -bool PyHelper( addPropertyToCatalogue )( IInterface* p, char* comp, char* name, char* value ) +void PyHelper( setOption )( Gaudi::Interfaces::IOptionsSvc* opts, char* name, char* value ) { - auto jos = SmartIF( p ); - return jos && jos->addPropertyToCatalogue( comp, Gaudi::Property( name, value ) ).isSuccess(); + opts->set( name, value ); } int PyHelper( ROOT_VERSION_CODE )() { return ROOT_VERSION_CODE; } diff --git a/GaudiKernel/src/Lib/Service.cpp b/GaudiKernel/src/Lib/Service.cpp index 3f385f924d..55bc2f335b 100644 --- a/GaudiKernel/src/Lib/Service.cpp +++ b/GaudiKernel/src/Lib/Service.cpp @@ -37,8 +37,14 @@ void Service::sysInitialize_imp() // check if we want to audit the initialize ( m_auditorInitialize ) ? auditorSvc().get() : nullptr, IAuditor::Initialize ); - m_initSC = setProperties(); - if ( !m_initSC ) return; + // initialize messaging (except for MessageSvc) + if ( name() != "MessageSvc" ) { + // this initializes the messaging, in case property update handlers need to print + // and update the property value bypassing the update handler + m_outputLevel.value() = setUpMessaging(); + } + + setPropertiesFrom( serviceLocator()->getOptsSvc() ); m_initSC = initialize(); // This should change the state to Gaudi::StateMachine::CONFIGURED if ( m_initSC.isSuccess() ) m_state = m_targetState; @@ -290,25 +296,6 @@ const std::string& Service::name() const { return m_name; } //--- Retrieve pointer to service locator SmartIF& Service::serviceLocator() const { return m_svcLocator; } -// Use the job options service to set declared properties -StatusCode Service::setProperties() -{ - const bool CREATEIF( true ); - auto jos = serviceLocator()->service( "JobOptionsSvc", CREATEIF ); - if ( !jos ) { - throw GaudiException( "Service [JobOptionsSvc] not found", name(), StatusCode::FAILURE ); - } - - // initialize messaging (except for MessageSvc) - if ( name() != "MessageSvc" ) { - // this initializes the messaging, in case property update handlers need to print - // and update the property value bypassing the update handler - m_outputLevel.value() = setUpMessaging(); - } - - return jos->setMyProperties( name(), this ); -} - //--- Local methods // Standard Constructor Service::Service( std::string name, ISvcLocator* svcloc ) : m_name( std::move( name ) ), m_svcLocator( svcloc ) diff --git a/GaudiPartProp/src/ParticlePropertySvc.cpp b/GaudiPartProp/src/ParticlePropertySvc.cpp index 2d19114c27..35354c2297 100644 --- a/GaudiPartProp/src/ParticlePropertySvc.cpp +++ b/GaudiPartProp/src/ParticlePropertySvc.cpp @@ -62,12 +62,6 @@ namespace Gaudi return sc; } - sc = setProperties(); - if ( sc.isFailure() ) { - error() << " Could not set the properties " << endmsg; - return sc; - } - m_fileAccess = service( "VFSSvc" ); if ( !m_fileAccess ) { error() << " Cannot retrieve the VFS service " << endmsg; diff --git a/GaudiSvc/options/MultiStore.opts b/GaudiSvc/options/MultiStore.opts index 9c781d1572..276567d5b8 100644 --- a/GaudiSvc/options/MultiStore.opts +++ b/GaudiSvc/options/MultiStore.opts @@ -3,7 +3,7 @@ EventDataSvc.Partitions = {"NAME='Buffer1' TYPE='EvtDataSvc/EvtBuff1'", "NAME='Buffer2' TYPE='EvtDataSvc/EvtBuff2'"}; EventDataSvc.DefaultPartition = "Buffer1"; ApplicationMgr.TopAlg += { "PartitionSwitchAlg/Switcher", "StoreExplorerAlg/Exp" }; -Exp.Printfreq = 1.0; +Exp.PrintFreq = 1.0; Switcher.Partition = "Buffer2"; Switcher.Tool = "PartitionSwitchTool"; Switcher.PartitionSwitchTool.Actor = "EventDataSvc"; diff --git a/GaudiSvc/options/StoreExplorer.opts b/GaudiSvc/options/StoreExplorer.opts index ed0ef55374..5af798d84e 100644 --- a/GaudiSvc/options/StoreExplorer.opts +++ b/GaudiSvc/options/StoreExplorer.opts @@ -1,5 +1,3 @@ ApplicationMgr.TopAlg += { "StoreExplorerAlg/Explorer" }; -Explorer.Printfreq = 1.0; +Explorer.PrintFreq = 1.0; Explorer.Load = 1; - - diff --git a/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp b/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp index 0351cc2f68..6994b886e0 100644 --- a/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp +++ b/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp @@ -59,19 +59,16 @@ StatusCode NTupleSvc::initialize() { StatusCode status = DataSvc::initialize(); if ( status.isSuccess() ) { - status = setProperties(); - if ( status.isSuccess() ) { - StatusCode iret( StatusCode::SUCCESS, true ); - DataObject* root = new NTuple::Directory(); - status = setRoot( m_rootName, root ); - for ( auto& i : m_output ) { - iret = connect( i ); - if ( !iret.isSuccess() ) status = iret; - } - for ( auto& j : m_input ) { - iret = connect( j ); - if ( !iret.isSuccess() ) status = iret; - } + StatusCode iret( StatusCode::SUCCESS, true ); + DataObject* root = new NTuple::Directory(); + status = setRoot( m_rootName, root ); + for ( auto& i : m_output ) { + iret = connect( i ); + if ( !iret.isSuccess() ) status = iret; + } + for ( auto& j : m_input ) { + iret = connect( j ); + if ( !iret.isSuccess() ) status = iret; } } return status; diff --git a/GaudiSvc/src/RndmGenSvc/RndmEngine.cpp b/GaudiSvc/src/RndmGenSvc/RndmEngine.cpp index 5f67f0be1a..c574a2ff6e 100644 --- a/GaudiSvc/src/RndmGenSvc/RndmEngine.cpp +++ b/GaudiSvc/src/RndmGenSvc/RndmEngine.cpp @@ -27,14 +27,6 @@ #include "GaudiKernel/MsgStream.h" #include "RndmEngine.h" -/// Service override: initialization -StatusCode RndmEngine::initialize() -{ - StatusCode status = Service::initialize(); - if ( status.isSuccess() ) status = setProperties(); - return status; -} - /** IRndmEngine interface implementation */ /// Input serialization from stream buffer. Restores the status of the generator engine. StreamBuffer& RndmEngine::serialize( StreamBuffer& str ) { return str; } diff --git a/GaudiSvc/src/RndmGenSvc/RndmEngine.h b/GaudiSvc/src/RndmGenSvc/RndmEngine.h index c733c161b8..7dad40f222 100644 --- a/GaudiSvc/src/RndmGenSvc/RndmEngine.h +++ b/GaudiSvc/src/RndmGenSvc/RndmEngine.h @@ -46,8 +46,6 @@ protected: using extends::extends; public: - /// Service override: initialization - StatusCode initialize() override; /// Single shot returning single random number double rndm() const override; /** Multiple shots returning vector with flat random numbers. diff --git a/GaudiSvc/src/RndmGenSvc/RndmGenSvc.cpp b/GaudiSvc/src/RndmGenSvc/RndmGenSvc.cpp index f1b9921a3b..9e47f7792d 100644 --- a/GaudiSvc/src/RndmGenSvc/RndmGenSvc.cpp +++ b/GaudiSvc/src/RndmGenSvc/RndmGenSvc.cpp @@ -38,26 +38,23 @@ StatusCode RndmGenSvc::initialize() auto mgr = serviceLocator()->as(); if ( status.isSuccess() ) { - status = setProperties(); - if ( status.isSuccess() ) { // Check if the Engine service exists: - // FIXME: (MCl) why RndmGenSvc cannot create the engine service in a standard way? - const bool CREATE = false; - std::string machName = name() + ".Engine"; - auto engine = serviceLocator()->service( machName, CREATE ); - if ( !engine && mgr ) { - using Gaudi::Utils::TypeNameString; - engine = mgr->createService( TypeNameString( machName, m_engineName ) ); - } - if ( engine ) { - auto serial = engine.as(); - auto service = engine.as(); - if ( serial && service ) { - status = service->sysInitialize(); - if ( status.isSuccess() ) { - m_engine = engine; - m_serialize = serial; - info() << "Using Random engine:" << m_engineName.value() << endmsg; - } + // FIXME: (MCl) why RndmGenSvc cannot create the engine service in a standard way? + const bool CREATE = false; + std::string machName = name() + ".Engine"; + auto engine = serviceLocator()->service( machName, CREATE ); + if ( !engine && mgr ) { + using Gaudi::Utils::TypeNameString; + engine = mgr->createService( TypeNameString( machName, m_engineName ) ); + } + if ( engine ) { + auto serial = engine.as(); + auto service = engine.as(); + if ( serial && service ) { + status = service->sysInitialize(); + if ( status.isSuccess() ) { + m_engine = engine; + m_serialize = serial; + info() << "Using Random engine:" << m_engineName.value() << endmsg; } } } diff --git a/RootHistCnv/src/PersSvc.cpp b/RootHistCnv/src/PersSvc.cpp index 803fc91e54..531e784b71 100644 --- a/RootHistCnv/src/PersSvc.cpp +++ b/RootHistCnv/src/PersSvc.cpp @@ -37,11 +37,6 @@ StatusCode RootHistCnv::PersSvc::initialize() StatusCode status = ConversionSvc::initialize(); if ( status.isFailure() ) return status; - // Get my properties from the JobOptionsSvc - if ( setProperties().isFailure() ) { - error() << "Could not set my properties" << endmsg; - return StatusCode::FAILURE; - } if ( m_outputEnabled ) { // Initialize ROOT if output file name is defined if ( undefFileName != m_defFileName ) { -- GitLab From 5c499eb76ea72610db7f0d234cd72d086fca6e01 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Mon, 18 Dec 2017 13:01:45 +0100 Subject: [PATCH 08/53] Removed use of JobOptionsSvc deprecated methods --- GaudiAlg/src/lib/GaudiCommon.icpp | 26 ++++----- GaudiAlg/src/lib/GaudiSequencer.cpp | 40 ++++++-------- .../HistogramPersistencySvc.cpp | 14 +++-- GaudiExamples/src/Properties/PropertyAlg.cpp | 38 ++++++------- .../src/Properties/PropertyProxy.cpp | 22 ++++---- GaudiExamples/tests/qmtest/refs/History.ref | 3 +- .../tests/qmtest/refs/MetaDataSvc.ref | 8 +-- .../tests/qmtest/refs/Properties.ref | 54 +++++++++++++++---- .../tests/qmtest/refs/Properties2.ref | 43 +++++++++++---- .../tests/qmtest/refs/Properties_py.ref | 40 +++++++++++--- GaudiExamples/tests/qmtest/refs/THistRead.ref | 1 + .../tests/qmtest/refs/THistWrite.ref | 1 + .../qmtest/refs/conditional_output/write.ref | 3 -- GaudiKernel/GaudiKernel/JobHistory.h | 3 +- GaudiKernel/src/Lib/JobHistory.cpp | 19 ++++++- GaudiMonitor/src/HistorySvc.cpp | 35 +++++------- GaudiPolicy/python/GaudiTesting/BaseTest.py | 2 + GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp | 16 ++---- RootHistCnv/src/RFileCnv.cpp | 14 +++-- 19 files changed, 221 insertions(+), 161 deletions(-) diff --git a/GaudiAlg/src/lib/GaudiCommon.icpp b/GaudiAlg/src/lib/GaudiCommon.icpp index 84b5052823..68b58aa495 100644 --- a/GaudiAlg/src/lib/GaudiCommon.icpp +++ b/GaudiAlg/src/lib/GaudiCommon.icpp @@ -79,23 +79,15 @@ void GaudiCommon::initGaudiCommonConstructor( const IInterface* parent ) } } - // Get the job option service - auto jos = PBASE::template service( "JobOptionsSvc" ); - if ( !jos ) Exception( "Cannot get JobOptionsSvc" ); - - // Get the "Context" option if in the file... - const auto myList = jos->getProperties( this->name() ); - if ( myList ) { - // Iterate over the list to set the options - for ( const auto& iter : *myList ) { - const Gaudi::Property* sp = dynamic_cast*>( iter ); - if ( sp ) { - if ( iter->name().compare( "Context" ) == 0 ) { - m_context = sp->value(); - } else if ( iter->name().compare( "RootInTES" ) == 0 ) { - m_rootInTES = sp->value(); - } - } + // Get options values from IOptionsSvc + // \fixme this part is not needed because this method is called in the constructor, + // and properties are, anyway, set during the initialize... except for Context and + // RootInTES which might be set in the contructor by GaudiSequencer. + const auto& optsSvc = this->serviceLocator()->getOptsSvc(); + for ( auto p : {"Context", "RootInTES"} ) { + const std::string key = this->name() + '.' + p; + if ( optsSvc.has( key ) ) { + this->setProperty( p, optsSvc.get( key ) ).ignore(); } } } diff --git a/GaudiAlg/src/lib/GaudiSequencer.cpp b/GaudiAlg/src/lib/GaudiSequencer.cpp index 568f64bb79..8ab7958a9c 100644 --- a/GaudiAlg/src/lib/GaudiSequencer.cpp +++ b/GaudiAlg/src/lib/GaudiSequencer.cpp @@ -1,5 +1,6 @@ // Include files #include +#include #include // from Gaudi @@ -13,13 +14,6 @@ namespace bool isDefault( const std::string& s ) { return s.empty(); } - template - bool veto( const Container* props, const char* name ) - { // avoid changing properties explicitly present in the JOS... - return props && - std::any_of( begin( *props ), end( *props ), [name]( const auto* prop ) { return prop->name() == name; } ); - } - template void for_each_arg( F&& f, Args&&... args ) { @@ -33,33 +27,33 @@ namespace // set a-priori (effectively inheriting their values from the GaudiSequencer) class populate_JobOptionsSvc_t { - std::vector m_props; - IJobOptionsSvc* m_jos; - std::string m_name; + std::vector m_props; + Gaudi::Interfaces::IOptionsSvc& m_optsSvc; + std::string m_name; - template - void addPropertyToCatalogue( const Properties* props, const std::tuple& arg ) + template + void addPropertyToCatalogue( const std::tuple& arg ) { - const auto& key = std::get<0>( arg ); + const auto& key = m_name + '.' + std::get<0>( arg ); const auto& value = std::get<1>( arg ); - if ( isDefault( value ) || veto( props, key ) ) return; - m_jos->addPropertyToCatalogue( m_name, Gaudi::Property>{key, value} ).ignore(); + if ( isDefault( value ) || m_optsSvc.has( key ) ) return; + std::stringstream ss; + ss << quoted( value ); + m_optsSvc.set( key, ss.str() ); m_props.push_back( key ); } public: template - populate_JobOptionsSvc_t( std::string name, IJobOptionsSvc* jos, Args&&... args ) - : m_jos{jos}, m_name{std::move( name )} + populate_JobOptionsSvc_t( std::string name, Gaudi::Interfaces::IOptionsSvc& optsSvc, Args&&... args ) + : m_optsSvc{optsSvc}, m_name{std::move( name )} { - const auto* props = m_jos->getProperties( m_name ); - for_each_arg( [&]( auto&& arg ) { this->addPropertyToCatalogue( props, std::forward( arg ) ); }, + for_each_arg( [&]( auto&& arg ) { this->addPropertyToCatalogue( std::forward( arg ) ); }, std::forward( args )... ); } ~populate_JobOptionsSvc_t() { - std::for_each( begin( m_props ), end( m_props ), - [&]( const std::string& key ) { m_jos->removePropertyFromCatalogue( m_name, key ).ignore(); } ); + std::for_each( begin( m_props ), end( m_props ), [&]( const std::string& key ) { m_optsSvc.pop( key ); } ); } }; } @@ -191,7 +185,6 @@ StatusCode GaudiSequencer::decodeNames() m_entries.clear(); //== Get the "Context" option if in the file... - auto jos = service( "JobOptionsSvc" ); //= Get the Application manager, to see if algorithm exist auto appMgr = service( "ApplicationMgr" ); @@ -207,7 +200,8 @@ StatusCode GaudiSequencer::decodeNames() // ensure some magic properties are set while we create the subalgorithm so // that it effectively inherites 'our' settings -- if they have non-default // values... and are not set explicitly already. - populate_JobOptionsSvc_t populate_guard{theName, jos, std::forward_as_tuple( "Context", context() ), + populate_JobOptionsSvc_t populate_guard{theName, serviceLocator()->getOptsSvc(), + std::forward_as_tuple( "Context", context() ), std::forward_as_tuple( "RootInTES", rootInTES() )}; Algorithm* myAlg = nullptr; result = createSubAlgorithm( theType, theName, myAlg ); diff --git a/GaudiCommonSvc/src/HistogramPersistencySvc/HistogramPersistencySvc.cpp b/GaudiCommonSvc/src/HistogramPersistencySvc/HistogramPersistencySvc.cpp index a2a179fc7e..3b3d199742 100644 --- a/GaudiCommonSvc/src/HistogramPersistencySvc/HistogramPersistencySvc.cpp +++ b/GaudiCommonSvc/src/HistogramPersistencySvc/HistogramPersistencySvc.cpp @@ -107,14 +107,12 @@ StatusCode HistogramPersistencySvc::reinitialize() // To keep backward compatibility, we set the property of conversion service // into JobOptions catalogue if ( !m_outputFile.empty() ) { - auto joptsvc = serviceLocator()->service( "JobOptionsSvc" ); - if ( joptsvc ) { - Gaudi::Property p( "OutputFile", m_outputFile ); - if ( m_histPersName == "ROOT" ) { - joptsvc->addPropertyToCatalogue( "RootHistSvc", p ).ignore(); - } else if ( m_histPersName == "HBOOK" ) { - joptsvc->addPropertyToCatalogue( "HbookHistSvc", p ).ignore(); - } + auto& opts = serviceLocator()->getOptsSvc(); + const std::string outputFile = '"' + m_outputFile + '"'; + if ( m_histPersName == "ROOT" ) { + opts.set( "RootHistSvc.OutputFile", outputFile ); + } else if ( m_histPersName == "HBOOK" ) { + opts.set( "HbookHistSvc.OutputFile", outputFile ); } } diff --git a/GaudiExamples/src/Properties/PropertyAlg.cpp b/GaudiExamples/src/Properties/PropertyAlg.cpp index a501d7d825..23c44c85b7 100644 --- a/GaudiExamples/src/Properties/PropertyAlg.cpp +++ b/GaudiExamples/src/Properties/PropertyAlg.cpp @@ -240,34 +240,30 @@ StatusCode PropertyAlg::initialize() newlog << MSG::ALWAYS << "This should be printed ALWAYS" << endmsg; // Testing access to the JobOptions catalogue - auto jopts = service( "JobOptionsSvc" ); - if ( !jopts ) { - error() << " Unable to access the JobOptionsSvc" << endmsg; - return StatusCode::SUCCESS; - } + auto& opts = serviceLocator()->getOptsSvc(); // Dump of the catalogue info() << "=================================================" << endmsg; - info() << "Dump of the property catalogue.... " << endmsg; - for ( const auto& cit : jopts->getClients() ) { - using GaudiUtils::details::ostream_joiner; - ostream_joiner( - info() << " Properties of " << cit << ": ", *jopts->getProperties( cit ), ", ", - []( MsgStream& os, const Gaudi::Details::PropertyBase* p ) -> MsgStream& { return os << p->name(); } ) - << endmsg; - } + using GaudiUtils::details::ostream_joiner; + ostream_joiner( info() << "Dump of the property catalogue:\n", opts.items(), '\n', + []( MsgStream& os, const auto& item ) -> MsgStream& { + return os << std::get<0>( item ) << ": " << std::get<1>( item ); + } ) + << endmsg; info() << "=================================================" << endmsg; // Change an option of my own.... - jopts->addPropertyToCatalogue( name(), Gaudi::Property( "PInt", "155" ) ).ignore(); - Gaudi::Property> sap( "DoubleArray", {"12.12", "13.13"} ); - if ( jopts->addPropertyToCatalogue( name(), sap ).isSuccess() ) { - info() << "Changed property DoubleArray in catalogue" << endmsg; - jopts->setMyProperties( name(), this ).ignore(); - info() << "DoubleArray = " << m_doublearray.value() << endmsg; - } else { - error() << "Unable to change property in catalogue" << endmsg; + opts.set( name() + '.' + "PInt", "155" ); + setPropertiesFrom( opts ); + // trying to use an invalid value + opts.set( name() + '.' + "DoubleArray", "{\"12.12\", \"13.13\"}" ); + info() << "Changed property DoubleArray in catalogue" << endmsg; + try { + setPropertiesFrom( opts ); + } catch ( const std::invalid_argument& exc ) { + error() << "got invalid_argument exception: " << exc.what() << endmsg; } + info() << "DoubleArray = " << m_doublearray.value() << endmsg; info() << "=================================================" << endmsg; return StatusCode::SUCCESS; } diff --git a/GaudiExamples/src/Properties/PropertyProxy.cpp b/GaudiExamples/src/Properties/PropertyProxy.cpp index 286cf59bac..b5843280d8 100644 --- a/GaudiExamples/src/Properties/PropertyProxy.cpp +++ b/GaudiExamples/src/Properties/PropertyProxy.cpp @@ -1,5 +1,5 @@ -// Include files #include "PropertyProxy.h" + #include "GaudiKernel/DataObject.h" #include "GaudiKernel/IAlgManager.h" #include "GaudiKernel/IChronoStatSvc.h" @@ -7,8 +7,6 @@ #include "GaudiKernel/MsgStream.h" #include "GaudiKernel/SmartIF.h" -// Static Factory declaration - DECLARE_COMPONENT( PropertyProxy ) // Constructor @@ -31,20 +29,26 @@ PropertyProxy::PropertyProxy( const std::string& name, ISvcLocator* ploc ) : Alg //------------------------------------------------------------------------------ StatusCode PropertyProxy::initialize() { - //------------------------------------------------------------------------------ + if ( !Algorithm::initialize() ) return StatusCode::FAILURE; + std::string value( "empty" ); std::string value1( "empty" ); - this->getProperty( "RInt", value ).ignore(); + if ( !this->getProperty( "RInt", value ) ) { + warning() << "failed to get property RInt" << endmsg; + } info() << " Got property this.RInt = " << value << ";" << endmsg; - this->setProperty( "RInt", "1001" ).ignore(); - info() << " Set property this.RInt = " - << "1001" - << ";" << endmsg; + info() << " Set property this.RInt = 1001;" << endmsg; + if ( !this->setProperty( "RInt", "1001" ) ) { + warning() << "failed to set property RInt" << endmsg; + } this->getProperty( "RInt", value ).ignore(); info() << " Got property this.RInt = " << value << ";" << endmsg; + if ( value != "1001" ) { + error() << "RInt value not what expected" << endmsg; + } this->getProperty( "String", value ).ignore(); m_remAlg->getProperty( "String", value1 ).ignore(); diff --git a/GaudiExamples/tests/qmtest/refs/History.ref b/GaudiExamples/tests/qmtest/refs/History.ref index 2b56bf78e7..4f81452d58 100644 --- a/GaudiExamples/tests/qmtest/refs/History.ref +++ b/GaudiExamples/tests/qmtest/refs/History.ref @@ -86,7 +86,6 @@ ToolSvc DEBUG START transition for AlgTools ServiceManager DEBUG Starting service EventLoopMgr ServiceManager DEBUG Starting service HistorySvc ApplicationMgr INFO Application Manager Started successfully -HistorySvc VERBOSE ServiceLocatorHelper::service: found service JobOptionsSvc HistorySvc DEBUG Registering algorithm: History HistorySvc INFO Registered 1 Algorithms HistorySvc INFO Registered 0 AlgTools @@ -174,7 +173,7 @@ StatusCodeSvc DEBUG all StatusCode instances where checked ServiceManager DEBUG Looping over all active services... ServiceManager DEBUG ---- StatusCodeSvc (refCount = 3) ServiceManager DEBUG ---- MessageSvc (refCount = 22) -ServiceManager DEBUG ---- JobOptionsSvc (refCount = 5) +ServiceManager DEBUG ---- JobOptionsSvc (refCount = 4) ServiceManager DEBUG ---- HistorySvc (refCount = 3) ServiceManager DEBUG ---- HistogramPersistencySvc (refCount = 3) ServiceManager DEBUG ---- HistogramDataSvc (refCount = 4) diff --git a/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref b/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref index cdb8a47918..7129dbcbaa 100644 --- a/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref +++ b/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref @@ -131,11 +131,11 @@ NTupleSvc.Output:[ "MYLUN DATAFILE='TupleEx.root' OPT='NEW' TYP='ROOT'" ] NTupleSvc.OutputLevel:3 NTupleSvc.RootCLID:1 NTupleSvc.RootName:/NTUPLES -RFileCnv.GlobalCompression:LZMA:6 +RFileCnv.GlobalCompression:"LZMA:6" ToolSvc: -Tuple.NTupleLUN:MYLUN -Tuple2.NTupleLUN:MYLUN -Tuple3.NTupleLUN:MYLUN +Tuple.NTupleLUN:"MYLUN" +Tuple2.NTupleLUN:"MYLUN" +Tuple3.NTupleLUN:"MYLUN" ApplicationMgr INFO Application Manager Started successfully RFileCnv INFO opening Root file "TupleEx.root" for writing, CompressionLevel='LZMA:6' diff --git a/GaudiExamples/tests/qmtest/refs/Properties.ref b/GaudiExamples/tests/qmtest/refs/Properties.ref index 05cb395188..05e01a299e 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties.ref @@ -146,24 +146,56 @@ MsgTest ERROR This should be printed if threshold is ERROR MsgTest FATAL This should be printed if threshold is FATAL MsgTest SUCCESS This should be printed ALWAYS PropertyAlg INFO ================================================= -PropertyAlg INFO Dump of the property catalogue.... -PropertyAlg INFO Properties of ApplicationMgr: EvtMax, EvtSel, HistogramPersistency, StatusCodeCheck, TopAlg -PropertyAlg INFO Properties of AuditorSvc: Auditors -PropertyAlg INFO Properties of Dummy1: Property -PropertyAlg INFO Properties of Dummy2: Property -PropertyAlg INFO Properties of MessageSvc: OutputLevel, setDebug, setVerbose, setWarning -PropertyAlg INFO Properties of PropertyAlg: Bool, BoolArray, Double, DoubleArray, DoubleArrayWithUnits, DoubleArrayWithoutUnits, DoublePairArray, EmptyArray, Int, Int64, Int64Array, IntArray, IntPairArray, OutputLevel, PBool, PBoolArray, PDouble, PDoubleArray, PInt, PIntArray, PString, PStringArray, String, StringArray, UInt64, UInt64Array -PropertyAlg INFO Properties of PropertyProxy: String +PropertyAlg INFO Dump of the property catalogue: +ApplicationMgr.EvtMax: 1 +ApplicationMgr.EvtSel: "NONE" +ApplicationMgr.HistogramPersistency: "NONE" +ApplicationMgr.StatusCodeCheck: 1 +ApplicationMgr.TopAlg: ["PropertyAlg", "PropertyProxy"] +AuditorSvc.Auditors: ["ChronoAuditor"] +Dummy1.Property: 1 +Dummy2.Property: 1 +MessageSvc.OutputLevel: 3 +MessageSvc.setDebug: ["EventLoopMgr"] +MessageSvc.setVerbose: ["MsgTest"] +MessageSvc.setWarning: ["MsgTest"] +PropertyAlg.Bool: 0 +PropertyAlg.BoolArray: [0, 1, 0] +PropertyAlg.Double: 101.1e+10 +PropertyAlg.DoubleArray: [-11.0, 2., 3.3, 0.4e-03] +PropertyAlg.DoubleArrayWithUnits: [1100000.000000, -20.000000, 33.000000, 0.400000] +PropertyAlg.DoubleArrayWithoutUnits: [1100000.0, -20., 33.0, 0.4] +PropertyAlg.DoublePairArray: [[1.1, 2.1], [2.3, 4.5], [5.6, 6.7]] +PropertyAlg.EmptyArray: {} +PropertyAlg.Int: 101 +PropertyAlg.Int64: 4294967296 +PropertyAlg.Int64Array: [4294967296] +PropertyAlg.IntArray: [1, 2, 3, 5] +PropertyAlg.IntPairArray: [[1, 2], [3, 4], [5, 6]] +PropertyAlg.OutputLevel: 3 +PropertyAlg.PBool: 1 +PropertyAlg.PBoolArray: [1, 0, 1, 0] +PropertyAlg.PDouble: 101.E5 +PropertyAlg.PDoubleArray: [1.1, 2., 3.3] +PropertyAlg.PInt: 101 +PropertyAlg.PIntArray: [1, 2, 3, 5] +PropertyAlg.PString: "hundred one" +PropertyAlg.PStringArray: ["one", "two", "four"] +PropertyAlg.String: "hundred one" +PropertyAlg.StringArray: ["one", "two", "four"] +PropertyAlg.UInt64: 4294967296 +PropertyAlg.UInt64Array: [4294967296] +PropertyProxy.String: "This is set by the proxy" PropertyAlg INFO ================================================= -PropertyAlg INFO Changed property DoubleArray in catalogue -JobOptionsSvc ERROR Unable to set the property 'DoubleArray' of 'PropertyAlg'. Check option and algorithm names, type and bounds. PropertyAlg INFO Read handler called for property: 'PDouble':10100000. PropertyAlg INFO Update handler called for property: 'PDouble':10100000. +PropertyAlg INFO Changed property DoubleArray in catalogue +PropertyAlg ERROR got invalid_argument exception: cannot parse '{"12.12", "13.13"}' to std::vector > PropertyAlg INFO DoubleArray = [-11, 2, 3.3, 0.0004] PropertyAlg INFO ================================================= PropertyProxy INFO Got property this.RInt = 101; PropertyProxy INFO Set property this.RInt = 1001; -PropertyProxy INFO Got property this.RInt = 101; +PropertyProxy INFO Got property this.RInt = 1001; PropertyProxy INFO Got property this.String = This is set by the proxy; EventLoopMgr WARNING Unable to locate service "EventSelector" EventLoopMgr WARNING No events will be processed from external input. diff --git a/GaudiExamples/tests/qmtest/refs/Properties2.ref b/GaudiExamples/tests/qmtest/refs/Properties2.ref index 35f4a128e2..afc892dbae 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties2.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties2.ref @@ -148,22 +148,47 @@ MsgTest ERROR This should be printed if threshold is ERROR MsgTest FATAL This should be printed if threshold is FATAL MsgTest SUCCESS This should be printed ALWAYS PropertyAlg INFO ================================================= -PropertyAlg INFO Dump of the property catalogue.... -PropertyAlg INFO Properties of AuditorSvc: Auditors -PropertyAlg INFO Properties of Dummy1: Property -PropertyAlg INFO Properties of Dummy2: Property -PropertyAlg INFO Properties of PropertyAlg: Bool, BoolArray, Double, DoubleArray, DoubleArrayWithUnits, DoubleArrayWithoutUnits, DoublePairArray, EmptyArray, Int, Int64, Int64Array, IntArray, IntPairArray, OutputLevel, PBool, PBoolArray, PDouble, PDoubleArray, PInt, PIntArray, PString, PStringArray, String, StringArray, UInt64, UInt64Array -PropertyAlg INFO Properties of PropertyProxy: String +PropertyAlg INFO Dump of the property catalogue: +AuditorSvc.Auditors: ['ChronoAuditor'] +Dummy1.Property: True +Dummy2.Property: True +PropertyAlg.Bool: False +PropertyAlg.BoolArray: [False, True, False] +PropertyAlg.Double: 1.011e+12 +PropertyAlg.DoubleArray: [-11.0, 2.0, 3.3, 0.0004] +PropertyAlg.DoubleArrayWithUnits: [1100000.0, -20.0, 33.0, 0.4] +PropertyAlg.DoubleArrayWithoutUnits: [1100000.0, -20.0, 33.0, 0.4] +PropertyAlg.DoublePairArray: [(1.1, 2.1), (2.3, 4.5), (5.6, 6.7)] +PropertyAlg.EmptyArray: [] +PropertyAlg.Int: 101 +PropertyAlg.Int64: 4294967296 +PropertyAlg.Int64Array: [4294967296] +PropertyAlg.IntArray: [1, 2, 3, 5] +PropertyAlg.IntPairArray: [(1, 2), (3, 4), (5, 6)] +PropertyAlg.OutputLevel: 3 +PropertyAlg.PBool: True +PropertyAlg.PBoolArray: [True, False, True, False] +PropertyAlg.PDouble: 10100000.0 +PropertyAlg.PDoubleArray: [1.1, 2.0, 3.3] +PropertyAlg.PInt: 101 +PropertyAlg.PIntArray: [1, 2, 3, 5] +PropertyAlg.PString: "hundred one" +PropertyAlg.PStringArray: ['one', 'two', 'four'] +PropertyAlg.String: "hundred one" +PropertyAlg.StringArray: ['one', 'two', 'four'] +PropertyAlg.UInt64: 4294967296 +PropertyAlg.UInt64Array: [4294967296] +PropertyProxy.String: "This is set by the proxy" PropertyAlg INFO ================================================= -PropertyAlg INFO Changed property DoubleArray in catalogue -JobOptionsSvc ERROR Unable to set the property 'DoubleArray' of 'PropertyAlg'. Check option and algorithm names, type and bounds. PropertyAlg INFO Read handler called for property: 'PDouble':10100000. PropertyAlg INFO Update handler called for property: 'PDouble':10100000. +PropertyAlg INFO Changed property DoubleArray in catalogue +PropertyAlg ERROR got invalid_argument exception: cannot parse '{"12.12", "13.13"}' to std::vector > PropertyAlg INFO DoubleArray = [-11, 2, 3.3, 0.0004] PropertyAlg INFO ================================================= PropertyProxy INFO Got property this.RInt = 101; PropertyProxy INFO Set property this.RInt = 1001; -PropertyProxy INFO Got property this.RInt = 101; +PropertyProxy INFO Got property this.RInt = 1001; PropertyProxy INFO Got property this.String = This is set by the proxy; EventLoopMgr WARNING Unable to locate service "EventSelector" EventLoopMgr WARNING No events will be processed from external input. diff --git a/GaudiExamples/tests/qmtest/refs/Properties_py.ref b/GaudiExamples/tests/qmtest/refs/Properties_py.ref index 1806009bba..45b63bb90f 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties_py.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties_py.ref @@ -108,21 +108,45 @@ MsgTest ERROR This should be printed if threshold is ERROR MsgTest FATAL This should be printed if threshold is FATAL MsgTest SUCCESS This should be printed ALWAYS PropertyAlg INFO ================================================= -PropertyAlg INFO Dump of the property catalogue.... -PropertyAlg INFO Properties of AuditorSvc: Auditors -PropertyAlg INFO Properties of Dummy1: Property -PropertyAlg INFO Properties of Dummy2: Property -PropertyAlg INFO Properties of PropertyAlg: Bool, BoolArray, Double, DoubleArray, DoubleArrayWithUnits, DoubleArrayWithoutUnits, DoublePairArray, Int, Int64, Int64Array, IntArray, IntPairArray, OutputLevel, PBool, PBoolArray, PDouble, PDoubleArray, PInt, PIntArray, PString, PStringArray, String, StringArray, UInt64, UInt64Array +PropertyAlg INFO Dump of the property catalogue: +AuditorSvc.Auditors: ['ChronoAuditor/ChronoAuditor'] +Dummy1.Property: True +Dummy2.Property: True +PropertyAlg.Bool: False +PropertyAlg.BoolArray: [False, True, False] +PropertyAlg.Double: 1.011e+12 +PropertyAlg.DoubleArray: [-11.0, 2.0, 3.3, 0.0004, 1e-20, 1e+20] +PropertyAlg.DoubleArrayWithUnits: [1100000.0, -20.0, 33.0, 0.4] +PropertyAlg.DoubleArrayWithoutUnits: [1100000.0, -20.0, 33.0, 0.4] +PropertyAlg.DoublePairArray: [(1.1, 2.1), (2.3, 4.5), (5.6, 6.7)] +PropertyAlg.Int: 101 +PropertyAlg.Int64: 4294967296 +PropertyAlg.Int64Array: [4294967296] +PropertyAlg.IntArray: [1, 2, 3, 5] +PropertyAlg.IntPairArray: [(1, 2), (3, 4), (5, 6)] +PropertyAlg.OutputLevel: 3 +PropertyAlg.PBool: True +PropertyAlg.PBoolArray: [True, False, True, False] +PropertyAlg.PDouble: 10100000.0 +PropertyAlg.PDoubleArray: [1.1, 2.0, 3.3, 1e-20, 1e+20] +PropertyAlg.PInt: 101 +PropertyAlg.PIntArray: [1, 2, 3, 5] +PropertyAlg.PString: "hundred one" +PropertyAlg.PStringArray: ['one', 'two', 'four'] +PropertyAlg.String: "hundred one" +PropertyAlg.StringArray: ['one', 'two', 'four'] +PropertyAlg.UInt64: 4294967296 +PropertyAlg.UInt64Array: [4294967296L] PropertyAlg INFO ================================================= -PropertyAlg INFO Changed property DoubleArray in catalogue -JobOptionsSvc ERROR Unable to set the property 'DoubleArray' of 'PropertyAlg'. Check option and algorithm names, type and bounds. PropertyAlg INFO Read handler called for property: 'PDouble':10100000. PropertyAlg INFO Update handler called for property: 'PDouble':10100000. +PropertyAlg INFO Changed property DoubleArray in catalogue +PropertyAlg ERROR got invalid_argument exception: cannot parse '{"12.12", "13.13"}' to std::vector > PropertyAlg INFO DoubleArray = [-11, 2, 3.3, 0.0004, 1e-20, 1e+20] PropertyAlg INFO ================================================= PropertyProxy INFO Got property this.RInt = 101; PropertyProxy INFO Set property this.RInt = 1001; -PropertyProxy INFO Got property this.RInt = 101; +PropertyProxy INFO Got property this.RInt = 1001; PropertyProxy INFO Got property this.String = hundred one; EventLoopMgr WARNING Unable to locate service "EventSelector" EventLoopMgr WARNING No events will be processed from external input. diff --git a/GaudiExamples/tests/qmtest/refs/THistRead.ref b/GaudiExamples/tests/qmtest/refs/THistRead.ref index 359074fac7..2c4e8fff0a 100644 --- a/GaudiExamples/tests/qmtest/refs/THistRead.ref +++ b/GaudiExamples/tests/qmtest/refs/THistRead.ref @@ -30,6 +30,7 @@ ApplicationMgr DEBUG Loading declared DLL's ApplicationMgr VERBOSE added service EventLoopMgr/EventLoopMgr ApplicationMgr INFO Application Manager Configured successfully THistSvc DEBUG Property update for OutputLevel : new value = 2 +THistSvc DEBUG Delaying connection of Input Files until Initialize. now in OFFLINE THistSvc DEBUG Service base class initialized successfully THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED diff --git a/GaudiExamples/tests/qmtest/refs/THistWrite.ref b/GaudiExamples/tests/qmtest/refs/THistWrite.ref index 3c6191af31..3882b16c83 100644 --- a/GaudiExamples/tests/qmtest/refs/THistWrite.ref +++ b/GaudiExamples/tests/qmtest/refs/THistWrite.ref @@ -30,6 +30,7 @@ ApplicationMgr DEBUG Loading declared DLL's ApplicationMgr VERBOSE added service EventLoopMgr/EventLoopMgr ApplicationMgr INFO Application Manager Configured successfully THistSvc DEBUG Property update for OutputLevel : new value = 2 +THistSvc DEBUG Delaying connection of Input Files until Initialize. now in OFFLINE THistSvc DEBUG Service base class initialized successfully THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED diff --git a/GaudiExamples/tests/qmtest/refs/conditional_output/write.ref b/GaudiExamples/tests/qmtest/refs/conditional_output/write.ref index 7f10a36724..f95efbd9e9 100644 --- a/GaudiExamples/tests/qmtest/refs/conditional_output/write.ref +++ b/GaudiExamples/tests/qmtest/refs/conditional_output/write.ref @@ -56,11 +56,8 @@ EventPersistenc... DEBUG Service base class initialized successfully EventLoopMgr VERBOSE ServiceLocatorHelper::service: found service EventDataSvc EventLoopMgr DEBUG Creating Output Stream OutputStream/OutputStream EventLoopMgr DEBUG Creating Top Algorithm GaudiTesting::PutDataObjectAlg with name DataCreator -DataCreator VERBOSE ServiceLocatorHelper::service: found service JobOptionsSvc EventLoopMgr DEBUG Creating Top Algorithm GaudiTesting::OddEventsFilter with name OddEvents -OddEvents VERBOSE ServiceLocatorHelper::service: found service JobOptionsSvc EventLoopMgr DEBUG Creating Top Algorithm GaudiTesting::EvenEventsFilter with name EvenEvents -EvenEvents VERBOSE ServiceLocatorHelper::service: found service JobOptionsSvc AlgContextSvc DEBUG Service base class initialized successfully AlgContextSvc VERBOSE ServiceLocatorHelper::service: found service IncidentSvc IncidentSvc DEBUG Adding [BeginEvent] listener 'AlgContextSvc' with priority 0 diff --git a/GaudiKernel/GaudiKernel/JobHistory.h b/GaudiKernel/GaudiKernel/JobHistory.h index 32531aac42..f95b20dc37 100644 --- a/GaudiKernel/GaudiKernel/JobHistory.h +++ b/GaudiKernel/GaudiKernel/JobHistory.h @@ -58,7 +58,8 @@ public: // functions static const CLID& classID(); // add a global property - void addProperty( const std::string&, const Gaudi::Details::PropertyBase* ); + [[deprecated]] void addProperty( const std::string&, const Gaudi::Details::PropertyBase* ); + void addProperty( const std::string& key, const std::string& value ); // Return the job history data. std::string release_version() const { return m_release_version; } diff --git a/GaudiKernel/src/Lib/JobHistory.cpp b/GaudiKernel/src/Lib/JobHistory.cpp index 1bfc79d0f9..f2616b4015 100644 --- a/GaudiKernel/src/Lib/JobHistory.cpp +++ b/GaudiKernel/src/Lib/JobHistory.cpp @@ -83,12 +83,27 @@ const CLID& JobHistory::classID() } void JobHistory::addProperty( const std::string& client, const PropertyBase* prop ) +{ + addProperty( client + '.' + prop->name(), prop->toString() ); +} + +void JobHistory::addProperty( const std::string& key, const std::string& value ) { /// \fixme strip optional quotes around the string - std::string prop_value = prop->toString(); + std::string prop_value = value; if ( !prop_value.empty() && prop_value[0] == '"' && prop_value[prop_value.size() - 1] == '"' ) prop_value = prop_value.substr( 1, prop_value.size() - 2 ); - m_ppl.emplace_back( client, std::make_unique>( prop->name(), prop_value ) ); + + std::string client, prop_name; + auto pos = key.rfind( '.' ); + if ( pos == std::string::npos ) { + prop_name = key; + } else { + client = key.substr( 0, pos ); + prop_name = key.substr( pos + 1 ); + } + + m_ppl.emplace_back( client, std::make_unique>( prop_name, prop_value ) ); } void JobHistory::dump( std::ostream& ost, const bool isXML, int /*ind*/ ) const diff --git a/GaudiMonitor/src/HistorySvc.cpp b/GaudiMonitor/src/HistorySvc.cpp index 54b96acfb4..e99fccb68c 100644 --- a/GaudiMonitor/src/HistorySvc.cpp +++ b/GaudiMonitor/src/HistorySvc.cpp @@ -170,30 +170,21 @@ StatusCode HistorySvc::captureState() { if ( !m_jobHistory ) { - m_jobHistory.reset( new JobHistory ); - IJobOptionsSvc* jo; - if ( service( "JobOptionsSvc", jo ).isFailure() ) { - error() << "Could not get jobOptionsSvc - " - << "not adding properties to JobHistory" << endmsg; - } else { - - bool foundAppMgr( false ); + m_jobHistory = std::make_unique(); - for ( auto& client : jo->getClients() ) { - if ( client == "ApplicationMgr" ) foundAppMgr = true; - for ( auto prop : *jo->getProperties( client ) ) { - m_jobHistory->addProperty( client, prop ); - } - } + bool foundAppMgr( false ); + for ( const auto& item : serviceLocator()->getOptsSvc().items() ) { + m_jobHistory->addProperty( get<0>( item ), get<1>( item ) ); + foundAppMgr |= get<0>( item ).compare( 0, 15, "ApplicationMgr." ) == 0; + } - if ( !foundAppMgr ) { - auto ap = service( "ApplicationMgr" ); - if ( !ap ) { - error() << "could not get the ApplicationMgr" << endmsg; - } else { - for ( auto prop : ap->getProperties() ) { - m_jobHistory->addProperty( "ApplicationMgr", prop ); - } + if ( !foundAppMgr ) { + auto ap = service( "ApplicationMgr" ); + if ( !ap ) { + error() << "could not get the ApplicationMgr" << endmsg; + } else { + for ( auto prop : ap->getProperties() ) { + m_jobHistory->addProperty( "ApplicationMgr." + prop->name(), prop->toString() ); } } } diff --git a/GaudiPolicy/python/GaudiTesting/BaseTest.py b/GaudiPolicy/python/GaudiTesting/BaseTest.py index 48cc70c191..64aa8105b7 100644 --- a/GaudiPolicy/python/GaudiTesting/BaseTest.py +++ b/GaudiPolicy/python/GaudiTesting/BaseTest.py @@ -899,6 +899,8 @@ lineSkipper = LineSkipper(["//GP:", # The signal handler complains about SIGXCPU not # defined on some platforms 'SIGXCPU', + # Message removed with redesing of JobOptionsSvc + 'ServiceLocatorHelper::service: found service JobOptionsSvc', ], regexps=[ r"^JobOptionsSvc INFO *$", r"^# ", # Ignore python comments diff --git a/GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp b/GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp index 2d55b39a55..47ad864b04 100644 --- a/GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp +++ b/GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp @@ -6,9 +6,9 @@ */ // Framework include files +#include "Gaudi/Interfaces/IOptionsSvc.h" #include "GaudiKernel/IAlgManager.h" #include "GaudiKernel/IAlgorithm.h" -#include "GaudiKernel/IJobOptionsSvc.h" #include "GaudiKernel/IProperty.h" #include "GaudiKernel/IService.h" #include "GaudiKernel/ISvcLocator.h" @@ -62,18 +62,8 @@ StatusCode MetaDataSvc::collectData() { // save options for all clients - { - auto joSvc = service( "JobOptionsSvc" ); - if ( !joSvc.isValid() ) return StatusCode::FAILURE; - for ( const auto c : joSvc->getClients() ) { - // get options for this client - const auto props = joSvc->getProperties( c ); - if ( props ) { - for ( const auto prop : *props ) { - m_metadata[c + "." + prop->name()] = prop->toString(); - } - } - } + for ( const auto& p : serviceLocator()->getOptsSvc().items() ) { + m_metadata[std::get<0>( p )] = std::get<1>( p ); } for ( const auto* name : {"ApplicationMgr", "MessageSvc", "NTupleSvc"} ) { diff --git a/RootHistCnv/src/RFileCnv.cpp b/RootHistCnv/src/RFileCnv.cpp index 511d1a8872..bc76720897 100644 --- a/RootHistCnv/src/RFileCnv.cpp +++ b/RootHistCnv/src/RFileCnv.cpp @@ -6,6 +6,8 @@ #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/MsgStream.h" +#include "Gaudi/Interfaces/IOptionsSvc.h" + // ROOT #include "RFileCnv.h" #include "TFile.h" @@ -28,14 +30,10 @@ RootHistCnv::RFileCnv::RFileCnv( ISvcLocator* svc ) : RDirectoryCnv( svc, classI StatusCode RootHistCnv::RFileCnv::initialize() { // Set compression level property ... - ISvcLocator* svcLoc = Gaudi::svcLocator(); - auto jobSvc = svcLoc->service( "JobOptionsSvc" ); - auto prop = jobSvc->getClientProperty( "RFileCnv", "GlobalCompression" ); - if ( prop ) m_compLevel = prop->toString(); - /// \fixme strip optional quotes around the string - if ( !m_compLevel.empty() && m_compLevel[0] == '"' && m_compLevel[m_compLevel.size() - 1] == '"' ) - m_compLevel = m_compLevel.substr( 1, m_compLevel.size() - 2 ); - + const auto& optsSvc = serviceLocator()->getOptsSvc(); + if ( optsSvc.has( "RFileCnv.GlobalCompression" ) ) { + Gaudi::Parsers::parse( m_compLevel, optsSvc.get( "RFileCnv.GlobalCompression" ) ); + } // initialise base class return RDirectoryCnv::initialize(); } -- GitLab From e66e64f126f8d2f2c1e7b9d995525ab9d7e5fa50 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Sun, 31 Dec 2017 16:17:36 +0100 Subject: [PATCH 09/53] Restored setProperties method for backward compatibility --- GaudiKernel/GaudiKernel/AlgTool.h | 7 +++++++ GaudiKernel/GaudiKernel/Algorithm.h | 7 +++++++ GaudiKernel/GaudiKernel/Auditor.h | 7 +++++++ GaudiKernel/GaudiKernel/Service.h | 7 +++++++ 4 files changed, 28 insertions(+) diff --git a/GaudiKernel/GaudiKernel/AlgTool.h b/GaudiKernel/GaudiKernel/AlgTool.h index 38de517807..76a4a49ac5 100644 --- a/GaudiKernel/GaudiKernel/AlgTool.h +++ b/GaudiKernel/GaudiKernel/AlgTool.h @@ -118,6 +118,13 @@ public: /// The standard ToolSvc service, Return a pointer to the service if present IToolSvc* toolSvc() const; + [[deprecated( "it should not be called explicitely" )]] StatusCode setProperties() + { + if ( !serviceLocator() ) return StatusCode::FAILURE; + setPropertiesFrom( serviceLocator()->getOptsSvc() ); + return StatusCode::SUCCESS; + } + /** Access a service by name, * creating it if it doesn't already exist. */ diff --git a/GaudiKernel/GaudiKernel/Algorithm.h b/GaudiKernel/GaudiKernel/Algorithm.h index 74dfc044de..b29141a46c 100644 --- a/GaudiKernel/GaudiKernel/Algorithm.h +++ b/GaudiKernel/GaudiKernel/Algorithm.h @@ -353,6 +353,13 @@ public: /// List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms std::vector* subAlgorithms(); + [[deprecated( "it should not be called explicitely" )]] StatusCode setProperties() + { + if ( !serviceLocator() ) return StatusCode::FAILURE; + setPropertiesFrom( serviceLocator()->getOptsSvc() ); + return StatusCode::SUCCESS; + } + // ========================================================================== using PropertyHolderImpl::declareProperty; diff --git a/GaudiKernel/GaudiKernel/Auditor.h b/GaudiKernel/GaudiKernel/Auditor.h index 17c0b33fee..cd55d3ef4b 100644 --- a/GaudiKernel/GaudiKernel/Auditor.h +++ b/GaudiKernel/GaudiKernel/Auditor.h @@ -122,6 +122,13 @@ public: return serviceLocator()->service( name, createIf ); } + [[deprecated( "it should not be called explicitely" )]] StatusCode setProperties() + { + if ( !serviceLocator() ) return StatusCode::FAILURE; + setPropertiesFrom( serviceLocator()->getOptsSvc() ); + return StatusCode::SUCCESS; + } + private: std::string m_name; ///< Auditor's name for identification diff --git a/GaudiKernel/GaudiKernel/Service.h b/GaudiKernel/GaudiKernel/Service.h index c778ac3ac7..fc5f5dbd90 100644 --- a/GaudiKernel/GaudiKernel/Service.h +++ b/GaudiKernel/GaudiKernel/Service.h @@ -73,6 +73,13 @@ public: /** Retrieve pointer to service locator */ SmartIF& serviceLocator() const override; + [[deprecated( "it should not be called explicitely" )]] StatusCode setProperties() + { + if ( !serviceLocator() ) return StatusCode::FAILURE; + setPropertiesFrom( serviceLocator()->getOptsSvc() ); + return StatusCode::SUCCESS; + } + /** Access a service by name, creating it if it doesn't already exist. */ template -- GitLab From 661d92651a5e438fb6d7907a7ae42a7735e04021 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Thu, 28 Dec 2017 11:32:08 +0100 Subject: [PATCH 10/53] Use new IOptionsSvc in GaudiPython --- Gaudi/python/Gaudi/Main.py | 2 +- .../src/JobOptionsSvc/PythonConfig.cpp | 4 +- .../tests/qmtest/refs/Properties2.ref | 6 +- .../tests/qmtest/refs/Properties_py.ref | 4 +- GaudiPython/python/GaudiPython/Bindings.py | 70 ++++++------------- 5 files changed, 30 insertions(+), 56 deletions(-) diff --git a/Gaudi/python/Gaudi/Main.py b/Gaudi/python/Gaudi/Main.py index 35cf194e5d..e3c6267ca9 100644 --- a/Gaudi/python/Gaudi/Main.py +++ b/Gaudi/python/Gaudi/Main.py @@ -362,7 +362,7 @@ class gaudimain(object): # so we do it again to get it v = v.__resolve__() if type(v) == str: - v = '"%s"' % v # need double quotes + v = repr(v) # need double quotes elif type(v) == long: v = '%d' % v # prevent pending 'L' _bootstrap.setOption(optssvc, '.'.join((n, p)), str(v)) diff --git a/GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.cpp b/GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.cpp index 07ea6130d5..8b2e29507d 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.cpp +++ b/GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.cpp @@ -33,8 +33,8 @@ StatusCode PythonConfig::evaluateConfig( const std::string& filename, const std: "applyConfigurableUsers\napplyConfigurableUsers()\n"; command += postAction; command += "\nfor n, c in Configurable.allConfigurables.items():\n for p, v in c.getValuedProperties().items() " - ":\n v = expandvars(v)\n if type(v) == str : v = '\"%s\"' % v # need double quotes\n elif " - "type(v) == long: v = '%d' % v # prevent pending 'L'\n adaptor.addPropertyToJobOptions(n,p,str(v))"; + ":\n v = expandvars(v)\n if type(v) == str : v = repr(v) # need double quotes\n elif " + "type(v) == long: v = '%d' % v # prevent pending 'L'\n adaptor.addPropertyToJobOptions(n,p,str(v))"; // Now fire off the translation handle<> ignored( ( PyRun_String( command.c_str(), Py_file_input, main_namespace.ptr(), main_namespace.ptr() ) ) ); diff --git a/GaudiExamples/tests/qmtest/refs/Properties2.ref b/GaudiExamples/tests/qmtest/refs/Properties2.ref index afc892dbae..237e2010a5 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties2.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties2.ref @@ -172,13 +172,13 @@ PropertyAlg.PDouble: 10100000.0 PropertyAlg.PDoubleArray: [1.1, 2.0, 3.3] PropertyAlg.PInt: 101 PropertyAlg.PIntArray: [1, 2, 3, 5] -PropertyAlg.PString: "hundred one" +PropertyAlg.PString: 'hundred one' PropertyAlg.PStringArray: ['one', 'two', 'four'] -PropertyAlg.String: "hundred one" +PropertyAlg.String: 'hundred one' PropertyAlg.StringArray: ['one', 'two', 'four'] PropertyAlg.UInt64: 4294967296 PropertyAlg.UInt64Array: [4294967296] -PropertyProxy.String: "This is set by the proxy" +PropertyProxy.String: 'This is set by the proxy' PropertyAlg INFO ================================================= PropertyAlg INFO Read handler called for property: 'PDouble':10100000. PropertyAlg INFO Update handler called for property: 'PDouble':10100000. diff --git a/GaudiExamples/tests/qmtest/refs/Properties_py.ref b/GaudiExamples/tests/qmtest/refs/Properties_py.ref index 45b63bb90f..1a1684c7f7 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties_py.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties_py.ref @@ -131,9 +131,9 @@ PropertyAlg.PDouble: 10100000.0 PropertyAlg.PDoubleArray: [1.1, 2.0, 3.3, 1e-20, 1e+20] PropertyAlg.PInt: 101 PropertyAlg.PIntArray: [1, 2, 3, 5] -PropertyAlg.PString: "hundred one" +PropertyAlg.PString: 'hundred one' PropertyAlg.PStringArray: ['one', 'two', 'four'] -PropertyAlg.String: "hundred one" +PropertyAlg.String: 'hundred one' PropertyAlg.StringArray: ['one', 'two', 'four'] PropertyAlg.UInt64: 4294967296 PropertyAlg.UInt64Array: [4294967296L] diff --git a/GaudiPython/python/GaudiPython/Bindings.py b/GaudiPython/python/GaudiPython/Bindings.py index 83c2be7d04..6c49d4b31f 100644 --- a/GaudiPython/python/GaudiPython/Bindings.py +++ b/GaudiPython/python/GaudiPython/Bindings.py @@ -57,12 +57,17 @@ SUCCESS = gbl.StatusCode(gbl.StatusCode.SUCCESS, True) FAILURE = gbl.StatusCode(gbl.StatusCode.FAILURE, True) # Helper to create a StringProperty cppyy.gbl.gInterpreter.Declare(''' +#include namespace GaudiPython { namespace Helpers { Gaudi::Property mkStringProperty(const std::string &name, const std::string &value) { return Gaudi::Property{name, value}; } -}}''') + void setProperty(ISvcLocator* svcLoc, std::string key, std::string value) { + gsl::not_null(svcLoc)->getOptsSvc().set(key, value); + } +}} +''') # toIntArray, toShortArray, etc. for l in [l for l in dir(Helper) if re.match("^to.*Array$", l)]: @@ -254,53 +259,23 @@ class iProperty(object): """ if hasattr(value, 'toStringProperty'): # user defined behaviour - value = '%s' % value.toStringProperty() + value = str(value.toStringProperty()) + elif hasattr(value, 'toString'): + value = str(value.toString()) + elif type(value) == long: + value = '%d' % value # prevent pending 'L' + else: + value = repr(value) + ip = self.getInterface() if ip: if not gbl.Gaudi.Utils.hasProperty(ip, name): raise AttributeError, 'property %s does not exist' % name - prop = ip.getProperty(name) - - if ROOT6WorkAroundEnabled('ROOT-7201'): - canSetValue = (hasattr(prop, 'value') and - 'const&[' not in prop.value.func_doc and - type(value) == type(prop.value())) - else: - canSetValue = (hasattr(prop, 'value') and - type(value) == type(prop.value())) - - if canSetValue: - if not prop.setValue(value): - raise AttributeError, 'property %s could not be set from %s' % ( - name, value) - else: - if tuple == type(value): - value = str(value) - elif hasattr(value, 'toString'): - value = value.toString() - elif not long == type(value): - value = '%s' % value - else: - value = '%d' % value - if ROOT6WorkAroundEnabled('ROOT-6028'): - sc = cppyy.gbl.GaudiPython.Helper.setPropertyFromString( - prop, value) - else: - sc = prop.fromString(value) - if sc.isFailure(): - raise AttributeError, 'property %s could not be set from %s' % ( - name, value) + ip.setProperty(name, value) else: - if type(value) == str: - value = '"%s"' % value # need double quotes - elif type(value) == tuple: - value = str(value) - elif hasattr(value, 'toString'): - value = value.toString() - elif type(value) == long: - value = '%d' % value # prevent pending 'L' - sp = gbl.GaudiPython.Helpers.mkStringProperty(name, str(value)) - self._optsvc.addPropertyToCatalogue(self._name, sp).ignore() + gbl.GaudiPython.Helpers.setProperty(self._svcloc, + '.'.join([self._name, name]), + value) def __getattr__(self, name): """ @@ -969,7 +944,6 @@ class AppMgr(iService): self.__dict__['_optsvc'] = InterfaceCast(gbl.IJobOptionsSvc)( Helper.service(self._svcloc, 'JobOptionsSvc')) # ------Configurables initialization (part2)------------------------------- - mkStringProperty = gbl.GaudiPython.Helpers.mkStringProperty for n in getNeededConfigurables(): c = Configurable.allConfigurables[n] if n in ['ApplicationMgr', 'MessageSvc']: @@ -982,11 +956,11 @@ class AppMgr(iService): # so we do it again to get it v = v.__resolve__() if type(v) == str: - v = '"%s"' % v # need double quotes - elif type(v) == long: + v = repr(v) # need double quotes + if type(v) == long: v = '%d' % v # prevent pending 'L' - self._optsvc.addPropertyToCatalogue( - n, mkStringProperty(p, str(v))) + gbl.GaudiPython.Helpers.setProperty(self._svcloc, + '.'.join([n, p]), str(v)) if hasattr(Configurable, "_configurationLocked"): Configurable._configurationLocked = True -- GitLab From 1d101dfa88035144e40da7cbad978ce0d3a9e6d7 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Thu, 28 Dec 2017 11:39:28 +0100 Subject: [PATCH 11/53] Removed asymmetry Property wrt Property --- GaudiExamples/scripts/StringKeyEx.py | 4 +- GaudiExamples/tests/qmtest/refs/Aida2Root.ref | 75 ++++++++++--------- GaudiExamples/tests/qmtest/refs/AlgTools.ref | 42 ++++++----- GaudiExamples/tests/qmtest/refs/AlgTools2.ref | 58 +++++++------- .../tests/qmtest/refs/AlgTools_pyopts.ref | 28 +++---- .../tests/qmtest/refs/EvtColsEx/Write.ref | 37 ++++----- .../tests/qmtest/refs/GaudiCommonTests.ref | 30 ++++---- .../tests/qmtest/refs/Histograms.ref | 50 +++++++------ .../tests/qmtest/refs/MetaDataSvc.ref | 56 +++++++------- .../tests/qmtest/refs/Properties.ref | 6 +- .../tests/qmtest/refs/Properties2.ref | 6 +- .../tests/qmtest/refs/Properties_py.ref | 6 +- .../qmtest/refs/ROOT_IO/ExtCollWrite.ref | 39 +++++----- .../qmtest/refs/TBB/GaudiCommonTests.ref | 30 ++++---- .../qmtest/refs/conditional_output/write.ref | 47 ++++++------ GaudiKernel/Gaudi/Parsers/Grammars.h | 1 + GaudiKernel/GaudiKernel/Property.h | 6 -- GaudiKernel/src/Lib/StringKey.cpp | 2 +- GaudiKernel/src/Util/genconf.cpp | 2 +- GaudiKernel/tests/src/test_Property.cpp | 31 +------- GaudiPolicy/python/GaudiTesting/BaseTest.py | 1 + 21 files changed, 271 insertions(+), 286 deletions(-) diff --git a/GaudiExamples/scripts/StringKeyEx.py b/GaudiExamples/scripts/StringKeyEx.py index ed9168b6a9..6e0620bdfa 100755 --- a/GaudiExamples/scripts/StringKeyEx.py +++ b/GaudiExamples/scripts/StringKeyEx.py @@ -57,13 +57,13 @@ if '__main__' == __name__: key = SK('new Key') - print 'set new key: ', key + print 'set new key: %r' % key ske.Key = key keys = [key, 'rrr', SK('s')] - print 'set new keys: ', keys + print 'set new keys: %r' % keys ske.Keys = keys diff --git a/GaudiExamples/tests/qmtest/refs/Aida2Root.ref b/GaudiExamples/tests/qmtest/refs/Aida2Root.ref index d251900e09..36d6eaf5fb 100644 --- a/GaudiExamples/tests/qmtest/refs/Aida2Root.ref +++ b/GaudiExamples/tests/qmtest/refs/Aida2Root.ref @@ -31,16 +31,16 @@ ApplicationMgr INFO Application Manager Configured successfully SimpleHistos DEBUG Property update for OutputLevel : new value = 2 SimpleHistos DEBUG Initialize base class GaudiCommon SimpleHistos DEBUG could not locate CounterSummarySvc, no counter summary will be made -SimpleHistos DEBUG List of ALL properties of GaudiHistoAlgorithm/SimpleHistos #properties = 50 +SimpleHistos DEBUG List of ALL properties of GaudiHistoAlgorithm/SimpleHistos #properties = 51 SimpleHistos DEBUG Property ['Name': Value] = 'AutoStringIDPurgeMap':{ '/' : '=SLASH=' } SimpleHistos DEBUG Property ['Name': Value] = 'UseSequencialNumericAutoIDs':False -SimpleHistos DEBUG Property ['Name': Value] = 'HeaderFor1DHistoTable':| Title | # | Mean | RMS | Skewness | Kurtosis | -SimpleHistos DEBUG Property ['Name': Value] = 'ShortFormatFor1DHistoTable': | %1$-25.25s %2% -SimpleHistos DEBUG Property ['Name': Value] = 'FormatFor1DHistoTable':| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g | +SimpleHistos DEBUG Property ['Name': Value] = 'HeaderFor1DHistoTable':'| Title | # | Mean | RMS | Skewness | Kurtosis |' +SimpleHistos DEBUG Property ['Name': Value] = 'ShortFormatFor1DHistoTable':' | %1$-25.25s %2%' +SimpleHistos DEBUG Property ['Name': Value] = 'FormatFor1DHistoTable':'| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g |' SimpleHistos DEBUG Property ['Name': Value] = 'MonitorHistograms':True SimpleHistos DEBUG Property ['Name': Value] = 'FullDetail':False -SimpleHistos DEBUG Property ['Name': Value] = 'HistoDir':SimpleHistos -SimpleHistos DEBUG Property ['Name': Value] = 'HistoTopDir': +SimpleHistos DEBUG Property ['Name': Value] = 'HistoDir':'SimpleHistos' +SimpleHistos DEBUG Property ['Name': Value] = 'HistoTopDir':'' SimpleHistos DEBUG Property ['Name': Value] = 'HistoOffSet':0 SimpleHistos DEBUG Property ['Name': Value] = 'HistoSplitDir':False SimpleHistos DEBUG Property ['Name': Value] = 'HistoCheckForNaN':True @@ -52,21 +52,22 @@ SimpleHistos DEBUG Property ['Name': Value] = 'VetoObjects':[ ] SimpleHistos DEBUG Property ['Name': Value] = 'StatEntityList':[ ] SimpleHistos DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] SimpleHistos DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -SimpleHistos DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -SimpleHistos DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -SimpleHistos DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -SimpleHistos DEBUG Property ['Name': Value] = 'RootInTES': -SimpleHistos DEBUG Property ['Name': Value] = 'Context': +SimpleHistos DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +SimpleHistos DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +SimpleHistos DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +SimpleHistos DEBUG Property ['Name': Value] = 'RootInTES':'' +SimpleHistos DEBUG Property ['Name': Value] = 'Context':'' SimpleHistos DEBUG Property ['Name': Value] = 'TypePrint':True SimpleHistos DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False SimpleHistos DEBUG Property ['Name': Value] = 'StatPrint':True SimpleHistos DEBUG Property ['Name': Value] = 'PropertiesPrint':False SimpleHistos DEBUG Property ['Name': Value] = 'ErrorsPrint':True +SimpleHistos DEBUG Property ['Name': Value] = 'FilterCircularDependencies':True SimpleHistos DEBUG Property ['Name': Value] = 'IsIOBound':False SimpleHistos DEBUG Property ['Name': Value] = 'NeededResources':[ ] SimpleHistos DEBUG Property ['Name': Value] = 'Cardinality':1 SimpleHistos DEBUG Property ['Name': Value] = 'RegisterForContextService':True -SimpleHistos DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +SimpleHistos DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' SimpleHistos DEBUG Property ['Name': Value] = 'Timeline':False SimpleHistos DEBUG Property ['Name': Value] = 'AuditStop':False SimpleHistos DEBUG Property ['Name': Value] = 'AuditStart':False @@ -94,18 +95,18 @@ SimpleHistos DEBUG GaudiHistoAlgorithm:: The histogram path is set to be SimpleHistos DEBUG input handles: 0 SimpleHistos DEBUG output handles: 0 SimpleHistos DEBUG Data Deps for SimpleHistos -Histos2 SUCCESS List of ALL properties of Gaudi::Examples::HistoProps/Histos2 #properties = 52 +Histos2 SUCCESS List of ALL properties of Gaudi::Examples::HistoProps/Histos2 #properties = 53 Histos2 SUCCESS Property ['Name': Value] = 'Histo2':('',-5.00000,5.00000,200) Histos2 SUCCESS Property ['Name': Value] = 'Histo1':('Histogram1',-3.00000,3.00000,200) Histos2 SUCCESS Property ['Name': Value] = 'AutoStringIDPurgeMap':{ '/' : '=SLASH=' } Histos2 SUCCESS Property ['Name': Value] = 'UseSequencialNumericAutoIDs':False -Histos2 SUCCESS Property ['Name': Value] = 'HeaderFor1DHistoTable':| Title | # | Mean | RMS | Skewness | Kurtosis | -Histos2 SUCCESS Property ['Name': Value] = 'ShortFormatFor1DHistoTable': | %1$-25.25s %2% -Histos2 SUCCESS Property ['Name': Value] = 'FormatFor1DHistoTable':| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g | +Histos2 SUCCESS Property ['Name': Value] = 'HeaderFor1DHistoTable':'| Title | # | Mean | RMS | Skewness | Kurtosis |' +Histos2 SUCCESS Property ['Name': Value] = 'ShortFormatFor1DHistoTable':' | %1$-25.25s %2%' +Histos2 SUCCESS Property ['Name': Value] = 'FormatFor1DHistoTable':'| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g |' Histos2 SUCCESS Property ['Name': Value] = 'MonitorHistograms':True Histos2 SUCCESS Property ['Name': Value] = 'FullDetail':False -Histos2 SUCCESS Property ['Name': Value] = 'HistoDir':Histos2 -Histos2 SUCCESS Property ['Name': Value] = 'HistoTopDir': +Histos2 SUCCESS Property ['Name': Value] = 'HistoDir':'Histos2' +Histos2 SUCCESS Property ['Name': Value] = 'HistoTopDir':'' Histos2 SUCCESS Property ['Name': Value] = 'HistoOffSet':0 Histos2 SUCCESS Property ['Name': Value] = 'HistoSplitDir':False Histos2 SUCCESS Property ['Name': Value] = 'HistoCheckForNaN':True @@ -117,21 +118,22 @@ Histos2 SUCCESS Property ['Name': Value] = 'VetoObjects':[ ] Histos2 SUCCESS Property ['Name': Value] = 'StatEntityList':[ ] Histos2 SUCCESS Property ['Name': Value] = 'CounterList':[ '.*' ] Histos2 SUCCESS Property ['Name': Value] = 'UseEfficiencyRowFormat':True -Histos2 SUCCESS Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -Histos2 SUCCESS Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -Histos2 SUCCESS Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -Histos2 SUCCESS Property ['Name': Value] = 'RootInTES': -Histos2 SUCCESS Property ['Name': Value] = 'Context': +Histos2 SUCCESS Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +Histos2 SUCCESS Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +Histos2 SUCCESS Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +Histos2 SUCCESS Property ['Name': Value] = 'RootInTES':'' +Histos2 SUCCESS Property ['Name': Value] = 'Context':'' Histos2 SUCCESS Property ['Name': Value] = 'TypePrint':True Histos2 SUCCESS Property ['Name': Value] = 'PrintEmptyCounters':False Histos2 SUCCESS Property ['Name': Value] = 'StatPrint':True Histos2 SUCCESS Property ['Name': Value] = 'PropertiesPrint':True Histos2 SUCCESS Property ['Name': Value] = 'ErrorsPrint':True +Histos2 SUCCESS Property ['Name': Value] = 'FilterCircularDependencies':True Histos2 SUCCESS Property ['Name': Value] = 'IsIOBound':False Histos2 SUCCESS Property ['Name': Value] = 'NeededResources':[ ] Histos2 SUCCESS Property ['Name': Value] = 'Cardinality':1 Histos2 SUCCESS Property ['Name': Value] = 'RegisterForContextService':True -Histos2 SUCCESS Property ['Name': Value] = 'MonitorService':MonitorSvc +Histos2 SUCCESS Property ['Name': Value] = 'MonitorService':'MonitorSvc' Histos2 SUCCESS Property ['Name': Value] = 'Timeline':False Histos2 SUCCESS Property ['Name': Value] = 'AuditStop':False Histos2 SUCCESS Property ['Name': Value] = 'AuditStart':False @@ -148,7 +150,7 @@ Histos2 SUCCESS Property ['Name': Value] = 'Enable':True Histos2 SUCCESS Property ['Name': Value] = 'OutputLevel':3 Histos2 SUCCESS Property ['Name': Value] = 'ExtraOutputs':[] Histos2 SUCCESS Property ['Name': Value] = 'ExtraInputs':[] -Aida2Root SUCCESS List of ALL properties of Aida2Root/Aida2Root #properties = 55 +Aida2Root SUCCESS List of ALL properties of Aida2Root/Aida2Root #properties = 56 Aida2Root SUCCESS Property ['Name': Value] = 'Profs2D':[ 'SimpleHistos/321' , 'SimpleHistos/2dprof' ] Aida2Root SUCCESS Property ['Name': Value] = 'Profs1D':[ 'SimpleHistos/Expo V Gauss 1DProf' ] Aida2Root SUCCESS Property ['Name': Value] = 'Histos3D':[ 'SimpleHistos/3D plot AutoID' , 'SimpleHistos/3d' ] @@ -156,13 +158,13 @@ Aida2Root SUCCESS Property ['Name': Value] = 'Histos2D':[ 'SimpleHistos Aida2Root SUCCESS Property ['Name': Value] = 'Histos1D':[ 'SimpleHistos/Gaussian mean=0, sigma=1' , 'SimpleHistos/101' , 'SimpleHistos/102' , 'SimpleHistos/1111' , 'SimpleHistos/test1' , 'SimpleHistos/subdir2/bino' , 'SimpleHistos/subdir1/bino' , 'SimpleHistos/poisson' ] Aida2Root SUCCESS Property ['Name': Value] = 'AutoStringIDPurgeMap':{ '/' : '=SLASH=' } Aida2Root SUCCESS Property ['Name': Value] = 'UseSequencialNumericAutoIDs':False -Aida2Root SUCCESS Property ['Name': Value] = 'HeaderFor1DHistoTable':| Title | # | Mean | RMS | Skewness | Kurtosis | -Aida2Root SUCCESS Property ['Name': Value] = 'ShortFormatFor1DHistoTable': | %1$-25.25s %2% -Aida2Root SUCCESS Property ['Name': Value] = 'FormatFor1DHistoTable':| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g | +Aida2Root SUCCESS Property ['Name': Value] = 'HeaderFor1DHistoTable':'| Title | # | Mean | RMS | Skewness | Kurtosis |' +Aida2Root SUCCESS Property ['Name': Value] = 'ShortFormatFor1DHistoTable':' | %1$-25.25s %2%' +Aida2Root SUCCESS Property ['Name': Value] = 'FormatFor1DHistoTable':'| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g |' Aida2Root SUCCESS Property ['Name': Value] = 'MonitorHistograms':True Aida2Root SUCCESS Property ['Name': Value] = 'FullDetail':False -Aida2Root SUCCESS Property ['Name': Value] = 'HistoDir':Aida2Root -Aida2Root SUCCESS Property ['Name': Value] = 'HistoTopDir': +Aida2Root SUCCESS Property ['Name': Value] = 'HistoDir':'Aida2Root' +Aida2Root SUCCESS Property ['Name': Value] = 'HistoTopDir':'' Aida2Root SUCCESS Property ['Name': Value] = 'HistoOffSet':0 Aida2Root SUCCESS Property ['Name': Value] = 'HistoSplitDir':False Aida2Root SUCCESS Property ['Name': Value] = 'HistoCheckForNaN':True @@ -174,21 +176,22 @@ Aida2Root SUCCESS Property ['Name': Value] = 'VetoObjects':[ ] Aida2Root SUCCESS Property ['Name': Value] = 'StatEntityList':[ ] Aida2Root SUCCESS Property ['Name': Value] = 'CounterList':[ '.*' ] Aida2Root SUCCESS Property ['Name': Value] = 'UseEfficiencyRowFormat':True -Aida2Root SUCCESS Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -Aida2Root SUCCESS Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -Aida2Root SUCCESS Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -Aida2Root SUCCESS Property ['Name': Value] = 'RootInTES': -Aida2Root SUCCESS Property ['Name': Value] = 'Context': +Aida2Root SUCCESS Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +Aida2Root SUCCESS Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +Aida2Root SUCCESS Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +Aida2Root SUCCESS Property ['Name': Value] = 'RootInTES':'' +Aida2Root SUCCESS Property ['Name': Value] = 'Context':'' Aida2Root SUCCESS Property ['Name': Value] = 'TypePrint':True Aida2Root SUCCESS Property ['Name': Value] = 'PrintEmptyCounters':False Aida2Root SUCCESS Property ['Name': Value] = 'StatPrint':True Aida2Root SUCCESS Property ['Name': Value] = 'PropertiesPrint':True Aida2Root SUCCESS Property ['Name': Value] = 'ErrorsPrint':True +Aida2Root SUCCESS Property ['Name': Value] = 'FilterCircularDependencies':True Aida2Root SUCCESS Property ['Name': Value] = 'IsIOBound':False Aida2Root SUCCESS Property ['Name': Value] = 'NeededResources':[ ] Aida2Root SUCCESS Property ['Name': Value] = 'Cardinality':1 Aida2Root SUCCESS Property ['Name': Value] = 'RegisterForContextService':True -Aida2Root SUCCESS Property ['Name': Value] = 'MonitorService':MonitorSvc +Aida2Root SUCCESS Property ['Name': Value] = 'MonitorService':'MonitorSvc' Aida2Root SUCCESS Property ['Name': Value] = 'Timeline':False Aida2Root SUCCESS Property ['Name': Value] = 'AuditStop':False Aida2Root SUCCESS Property ['Name': Value] = 'AuditStart':False diff --git a/GaudiExamples/tests/qmtest/refs/AlgTools.ref b/GaudiExamples/tests/qmtest/refs/AlgTools.ref index 0e52ad0f39..95387e2cd5 100644 --- a/GaudiExamples/tests/qmtest/refs/AlgTools.ref +++ b/GaudiExamples/tests/qmtest/refs/AlgTools.ref @@ -62,63 +62,65 @@ ToolSvc.ToolA DEBUG Property update for OutputLevel : new value = 2 ToolSvc.ToolA DEBUG Initialize ToolSvc.ToolA DEBUG Initialize base class GaudiCommon ToolSvc.ToolA DEBUG could not locate CounterSummarySvc, no counter summary will be made -ToolSvc.ToolA DEBUG List of ALL properties of TestTool/ToolSvc.ToolA #properties = 24 +ToolSvc.ToolA DEBUG List of ALL properties of TestTool/ToolSvc.ToolA #properties = 25 ToolSvc.ToolA DEBUG Property ['Name': Value] = 'Tools':[ 'TestTool/ToolB' ] -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ContextService':AlgContextSvc +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ContextService':'AlgContextSvc' ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatEntityList':[ ] ToolSvc.ToolA DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] ToolSvc.ToolA DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RootInTES': -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'Context': +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RootInTES':'' +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'Context':'' ToolSvc.ToolA DEBUG Property ['Name': Value] = 'TypePrint':True ToolSvc.ToolA DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatPrint':True ToolSvc.ToolA DEBUG Property ['Name': Value] = 'PropertiesPrint':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ErrorsPrint':True -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ExtraOutputs':[] -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ExtraInputs':[] ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditRestart':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditReinitialize':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditFinalize':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditStop':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditStart':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditInitialize':False -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditTools':False +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' ToolSvc.ToolA DEBUG Property ['Name': Value] = 'OutputLevel':2 +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ExtraOutputs':[] +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ExtraInputs':[] ToolSvc.ToolA DEBUG Loading tool ToolB of type TestTool ToolSvc.ToolB DEBUG Property update for OutputLevel : new value = 2 ToolSvc.ToolB DEBUG Initialize ToolSvc.ToolB DEBUG Initialize base class GaudiCommon ToolSvc.ToolB DEBUG could not locate CounterSummarySvc, no counter summary will be made -ToolSvc.ToolB DEBUG List of ALL properties of TestTool/ToolSvc.ToolB #properties = 24 +ToolSvc.ToolB DEBUG List of ALL properties of TestTool/ToolSvc.ToolB #properties = 25 ToolSvc.ToolB DEBUG Property ['Name': Value] = 'Tools':[ 'TestTool/ToolA' ] -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ContextService':AlgContextSvc +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ContextService':'AlgContextSvc' ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatEntityList':[ ] ToolSvc.ToolB DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] ToolSvc.ToolB DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RootInTES': -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'Context': +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RootInTES':'' +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'Context':'' ToolSvc.ToolB DEBUG Property ['Name': Value] = 'TypePrint':True ToolSvc.ToolB DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatPrint':True ToolSvc.ToolB DEBUG Property ['Name': Value] = 'PropertiesPrint':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ErrorsPrint':True -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ExtraOutputs':[] -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ExtraInputs':[] ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditRestart':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditReinitialize':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditFinalize':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditStop':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditStart':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditInitialize':False -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditTools':False +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' ToolSvc.ToolB DEBUG Property ['Name': Value] = 'OutputLevel':2 +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ExtraOutputs':[] +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ExtraInputs':[] ToolSvc.ToolB DEBUG Loading tool ToolA of type TestTool ToolSvc.ToolB DEBUG Registering tool ToolSvc.ToolA ToolSvc.ToolA DEBUG Registering tool ToolSvc.ToolB diff --git a/GaudiExamples/tests/qmtest/refs/AlgTools2.ref b/GaudiExamples/tests/qmtest/refs/AlgTools2.ref index 361f7907c2..88223e30db 100644 --- a/GaudiExamples/tests/qmtest/refs/AlgTools2.ref +++ b/GaudiExamples/tests/qmtest/refs/AlgTools2.ref @@ -48,17 +48,17 @@ MyAlg DEBUG Property ['Name': Value] = 'UnusedToolHandle':TestToo MyAlg DEBUG Property ['Name': Value] = 'GenericToolHandle':MyTool/GenericToolHandle MyAlg DEBUG Property ['Name': Value] = 'PubToolHandle':MyTool/PubToolHandle MyAlg DEBUG Property ['Name': Value] = 'PrivToolHandle':MyTool/PrivToolHandle -MyAlg DEBUG Property ['Name': Value] = 'ToolWithName':MyTool +MyAlg DEBUG Property ['Name': Value] = 'ToolWithName':'MyTool' MyAlg DEBUG Property ['Name': Value] = 'RequireObjects':[ ] MyAlg DEBUG Property ['Name': Value] = 'VetoObjects':[ ] MyAlg DEBUG Property ['Name': Value] = 'StatEntityList':[ ] MyAlg DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] MyAlg DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -MyAlg DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -MyAlg DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -MyAlg DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -MyAlg DEBUG Property ['Name': Value] = 'RootInTES': -MyAlg DEBUG Property ['Name': Value] = 'Context': +MyAlg DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +MyAlg DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +MyAlg DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +MyAlg DEBUG Property ['Name': Value] = 'RootInTES':'' +MyAlg DEBUG Property ['Name': Value] = 'Context':'' MyAlg DEBUG Property ['Name': Value] = 'TypePrint':True MyAlg DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False MyAlg DEBUG Property ['Name': Value] = 'StatPrint':True @@ -69,7 +69,7 @@ MyAlg DEBUG Property ['Name': Value] = 'IsIOBound':False MyAlg DEBUG Property ['Name': Value] = 'NeededResources':[ ] MyAlg DEBUG Property ['Name': Value] = 'Cardinality':1 MyAlg DEBUG Property ['Name': Value] = 'RegisterForContextService':True -MyAlg DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +MyAlg DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' MyAlg DEBUG Property ['Name': Value] = 'Timeline':False MyAlg DEBUG Property ['Name': Value] = 'AuditStop':False MyAlg DEBUG Property ['Name': Value] = 'AuditStart':False @@ -111,18 +111,18 @@ MyAlg.MyGaudiTool DEBUG Initialize base class GaudiCommon MyAlg.MyGaudiTool DEBUG could not locate CounterSummarySvc, no counter summary will be made MyAlg.MyGaudiTool DEBUG List of ALL properties of MyGaudiTool/MyAlg.MyGaudiTool #properties = 28 MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'Bool':True -MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'String':hundred +MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'String':'hundred' MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'Double':100.00000 MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'Int':100 -MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'ContextService':AlgContextSvc +MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'ContextService':'AlgContextSvc' MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'StatEntityList':[ ] MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'RootInTES': -MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'Context': +MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'RootInTES':'' +MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'Context':'' MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'TypePrint':True MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'StatPrint':True @@ -135,7 +135,7 @@ MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'AuditStop':False MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'AuditStart':False MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'AuditInitialize':False MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'AuditTools':False -MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'OutputLevel':2 MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'ExtraOutputs':[] MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'ExtraInputs':[] @@ -206,15 +206,15 @@ ToolSvc.ToolA DEBUG Initialize base class GaudiCommon ToolSvc.ToolA DEBUG could not locate CounterSummarySvc, no counter summary will be made ToolSvc.ToolA DEBUG List of ALL properties of TestTool/ToolSvc.ToolA #properties = 25 ToolSvc.ToolA DEBUG Property ['Name': Value] = 'Tools':[ 'TestTool/ToolB' ] -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ContextService':AlgContextSvc +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ContextService':'AlgContextSvc' ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatEntityList':[ ] ToolSvc.ToolA DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] ToolSvc.ToolA DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RootInTES': -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'Context': +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RootInTES':'' +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'Context':'' ToolSvc.ToolA DEBUG Property ['Name': Value] = 'TypePrint':True ToolSvc.ToolA DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatPrint':True @@ -227,7 +227,7 @@ ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditStop':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditStart':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditInitialize':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditTools':False -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' ToolSvc.ToolA DEBUG Property ['Name': Value] = 'OutputLevel':2 ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ExtraOutputs':[] ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ExtraInputs':[] @@ -238,15 +238,15 @@ ToolSvc.ToolB DEBUG Initialize base class GaudiCommon ToolSvc.ToolB DEBUG could not locate CounterSummarySvc, no counter summary will be made ToolSvc.ToolB DEBUG List of ALL properties of TestTool/ToolSvc.ToolB #properties = 25 ToolSvc.ToolB DEBUG Property ['Name': Value] = 'Tools':[ 'TestTool/ToolA' ] -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ContextService':AlgContextSvc +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ContextService':'AlgContextSvc' ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatEntityList':[ ] ToolSvc.ToolB DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] ToolSvc.ToolB DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RootInTES': -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'Context': +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RootInTES':'' +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'Context':'' ToolSvc.ToolB DEBUG Property ['Name': Value] = 'TypePrint':True ToolSvc.ToolB DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatPrint':True @@ -259,7 +259,7 @@ ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditStop':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditStart':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditInitialize':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditTools':False -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' ToolSvc.ToolB DEBUG Property ['Name': Value] = 'OutputLevel':2 ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ExtraOutputs':[] ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ExtraInputs':[] diff --git a/GaudiExamples/tests/qmtest/refs/AlgTools_pyopts.ref b/GaudiExamples/tests/qmtest/refs/AlgTools_pyopts.ref index 5b65ed2dbd..938eb9f983 100644 --- a/GaudiExamples/tests/qmtest/refs/AlgTools_pyopts.ref +++ b/GaudiExamples/tests/qmtest/refs/AlgTools_pyopts.ref @@ -93,15 +93,15 @@ ToolSvc.ToolA DEBUG Initialize base class GaudiCommon ToolSvc.ToolA DEBUG could not locate CounterSummarySvc, no counter summary will be made ToolSvc.ToolA DEBUG List of ALL properties of TestTool/ToolSvc.ToolA #properties = 25 ToolSvc.ToolA DEBUG Property ['Name': Value] = 'Tools':[ 'TestTool/ToolB' ] -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ContextService':AlgContextSvc +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ContextService':'AlgContextSvc' ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatEntityList':[ ] ToolSvc.ToolA DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] ToolSvc.ToolA DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RootInTES': -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'Context': +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RootInTES':'' +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'Context':'' ToolSvc.ToolA DEBUG Property ['Name': Value] = 'TypePrint':True ToolSvc.ToolA DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatPrint':True @@ -114,7 +114,7 @@ ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditStop':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditStart':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditInitialize':False ToolSvc.ToolA DEBUG Property ['Name': Value] = 'AuditTools':False -ToolSvc.ToolA DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +ToolSvc.ToolA DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' ToolSvc.ToolA DEBUG Property ['Name': Value] = 'OutputLevel':2 ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ExtraOutputs':[] ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ExtraInputs':[] @@ -125,15 +125,15 @@ ToolSvc.ToolB DEBUG Initialize base class GaudiCommon ToolSvc.ToolB DEBUG could not locate CounterSummarySvc, no counter summary will be made ToolSvc.ToolB DEBUG List of ALL properties of TestTool/ToolSvc.ToolB #properties = 25 ToolSvc.ToolB DEBUG Property ['Name': Value] = 'Tools':[ 'TestTool/ToolA' ] -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ContextService':AlgContextSvc +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ContextService':'AlgContextSvc' ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatEntityList':[ ] ToolSvc.ToolB DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] ToolSvc.ToolB DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RootInTES': -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'Context': +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RootInTES':'' +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'Context':'' ToolSvc.ToolB DEBUG Property ['Name': Value] = 'TypePrint':True ToolSvc.ToolB DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatPrint':True @@ -146,7 +146,7 @@ ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditStop':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditStart':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditInitialize':False ToolSvc.ToolB DEBUG Property ['Name': Value] = 'AuditTools':False -ToolSvc.ToolB DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +ToolSvc.ToolB DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' ToolSvc.ToolB DEBUG Property ['Name': Value] = 'OutputLevel':2 ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ExtraOutputs':[] ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ExtraInputs':[] diff --git a/GaudiExamples/tests/qmtest/refs/EvtColsEx/Write.ref b/GaudiExamples/tests/qmtest/refs/EvtColsEx/Write.ref index 2384a1f88f..bb09045a0c 100644 --- a/GaudiExamples/tests/qmtest/refs/EvtColsEx/Write.ref +++ b/GaudiExamples/tests/qmtest/refs/EvtColsEx/Write.ref @@ -30,30 +30,30 @@ RndmGenSvc.Engine INFO Generator engine type:CLHEP::RanluxEngine RndmGenSvc.Engine INFO Current Seed:1234567 Luxury:3 RndmGenSvc INFO Using Random engine:HepRndm::Engine EvtTupleSvc INFO Added stream file:PFN:EvtColsEx.tags as EVTCOLS -Fill SUCCESS List of ALL properties of Gaudi::Examples::EvtColAlg/Fill #properties = 64 -Fill SUCCESS Property ['Name': Value] = 'EvtColDir':Fill -Fill SUCCESS Property ['Name': Value] = 'EvtColTopDir': -Fill SUCCESS Property ['Name': Value] = 'EvtColLUN':EVTCOLS +Fill SUCCESS List of ALL properties of Gaudi::Examples::EvtColAlg/Fill #properties = 65 +Fill SUCCESS Property ['Name': Value] = 'EvtColDir':'Fill' +Fill SUCCESS Property ['Name': Value] = 'EvtColTopDir':'' +Fill SUCCESS Property ['Name': Value] = 'EvtColLUN':'EVTCOLS' Fill SUCCESS Property ['Name': Value] = 'EvtColOffSet':0 Fill SUCCESS Property ['Name': Value] = 'EvtColSplitDir':False Fill SUCCESS Property ['Name': Value] = 'EvtColsPrint':True Fill SUCCESS Property ['Name': Value] = 'EvtColsProduce':True -Fill SUCCESS Property ['Name': Value] = 'NTupleDir':Fill -Fill SUCCESS Property ['Name': Value] = 'NTupleTopDir': -Fill SUCCESS Property ['Name': Value] = 'NTupleLUN':FILE1 +Fill SUCCESS Property ['Name': Value] = 'NTupleDir':'Fill' +Fill SUCCESS Property ['Name': Value] = 'NTupleTopDir':'' +Fill SUCCESS Property ['Name': Value] = 'NTupleLUN':'FILE1' Fill SUCCESS Property ['Name': Value] = 'NTupleOffSet':0 Fill SUCCESS Property ['Name': Value] = 'NTupleSplitDir':False Fill SUCCESS Property ['Name': Value] = 'NTuplePrint':False Fill SUCCESS Property ['Name': Value] = 'NTupleProduce':False Fill SUCCESS Property ['Name': Value] = 'AutoStringIDPurgeMap':{ '/' : '=SLASH=' } Fill SUCCESS Property ['Name': Value] = 'UseSequencialNumericAutoIDs':False -Fill SUCCESS Property ['Name': Value] = 'HeaderFor1DHistoTable':| Title | # | Mean | RMS | Skewness | Kurtosis | -Fill SUCCESS Property ['Name': Value] = 'ShortFormatFor1DHistoTable': | %1$-25.25s %2% -Fill SUCCESS Property ['Name': Value] = 'FormatFor1DHistoTable':| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g | +Fill SUCCESS Property ['Name': Value] = 'HeaderFor1DHistoTable':'| Title | # | Mean | RMS | Skewness | Kurtosis |' +Fill SUCCESS Property ['Name': Value] = 'ShortFormatFor1DHistoTable':' | %1$-25.25s %2%' +Fill SUCCESS Property ['Name': Value] = 'FormatFor1DHistoTable':'| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g |' Fill SUCCESS Property ['Name': Value] = 'MonitorHistograms':True Fill SUCCESS Property ['Name': Value] = 'FullDetail':False -Fill SUCCESS Property ['Name': Value] = 'HistoDir':Fill -Fill SUCCESS Property ['Name': Value] = 'HistoTopDir': +Fill SUCCESS Property ['Name': Value] = 'HistoDir':'Fill' +Fill SUCCESS Property ['Name': Value] = 'HistoTopDir':'' Fill SUCCESS Property ['Name': Value] = 'HistoOffSet':0 Fill SUCCESS Property ['Name': Value] = 'HistoSplitDir':False Fill SUCCESS Property ['Name': Value] = 'HistoCheckForNaN':True @@ -65,21 +65,22 @@ Fill SUCCESS Property ['Name': Value] = 'VetoObjects':[ ] Fill SUCCESS Property ['Name': Value] = 'StatEntityList':[ ] Fill SUCCESS Property ['Name': Value] = 'CounterList':[ '.*' ] Fill SUCCESS Property ['Name': Value] = 'UseEfficiencyRowFormat':True -Fill SUCCESS Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -Fill SUCCESS Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -Fill SUCCESS Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -Fill SUCCESS Property ['Name': Value] = 'RootInTES': -Fill SUCCESS Property ['Name': Value] = 'Context': +Fill SUCCESS Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +Fill SUCCESS Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +Fill SUCCESS Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +Fill SUCCESS Property ['Name': Value] = 'RootInTES':'' +Fill SUCCESS Property ['Name': Value] = 'Context':'' Fill SUCCESS Property ['Name': Value] = 'TypePrint':False Fill SUCCESS Property ['Name': Value] = 'PrintEmptyCounters':False Fill SUCCESS Property ['Name': Value] = 'StatPrint':True Fill SUCCESS Property ['Name': Value] = 'PropertiesPrint':True Fill SUCCESS Property ['Name': Value] = 'ErrorsPrint':True +Fill SUCCESS Property ['Name': Value] = 'FilterCircularDependencies':True Fill SUCCESS Property ['Name': Value] = 'IsIOBound':False Fill SUCCESS Property ['Name': Value] = 'NeededResources':[ ] Fill SUCCESS Property ['Name': Value] = 'Cardinality':1 Fill SUCCESS Property ['Name': Value] = 'RegisterForContextService':True -Fill SUCCESS Property ['Name': Value] = 'MonitorService':MonitorSvc +Fill SUCCESS Property ['Name': Value] = 'MonitorService':'MonitorSvc' Fill SUCCESS Property ['Name': Value] = 'Timeline':False Fill SUCCESS Property ['Name': Value] = 'AuditStop':False Fill SUCCESS Property ['Name': Value] = 'AuditStart':False diff --git a/GaudiExamples/tests/qmtest/refs/GaudiCommonTests.ref b/GaudiExamples/tests/qmtest/refs/GaudiCommonTests.ref index 604cb0a8ba..24ecd863ca 100644 --- a/GaudiExamples/tests/qmtest/refs/GaudiCommonTests.ref +++ b/GaudiExamples/tests/qmtest/refs/GaudiCommonTests.ref @@ -26,27 +26,28 @@ StatusCodeSvc INFO initialize Test1 DEBUG Property update for OutputLevel : new value = 2 Test1 DEBUG Initialize base class GaudiCommon Test1 DEBUG could not locate CounterSummarySvc, no counter summary will be made -Test1 DEBUG List of ALL properties of GaudiCommonTests/Test1 #properties = 35 +Test1 DEBUG List of ALL properties of GaudiCommonTests/Test1 #properties = 36 Test1 DEBUG Property ['Name': Value] = 'RequireObjects':[ ] Test1 DEBUG Property ['Name': Value] = 'VetoObjects':[ ] Test1 DEBUG Property ['Name': Value] = 'StatEntityList':[ ] Test1 DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] Test1 DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -Test1 DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -Test1 DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -Test1 DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -Test1 DEBUG Property ['Name': Value] = 'RootInTES': -Test1 DEBUG Property ['Name': Value] = 'Context': +Test1 DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +Test1 DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +Test1 DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +Test1 DEBUG Property ['Name': Value] = 'RootInTES':'' +Test1 DEBUG Property ['Name': Value] = 'Context':'' Test1 DEBUG Property ['Name': Value] = 'TypePrint':True Test1 DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False Test1 DEBUG Property ['Name': Value] = 'StatPrint':True Test1 DEBUG Property ['Name': Value] = 'PropertiesPrint':False Test1 DEBUG Property ['Name': Value] = 'ErrorsPrint':True +Test1 DEBUG Property ['Name': Value] = 'FilterCircularDependencies':True Test1 DEBUG Property ['Name': Value] = 'IsIOBound':False Test1 DEBUG Property ['Name': Value] = 'NeededResources':[ ] Test1 DEBUG Property ['Name': Value] = 'Cardinality':1 Test1 DEBUG Property ['Name': Value] = 'RegisterForContextService':True -Test1 DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +Test1 DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' Test1 DEBUG Property ['Name': Value] = 'Timeline':False Test1 DEBUG Property ['Name': Value] = 'AuditStop':False Test1 DEBUG Property ['Name': Value] = 'AuditStart':False @@ -69,27 +70,28 @@ Test1 DEBUG Data Deps for Test1 Test2 DEBUG Property update for OutputLevel : new value = 2 Test2 DEBUG Initialize base class GaudiCommon Test2 DEBUG could not locate CounterSummarySvc, no counter summary will be made -Test2 DEBUG List of ALL properties of GaudiCommonTests/Test2 #properties = 35 +Test2 DEBUG List of ALL properties of GaudiCommonTests/Test2 #properties = 36 Test2 DEBUG Property ['Name': Value] = 'RequireObjects':[ ] Test2 DEBUG Property ['Name': Value] = 'VetoObjects':[ ] Test2 DEBUG Property ['Name': Value] = 'StatEntityList':[ ] Test2 DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] Test2 DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -Test2 DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -Test2 DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -Test2 DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -Test2 DEBUG Property ['Name': Value] = 'RootInTES':microDST/ -Test2 DEBUG Property ['Name': Value] = 'Context': +Test2 DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +Test2 DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +Test2 DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +Test2 DEBUG Property ['Name': Value] = 'RootInTES':'microDST/' +Test2 DEBUG Property ['Name': Value] = 'Context':'' Test2 DEBUG Property ['Name': Value] = 'TypePrint':True Test2 DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False Test2 DEBUG Property ['Name': Value] = 'StatPrint':True Test2 DEBUG Property ['Name': Value] = 'PropertiesPrint':False Test2 DEBUG Property ['Name': Value] = 'ErrorsPrint':True +Test2 DEBUG Property ['Name': Value] = 'FilterCircularDependencies':True Test2 DEBUG Property ['Name': Value] = 'IsIOBound':False Test2 DEBUG Property ['Name': Value] = 'NeededResources':[ ] Test2 DEBUG Property ['Name': Value] = 'Cardinality':1 Test2 DEBUG Property ['Name': Value] = 'RegisterForContextService':True -Test2 DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +Test2 DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' Test2 DEBUG Property ['Name': Value] = 'Timeline':False Test2 DEBUG Property ['Name': Value] = 'AuditStop':False Test2 DEBUG Property ['Name': Value] = 'AuditStart':False diff --git a/GaudiExamples/tests/qmtest/refs/Histograms.ref b/GaudiExamples/tests/qmtest/refs/Histograms.ref index e0b4825a96..2e539446c9 100644 --- a/GaudiExamples/tests/qmtest/refs/Histograms.ref +++ b/GaudiExamples/tests/qmtest/refs/Histograms.ref @@ -29,16 +29,16 @@ ApplicationMgr INFO Application Manager Configured successfully SimpleHistos DEBUG Property update for OutputLevel : new value = 2 SimpleHistos DEBUG Initialize base class GaudiCommon SimpleHistos DEBUG could not locate CounterSummarySvc, no counter summary will be made -SimpleHistos DEBUG List of ALL properties of GaudiHistoAlgorithm/SimpleHistos #properties = 50 +SimpleHistos DEBUG List of ALL properties of GaudiHistoAlgorithm/SimpleHistos #properties = 51 SimpleHistos DEBUG Property ['Name': Value] = 'AutoStringIDPurgeMap':{ '/' : '=SLASH=' } SimpleHistos DEBUG Property ['Name': Value] = 'UseSequencialNumericAutoIDs':False -SimpleHistos DEBUG Property ['Name': Value] = 'HeaderFor1DHistoTable':| Title | # | Mean | RMS | Skewness | Kurtosis | -SimpleHistos DEBUG Property ['Name': Value] = 'ShortFormatFor1DHistoTable': | %1$-25.25s %2% -SimpleHistos DEBUG Property ['Name': Value] = 'FormatFor1DHistoTable':| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g | +SimpleHistos DEBUG Property ['Name': Value] = 'HeaderFor1DHistoTable':'| Title | # | Mean | RMS | Skewness | Kurtosis |' +SimpleHistos DEBUG Property ['Name': Value] = 'ShortFormatFor1DHistoTable':' | %1$-25.25s %2%' +SimpleHistos DEBUG Property ['Name': Value] = 'FormatFor1DHistoTable':'| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g |' SimpleHistos DEBUG Property ['Name': Value] = 'MonitorHistograms':True SimpleHistos DEBUG Property ['Name': Value] = 'FullDetail':False -SimpleHistos DEBUG Property ['Name': Value] = 'HistoDir':SimpleHistos -SimpleHistos DEBUG Property ['Name': Value] = 'HistoTopDir': +SimpleHistos DEBUG Property ['Name': Value] = 'HistoDir':'SimpleHistos' +SimpleHistos DEBUG Property ['Name': Value] = 'HistoTopDir':'' SimpleHistos DEBUG Property ['Name': Value] = 'HistoOffSet':0 SimpleHistos DEBUG Property ['Name': Value] = 'HistoSplitDir':False SimpleHistos DEBUG Property ['Name': Value] = 'HistoCheckForNaN':True @@ -50,21 +50,22 @@ SimpleHistos DEBUG Property ['Name': Value] = 'VetoObjects':[ ] SimpleHistos DEBUG Property ['Name': Value] = 'StatEntityList':[ ] SimpleHistos DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] SimpleHistos DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -SimpleHistos DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -SimpleHistos DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -SimpleHistos DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -SimpleHistos DEBUG Property ['Name': Value] = 'RootInTES': -SimpleHistos DEBUG Property ['Name': Value] = 'Context': +SimpleHistos DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +SimpleHistos DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +SimpleHistos DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +SimpleHistos DEBUG Property ['Name': Value] = 'RootInTES':'' +SimpleHistos DEBUG Property ['Name': Value] = 'Context':'' SimpleHistos DEBUG Property ['Name': Value] = 'TypePrint':True SimpleHistos DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False SimpleHistos DEBUG Property ['Name': Value] = 'StatPrint':True SimpleHistos DEBUG Property ['Name': Value] = 'PropertiesPrint':False SimpleHistos DEBUG Property ['Name': Value] = 'ErrorsPrint':True +SimpleHistos DEBUG Property ['Name': Value] = 'FilterCircularDependencies':True SimpleHistos DEBUG Property ['Name': Value] = 'IsIOBound':False SimpleHistos DEBUG Property ['Name': Value] = 'NeededResources':[ ] SimpleHistos DEBUG Property ['Name': Value] = 'Cardinality':1 SimpleHistos DEBUG Property ['Name': Value] = 'RegisterForContextService':True -SimpleHistos DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +SimpleHistos DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' SimpleHistos DEBUG Property ['Name': Value] = 'Timeline':False SimpleHistos DEBUG Property ['Name': Value] = 'AuditStop':False SimpleHistos DEBUG Property ['Name': Value] = 'AuditStart':False @@ -92,18 +93,18 @@ SimpleHistos DEBUG GaudiHistoAlgorithm:: The histogram path is set to be SimpleHistos DEBUG input handles: 0 SimpleHistos DEBUG output handles: 0 SimpleHistos DEBUG Data Deps for SimpleHistos -Histos2 SUCCESS List of ALL properties of Gaudi::Examples::HistoProps/Histos2 #properties = 52 +Histos2 SUCCESS List of ALL properties of Gaudi::Examples::HistoProps/Histos2 #properties = 53 Histos2 SUCCESS Property ['Name': Value] = 'Histo2':('',-5.00000,5.00000,200) Histos2 SUCCESS Property ['Name': Value] = 'Histo1':('Histogram1',-3.00000,3.00000,200) Histos2 SUCCESS Property ['Name': Value] = 'AutoStringIDPurgeMap':{ '/' : '=SLASH=' } Histos2 SUCCESS Property ['Name': Value] = 'UseSequencialNumericAutoIDs':False -Histos2 SUCCESS Property ['Name': Value] = 'HeaderFor1DHistoTable':| Title | # | Mean | RMS | Skewness | Kurtosis | -Histos2 SUCCESS Property ['Name': Value] = 'ShortFormatFor1DHistoTable': | %1$-25.25s %2% -Histos2 SUCCESS Property ['Name': Value] = 'FormatFor1DHistoTable':| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g | +Histos2 SUCCESS Property ['Name': Value] = 'HeaderFor1DHistoTable':'| Title | # | Mean | RMS | Skewness | Kurtosis |' +Histos2 SUCCESS Property ['Name': Value] = 'ShortFormatFor1DHistoTable':' | %1$-25.25s %2%' +Histos2 SUCCESS Property ['Name': Value] = 'FormatFor1DHistoTable':'| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g |' Histos2 SUCCESS Property ['Name': Value] = 'MonitorHistograms':True Histos2 SUCCESS Property ['Name': Value] = 'FullDetail':False -Histos2 SUCCESS Property ['Name': Value] = 'HistoDir':Histos2 -Histos2 SUCCESS Property ['Name': Value] = 'HistoTopDir': +Histos2 SUCCESS Property ['Name': Value] = 'HistoDir':'Histos2' +Histos2 SUCCESS Property ['Name': Value] = 'HistoTopDir':'' Histos2 SUCCESS Property ['Name': Value] = 'HistoOffSet':0 Histos2 SUCCESS Property ['Name': Value] = 'HistoSplitDir':False Histos2 SUCCESS Property ['Name': Value] = 'HistoCheckForNaN':True @@ -115,21 +116,22 @@ Histos2 SUCCESS Property ['Name': Value] = 'VetoObjects':[ ] Histos2 SUCCESS Property ['Name': Value] = 'StatEntityList':[ ] Histos2 SUCCESS Property ['Name': Value] = 'CounterList':[ '.*' ] Histos2 SUCCESS Property ['Name': Value] = 'UseEfficiencyRowFormat':True -Histos2 SUCCESS Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -Histos2 SUCCESS Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -Histos2 SUCCESS Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -Histos2 SUCCESS Property ['Name': Value] = 'RootInTES': -Histos2 SUCCESS Property ['Name': Value] = 'Context': +Histos2 SUCCESS Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +Histos2 SUCCESS Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +Histos2 SUCCESS Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +Histos2 SUCCESS Property ['Name': Value] = 'RootInTES':'' +Histos2 SUCCESS Property ['Name': Value] = 'Context':'' Histos2 SUCCESS Property ['Name': Value] = 'TypePrint':True Histos2 SUCCESS Property ['Name': Value] = 'PrintEmptyCounters':False Histos2 SUCCESS Property ['Name': Value] = 'StatPrint':True Histos2 SUCCESS Property ['Name': Value] = 'PropertiesPrint':True Histos2 SUCCESS Property ['Name': Value] = 'ErrorsPrint':True +Histos2 SUCCESS Property ['Name': Value] = 'FilterCircularDependencies':True Histos2 SUCCESS Property ['Name': Value] = 'IsIOBound':False Histos2 SUCCESS Property ['Name': Value] = 'NeededResources':[ ] Histos2 SUCCESS Property ['Name': Value] = 'Cardinality':1 Histos2 SUCCESS Property ['Name': Value] = 'RegisterForContextService':True -Histos2 SUCCESS Property ['Name': Value] = 'MonitorService':MonitorSvc +Histos2 SUCCESS Property ['Name': Value] = 'MonitorService':'MonitorSvc' Histos2 SUCCESS Property ['Name': Value] = 'Timeline':False Histos2 SUCCESS Property ['Name': Value] = 'AuditStop':False Histos2 SUCCESS Property ['Name': Value] = 'AuditStart':False diff --git a/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref b/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref index 7129dbcbaa..124e3fff6c 100644 --- a/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref +++ b/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref @@ -21,36 +21,36 @@ Gaudi::MetaDataSvc DEBUG started Gaudi::MetaDataSvc DEBUG Metadata collected: ApplicationMgr.ActivateHistory:False ApplicationMgr.AlgTypeAliases:{ } -ApplicationMgr.AppName:ApplicationMgr -ApplicationMgr.AppVersion: +ApplicationMgr.AppName:'ApplicationMgr' +ApplicationMgr.AppVersion:'' ApplicationMgr.AuditAlgorithms:False ApplicationMgr.AuditServices:False ApplicationMgr.AuditTools:False ApplicationMgr.CreateSvc:[ ] ApplicationMgr.Dlls:[ ] ApplicationMgr.Environment:{ } -ApplicationMgr.EventLoop:EventLoopMgr +ApplicationMgr.EventLoop:'EventLoopMgr' ApplicationMgr.EvtMax:10 -ApplicationMgr.EvtSel:NONE +ApplicationMgr.EvtSel:'NONE' ApplicationMgr.Exit:0 ApplicationMgr.ExtSvc:[ 'RndmGenSvc' , 'Gaudi::MetaDataSvc' ] ApplicationMgr.ExtSvcCreates:True ApplicationMgr.Go:0 -ApplicationMgr.HistogramPersistency:ROOT +ApplicationMgr.HistogramPersistency:'ROOT' ApplicationMgr.InitializationLoopCheck:True -ApplicationMgr.JobOptionsPath: -ApplicationMgr.JobOptionsPostAction: -ApplicationMgr.JobOptionsPreAction: -ApplicationMgr.JobOptionsSvcType:JobOptionsSvc -ApplicationMgr.JobOptionsType:NONE -ApplicationMgr.MessageSvcType:MessageSvc +ApplicationMgr.JobOptionsPath:'' +ApplicationMgr.JobOptionsPostAction:'' +ApplicationMgr.JobOptionsPreAction:'' +ApplicationMgr.JobOptionsSvcType:'JobOptionsSvc' +ApplicationMgr.JobOptionsType:'NONE' +ApplicationMgr.MessageSvcType:'MessageSvc' ApplicationMgr.OutStream:[ ] -ApplicationMgr.OutStreamType:OutputStream +ApplicationMgr.OutStreamType:'OutputStream' ApplicationMgr.OutputLevel:3 ApplicationMgr.PluginDebugLevel:0 ApplicationMgr.PropertiesPrint:False ApplicationMgr.ReturnCode:0 -ApplicationMgr.Runable:AppMgrRunable +ApplicationMgr.Runable:'AppMgrRunable' ApplicationMgr.StalledEventMonitoring:False ApplicationMgr.StatusCodeCheck:False ApplicationMgr.StopOnSignal:False @@ -67,13 +67,13 @@ JobOptionsSvc.AuditRestart:False JobOptionsSvc.AuditServices:False JobOptionsSvc.AuditStart:False JobOptionsSvc.AuditStop:False -JobOptionsSvc.DUMPFILE: +JobOptionsSvc.DUMPFILE:'' JobOptionsSvc.OutputLevel:3 -JobOptionsSvc.PATH:../options/job.opts -JobOptionsSvc.PYTHONACTION: -JobOptionsSvc.PYTHONPARAMS: -JobOptionsSvc.SEARCHPATH:/workspace/build/GAUDI/GAUDI_HEAD/GaudiExamples/tests/qmtest:/workspace/build/GAUDI/GAUDI_HEAD/GaudiExamples/options -JobOptionsSvc.TYPE:NONE +JobOptionsSvc.PATH:'../options/job.opts' +JobOptionsSvc.PYTHONACTION:'' +JobOptionsSvc.PYTHONPARAMS:'' +JobOptionsSvc.SEARCHPATH:'/home/marco/Devel/workspace/Gaudi/GaudiExamples/tests/qmtest:/home/marco/Devel/workspace/Gaudi/GaudiExamples/options' +JobOptionsSvc.TYPE:'NONE' MessageSvc.AuditFinalize:False MessageSvc.AuditInitialize:False MessageSvc.AuditReinitialize:False @@ -81,7 +81,7 @@ MessageSvc.AuditRestart:False MessageSvc.AuditServices:False MessageSvc.AuditStart:False MessageSvc.AuditStop:False -MessageSvc.Format:% F%18W%S%7W%R%T %0W%M +MessageSvc.Format:'% F%18W%S%7W%R%T %0W%M' MessageSvc.OutputLevel:3 MessageSvc.alwaysColorCode:[ ] MessageSvc.alwaysLimit:0 @@ -106,7 +106,7 @@ MessageSvc.setVerbose:[ ] MessageSvc.setWarning:[ ] MessageSvc.showStats:False MessageSvc.statLevel:0 -MessageSvc.timeFormat:%Y-%m-%d %H:%M:%S,%f +MessageSvc.timeFormat:'%Y-%m-%d %H:%M:%S,%f' MessageSvc.tracedInactiveSources:[ ] MessageSvc.useColors:False MessageSvc.verboseColorCode:[ ] @@ -120,8 +120,8 @@ NTupleSvc.AuditRestart:False NTupleSvc.AuditServices:False NTupleSvc.AuditStart:False NTupleSvc.AuditStop:False -NTupleSvc.DataAccessName:DataAccess -NTupleSvc.DataFaultName:DataFault +NTupleSvc.DataAccessName:'DataAccess' +NTupleSvc.DataFaultName:'DataFault' NTupleSvc.EnableAccessHandler:False NTupleSvc.EnableFaultHandler:False NTupleSvc.ForceLeaves:False @@ -130,12 +130,12 @@ NTupleSvc.Input:[ ] NTupleSvc.Output:[ "MYLUN DATAFILE='TupleEx.root' OPT='NEW' TYP='ROOT'" ] NTupleSvc.OutputLevel:3 NTupleSvc.RootCLID:1 -NTupleSvc.RootName:/NTUPLES -RFileCnv.GlobalCompression:"LZMA:6" +NTupleSvc.RootName:'/NTUPLES' +RFileCnv.GlobalCompression:'LZMA:6' ToolSvc: -Tuple.NTupleLUN:"MYLUN" -Tuple2.NTupleLUN:"MYLUN" -Tuple3.NTupleLUN:"MYLUN" +Tuple.NTupleLUN:'MYLUN' +Tuple2.NTupleLUN:'MYLUN' +Tuple3.NTupleLUN:'MYLUN' ApplicationMgr INFO Application Manager Started successfully RFileCnv INFO opening Root file "TupleEx.root" for writing, CompressionLevel='LZMA:6' diff --git a/GaudiExamples/tests/qmtest/refs/Properties.ref b/GaudiExamples/tests/qmtest/refs/Properties.ref index 05e01a299e..ff70fa4a33 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties.ref @@ -78,7 +78,7 @@ PropertyAlg INFO DoublePairArray = [] PropertyAlg INFO PInt = 'PInt':100 PropertyAlg INFO Read handler called for property: 'PDouble':100.00000 PropertyAlg INFO PDouble = 'PDouble':100.00000 -PropertyAlg INFO PString = 'PString':hundred +PropertyAlg INFO PString = 'PString':'hundred' PropertyAlg INFO PBool = 'PBool':False PropertyAlg INFO PIntArray = 'PIntArray':[ ] PropertyAlg INFO PDoubleArray = 'PDoubleArray':[ ] @@ -106,7 +106,7 @@ PropertyAlg INFO DoublePairArray = [(1.1, 2.1), (2.3, 4.5), (5.6, 6.7) PropertyAlg INFO PInt = 'PInt':101 PropertyAlg INFO Read handler called for property: 'PDouble':10100000. PropertyAlg INFO PDouble = 'PDouble':10100000. -PropertyAlg INFO PString = 'PString':hundred one +PropertyAlg INFO PString = 'PString':'hundred one' PropertyAlg INFO PBool = 'PBool':True PropertyAlg INFO PIntArray = 'PIntArray':[ 1 , 2 , 3 , 5 ] PropertyAlg INFO PDoubleArray = 'PDoubleArray':[ 1.1000000 , 2.0000000 , 3.3000000 ] @@ -196,7 +196,7 @@ PropertyAlg INFO ================================================= PropertyProxy INFO Got property this.RInt = 101; PropertyProxy INFO Set property this.RInt = 1001; PropertyProxy INFO Got property this.RInt = 1001; -PropertyProxy INFO Got property this.String = This is set by the proxy; +PropertyProxy INFO Got property this.String = 'This is set by the proxy'; EventLoopMgr WARNING Unable to locate service "EventSelector" EventLoopMgr WARNING No events will be processed from external input. HistogramPersis...WARNING Histograms saving not required. diff --git a/GaudiExamples/tests/qmtest/refs/Properties2.ref b/GaudiExamples/tests/qmtest/refs/Properties2.ref index 237e2010a5..3ee558369b 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties2.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties2.ref @@ -80,7 +80,7 @@ PropertyAlg INFO DoublePairArray = [] PropertyAlg INFO PInt = 'PInt':100 PropertyAlg INFO Read handler called for property: 'PDouble':100.00000 PropertyAlg INFO PDouble = 'PDouble':100.00000 -PropertyAlg INFO PString = 'PString':hundred +PropertyAlg INFO PString = 'PString':'hundred' PropertyAlg INFO PBool = 'PBool':False PropertyAlg INFO PIntArray = 'PIntArray':[ ] PropertyAlg INFO PDoubleArray = 'PDoubleArray':[ ] @@ -108,7 +108,7 @@ PropertyAlg INFO DoublePairArray = [(1.1, 2.1), (2.3, 4.5), (5.6, 6.7) PropertyAlg INFO PInt = 'PInt':101 PropertyAlg INFO Read handler called for property: 'PDouble':10100000. PropertyAlg INFO PDouble = 'PDouble':10100000. -PropertyAlg INFO PString = 'PString':hundred one +PropertyAlg INFO PString = 'PString':'hundred one' PropertyAlg INFO PBool = 'PBool':True PropertyAlg INFO PIntArray = 'PIntArray':[ 1 , 2 , 3 , 5 ] PropertyAlg INFO PDoubleArray = 'PDoubleArray':[ 1.1000000 , 2.0000000 , 3.3000000 ] @@ -189,7 +189,7 @@ PropertyAlg INFO ================================================= PropertyProxy INFO Got property this.RInt = 101; PropertyProxy INFO Set property this.RInt = 1001; PropertyProxy INFO Got property this.RInt = 1001; -PropertyProxy INFO Got property this.String = This is set by the proxy; +PropertyProxy INFO Got property this.String = 'This is set by the proxy'; EventLoopMgr WARNING Unable to locate service "EventSelector" EventLoopMgr WARNING No events will be processed from external input. HistogramPersis...WARNING Histograms saving not required. diff --git a/GaudiExamples/tests/qmtest/refs/Properties_py.ref b/GaudiExamples/tests/qmtest/refs/Properties_py.ref index 1a1684c7f7..bab7cec0a1 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties_py.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties_py.ref @@ -40,7 +40,7 @@ PropertyAlg INFO DoublePairArray = [] PropertyAlg INFO PInt = 'PInt':100 PropertyAlg INFO Read handler called for property: 'PDouble':100.00000 PropertyAlg INFO PDouble = 'PDouble':100.00000 -PropertyAlg INFO PString = 'PString':hundred +PropertyAlg INFO PString = 'PString':'hundred' PropertyAlg INFO PBool = 'PBool':False PropertyAlg INFO PIntArray = 'PIntArray':[ ] PropertyAlg INFO PDoubleArray = 'PDoubleArray':[ ] @@ -68,7 +68,7 @@ PropertyAlg INFO DoublePairArray = [(1.1, 2.1), (2.3, 4.5), (5.6, 6.7) PropertyAlg INFO PInt = 'PInt':101 PropertyAlg INFO Read handler called for property: 'PDouble':10100000. PropertyAlg INFO PDouble = 'PDouble':10100000. -PropertyAlg INFO PString = 'PString':hundred one +PropertyAlg INFO PString = 'PString':'hundred one' PropertyAlg INFO PBool = 'PBool':True PropertyAlg INFO PIntArray = 'PIntArray':[ 1 , 2 , 3 , 5 ] PropertyAlg INFO PDoubleArray = 'PDoubleArray':[ 1.1000000 , 2.0000000 , 3.3000000 , 1.0000000e-20 , 1.0000000e+20 ] @@ -147,7 +147,7 @@ PropertyAlg INFO ================================================= PropertyProxy INFO Got property this.RInt = 101; PropertyProxy INFO Set property this.RInt = 1001; PropertyProxy INFO Got property this.RInt = 1001; -PropertyProxy INFO Got property this.String = hundred one; +PropertyProxy INFO Got property this.String = 'hundred one'; EventLoopMgr WARNING Unable to locate service "EventSelector" EventLoopMgr WARNING No events will be processed from external input. HistogramPersis...WARNING Histograms saving not required. diff --git a/GaudiExamples/tests/qmtest/refs/ROOT_IO/ExtCollWrite.ref b/GaudiExamples/tests/qmtest/refs/ROOT_IO/ExtCollWrite.ref index 834c440812..0a3a0c5e5a 100644 --- a/GaudiExamples/tests/qmtest/refs/ROOT_IO/ExtCollWrite.ref +++ b/GaudiExamples/tests/qmtest/refs/ROOT_IO/ExtCollWrite.ref @@ -35,31 +35,31 @@ EventAlgs INFO Member list: Gaudi::Examples::ExtendedEvtCol/Fill RndmGenSvc.Engine INFO Generator engine type:CLHEP::RanluxEngine RndmGenSvc.Engine INFO Current Seed:1234567 Luxury:3 RndmGenSvc INFO Using Random engine:HepRndm::Engine -Fill SUCCESS List of ALL properties of Gaudi::Examples::ExtendedEvtCol/Fill #properties = 65 -Fill SUCCESS Property ['Name': Value] = 'Tracks':MyTracks -Fill SUCCESS Property ['Name': Value] = 'EvtColDir':Fill -Fill SUCCESS Property ['Name': Value] = 'EvtColTopDir': -Fill SUCCESS Property ['Name': Value] = 'EvtColLUN':EXTEVT +Fill SUCCESS List of ALL properties of Gaudi::Examples::ExtendedEvtCol/Fill #properties = 66 +Fill SUCCESS Property ['Name': Value] = 'Tracks':'MyTracks' +Fill SUCCESS Property ['Name': Value] = 'EvtColDir':'Fill' +Fill SUCCESS Property ['Name': Value] = 'EvtColTopDir':'' +Fill SUCCESS Property ['Name': Value] = 'EvtColLUN':'EXTEVT' Fill SUCCESS Property ['Name': Value] = 'EvtColOffSet':0 Fill SUCCESS Property ['Name': Value] = 'EvtColSplitDir':False Fill SUCCESS Property ['Name': Value] = 'EvtColsPrint':True Fill SUCCESS Property ['Name': Value] = 'EvtColsProduce':True -Fill SUCCESS Property ['Name': Value] = 'NTupleDir':Fill -Fill SUCCESS Property ['Name': Value] = 'NTupleTopDir': -Fill SUCCESS Property ['Name': Value] = 'NTupleLUN':FILE1 +Fill SUCCESS Property ['Name': Value] = 'NTupleDir':'Fill' +Fill SUCCESS Property ['Name': Value] = 'NTupleTopDir':'' +Fill SUCCESS Property ['Name': Value] = 'NTupleLUN':'FILE1' Fill SUCCESS Property ['Name': Value] = 'NTupleOffSet':0 Fill SUCCESS Property ['Name': Value] = 'NTupleSplitDir':False Fill SUCCESS Property ['Name': Value] = 'NTuplePrint':False Fill SUCCESS Property ['Name': Value] = 'NTupleProduce':False Fill SUCCESS Property ['Name': Value] = 'AutoStringIDPurgeMap':{ '/' : '=SLASH=' } Fill SUCCESS Property ['Name': Value] = 'UseSequencialNumericAutoIDs':False -Fill SUCCESS Property ['Name': Value] = 'HeaderFor1DHistoTable':| Title | # | Mean | RMS | Skewness | Kurtosis | -Fill SUCCESS Property ['Name': Value] = 'ShortFormatFor1DHistoTable': | %1$-25.25s %2% -Fill SUCCESS Property ['Name': Value] = 'FormatFor1DHistoTable':| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g | +Fill SUCCESS Property ['Name': Value] = 'HeaderFor1DHistoTable':'| Title | # | Mean | RMS | Skewness | Kurtosis |' +Fill SUCCESS Property ['Name': Value] = 'ShortFormatFor1DHistoTable':' | %1$-25.25s %2%' +Fill SUCCESS Property ['Name': Value] = 'FormatFor1DHistoTable':'| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g |' Fill SUCCESS Property ['Name': Value] = 'MonitorHistograms':True Fill SUCCESS Property ['Name': Value] = 'FullDetail':False -Fill SUCCESS Property ['Name': Value] = 'HistoDir':Fill -Fill SUCCESS Property ['Name': Value] = 'HistoTopDir': +Fill SUCCESS Property ['Name': Value] = 'HistoDir':'Fill' +Fill SUCCESS Property ['Name': Value] = 'HistoTopDir':'' Fill SUCCESS Property ['Name': Value] = 'HistoOffSet':0 Fill SUCCESS Property ['Name': Value] = 'HistoSplitDir':False Fill SUCCESS Property ['Name': Value] = 'HistoCheckForNaN':True @@ -71,21 +71,22 @@ Fill SUCCESS Property ['Name': Value] = 'VetoObjects':[ ] Fill SUCCESS Property ['Name': Value] = 'StatEntityList':[ ] Fill SUCCESS Property ['Name': Value] = 'CounterList':[ '.*' ] Fill SUCCESS Property ['Name': Value] = 'UseEfficiencyRowFormat':True -Fill SUCCESS Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -Fill SUCCESS Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -Fill SUCCESS Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -Fill SUCCESS Property ['Name': Value] = 'RootInTES': -Fill SUCCESS Property ['Name': Value] = 'Context': +Fill SUCCESS Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +Fill SUCCESS Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +Fill SUCCESS Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +Fill SUCCESS Property ['Name': Value] = 'RootInTES':'' +Fill SUCCESS Property ['Name': Value] = 'Context':'' Fill SUCCESS Property ['Name': Value] = 'TypePrint':False Fill SUCCESS Property ['Name': Value] = 'PrintEmptyCounters':False Fill SUCCESS Property ['Name': Value] = 'StatPrint':True Fill SUCCESS Property ['Name': Value] = 'PropertiesPrint':True Fill SUCCESS Property ['Name': Value] = 'ErrorsPrint':True +Fill SUCCESS Property ['Name': Value] = 'FilterCircularDependencies':True Fill SUCCESS Property ['Name': Value] = 'IsIOBound':False Fill SUCCESS Property ['Name': Value] = 'NeededResources':[ ] Fill SUCCESS Property ['Name': Value] = 'Cardinality':1 Fill SUCCESS Property ['Name': Value] = 'RegisterForContextService':True -Fill SUCCESS Property ['Name': Value] = 'MonitorService':MonitorSvc +Fill SUCCESS Property ['Name': Value] = 'MonitorService':'MonitorSvc' Fill SUCCESS Property ['Name': Value] = 'Timeline':False Fill SUCCESS Property ['Name': Value] = 'AuditStop':False Fill SUCCESS Property ['Name': Value] = 'AuditStart':False diff --git a/GaudiExamples/tests/qmtest/refs/TBB/GaudiCommonTests.ref b/GaudiExamples/tests/qmtest/refs/TBB/GaudiCommonTests.ref index 365d07ae79..6a9f48a1f3 100644 --- a/GaudiExamples/tests/qmtest/refs/TBB/GaudiCommonTests.ref +++ b/GaudiExamples/tests/qmtest/refs/TBB/GaudiCommonTests.ref @@ -30,27 +30,28 @@ StatusCodeSvc INFO initialize Test1 DEBUG Property update for OutputLevel : new value = 2 Test1 DEBUG Initialize base class GaudiCommon Test1 DEBUG could not locate CounterSummarySvc, no counter summary will be made -Test1 DEBUG List of ALL properties of GaudiCommonTests/Test1 #properties = 35 +Test1 DEBUG List of ALL properties of GaudiCommonTests/Test1 #properties = 36 Test1 DEBUG Property ['Name': Value] = 'RequireObjects':[ ] Test1 DEBUG Property ['Name': Value] = 'VetoObjects':[ ] Test1 DEBUG Property ['Name': Value] = 'StatEntityList':[ ] Test1 DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] Test1 DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -Test1 DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -Test1 DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -Test1 DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -Test1 DEBUG Property ['Name': Value] = 'RootInTES': -Test1 DEBUG Property ['Name': Value] = 'Context': +Test1 DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +Test1 DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +Test1 DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +Test1 DEBUG Property ['Name': Value] = 'RootInTES':'' +Test1 DEBUG Property ['Name': Value] = 'Context':'' Test1 DEBUG Property ['Name': Value] = 'TypePrint':True Test1 DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False Test1 DEBUG Property ['Name': Value] = 'StatPrint':True Test1 DEBUG Property ['Name': Value] = 'PropertiesPrint':False Test1 DEBUG Property ['Name': Value] = 'ErrorsPrint':True +Test1 DEBUG Property ['Name': Value] = 'FilterCircularDependencies':True Test1 DEBUG Property ['Name': Value] = 'IsIOBound':False Test1 DEBUG Property ['Name': Value] = 'NeededResources':[ ] Test1 DEBUG Property ['Name': Value] = 'Cardinality':1 Test1 DEBUG Property ['Name': Value] = 'RegisterForContextService':True -Test1 DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +Test1 DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' Test1 DEBUG Property ['Name': Value] = 'Timeline':False Test1 DEBUG Property ['Name': Value] = 'AuditStop':False Test1 DEBUG Property ['Name': Value] = 'AuditStart':False @@ -73,27 +74,28 @@ Test1 DEBUG Data Deps for Test1 Test2 DEBUG Property update for OutputLevel : new value = 2 Test2 DEBUG Initialize base class GaudiCommon Test2 DEBUG could not locate CounterSummarySvc, no counter summary will be made -Test2 DEBUG List of ALL properties of GaudiCommonTests/Test2 #properties = 35 +Test2 DEBUG List of ALL properties of GaudiCommonTests/Test2 #properties = 36 Test2 DEBUG Property ['Name': Value] = 'RequireObjects':[ ] Test2 DEBUG Property ['Name': Value] = 'VetoObjects':[ ] Test2 DEBUG Property ['Name': Value] = 'StatEntityList':[ ] Test2 DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] Test2 DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -Test2 DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -Test2 DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -Test2 DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -Test2 DEBUG Property ['Name': Value] = 'RootInTES':microDST/ -Test2 DEBUG Property ['Name': Value] = 'Context': +Test2 DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +Test2 DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +Test2 DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +Test2 DEBUG Property ['Name': Value] = 'RootInTES':'microDST/' +Test2 DEBUG Property ['Name': Value] = 'Context':'' Test2 DEBUG Property ['Name': Value] = 'TypePrint':True Test2 DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False Test2 DEBUG Property ['Name': Value] = 'StatPrint':True Test2 DEBUG Property ['Name': Value] = 'PropertiesPrint':False Test2 DEBUG Property ['Name': Value] = 'ErrorsPrint':True +Test2 DEBUG Property ['Name': Value] = 'FilterCircularDependencies':True Test2 DEBUG Property ['Name': Value] = 'IsIOBound':False Test2 DEBUG Property ['Name': Value] = 'NeededResources':[ ] Test2 DEBUG Property ['Name': Value] = 'Cardinality':1 Test2 DEBUG Property ['Name': Value] = 'RegisterForContextService':True -Test2 DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +Test2 DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' Test2 DEBUG Property ['Name': Value] = 'Timeline':False Test2 DEBUG Property ['Name': Value] = 'AuditStop':False Test2 DEBUG Property ['Name': Value] = 'AuditStart':False diff --git a/GaudiExamples/tests/qmtest/refs/conditional_output/write.ref b/GaudiExamples/tests/qmtest/refs/conditional_output/write.ref index f95efbd9e9..733b4882fd 100644 --- a/GaudiExamples/tests/qmtest/refs/conditional_output/write.ref +++ b/GaudiExamples/tests/qmtest/refs/conditional_output/write.ref @@ -69,29 +69,30 @@ TimelineSvc DEBUG initialize DataCreator VERBOSE ServiceLocatorHelper::service: found service TimelineSvc DataCreator DEBUG Initialize base class GaudiCommon DataCreator DEBUG could not locate CounterSummarySvc, no counter summary will be made -DataCreator DEBUG List of ALL properties of GaudiTesting::PutDataObjectAlg/DataCreator #properties = 37 -DataCreator DEBUG Property ['Name': Value] = 'DataSvc':EventDataSvc +DataCreator DEBUG List of ALL properties of GaudiTesting::PutDataObjectAlg/DataCreator #properties = 38 +DataCreator DEBUG Property ['Name': Value] = 'DataSvc':'EventDataSvc' DataCreator DEBUG Property ['Name': Value] = 'Paths':[ 'A' , 'B' , 'C' , 'D' ] DataCreator DEBUG Property ['Name': Value] = 'RequireObjects':[ ] DataCreator DEBUG Property ['Name': Value] = 'VetoObjects':[ ] DataCreator DEBUG Property ['Name': Value] = 'StatEntityList':[ ] DataCreator DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] DataCreator DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -DataCreator DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -DataCreator DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -DataCreator DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -DataCreator DEBUG Property ['Name': Value] = 'RootInTES': -DataCreator DEBUG Property ['Name': Value] = 'Context': +DataCreator DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +DataCreator DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +DataCreator DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +DataCreator DEBUG Property ['Name': Value] = 'RootInTES':'' +DataCreator DEBUG Property ['Name': Value] = 'Context':'' DataCreator DEBUG Property ['Name': Value] = 'TypePrint':True DataCreator DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False DataCreator DEBUG Property ['Name': Value] = 'StatPrint':True DataCreator DEBUG Property ['Name': Value] = 'PropertiesPrint':False DataCreator DEBUG Property ['Name': Value] = 'ErrorsPrint':True +DataCreator DEBUG Property ['Name': Value] = 'FilterCircularDependencies':True DataCreator DEBUG Property ['Name': Value] = 'IsIOBound':False DataCreator DEBUG Property ['Name': Value] = 'NeededResources':[ ] DataCreator DEBUG Property ['Name': Value] = 'Cardinality':1 DataCreator DEBUG Property ['Name': Value] = 'RegisterForContextService':True -DataCreator DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +DataCreator DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' DataCreator DEBUG Property ['Name': Value] = 'Timeline':False DataCreator DEBUG Property ['Name': Value] = 'AuditStop':False DataCreator DEBUG Property ['Name': Value] = 'AuditStart':False @@ -121,27 +122,28 @@ OddEvents VERBOSE ServiceLocatorHelper::service: found service EventData OddEvents VERBOSE ServiceLocatorHelper::service: found service TimelineSvc OddEvents DEBUG Initialize base class GaudiCommon OddEvents DEBUG could not locate CounterSummarySvc, no counter summary will be made -OddEvents DEBUG List of ALL properties of GaudiTesting::OddEventsFilter/OddEvents #properties = 35 +OddEvents DEBUG List of ALL properties of GaudiTesting::OddEventsFilter/OddEvents #properties = 36 OddEvents DEBUG Property ['Name': Value] = 'RequireObjects':[ ] OddEvents DEBUG Property ['Name': Value] = 'VetoObjects':[ ] OddEvents DEBUG Property ['Name': Value] = 'StatEntityList':[ ] OddEvents DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] OddEvents DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -OddEvents DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -OddEvents DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -OddEvents DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -OddEvents DEBUG Property ['Name': Value] = 'RootInTES': -OddEvents DEBUG Property ['Name': Value] = 'Context': +OddEvents DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +OddEvents DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +OddEvents DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +OddEvents DEBUG Property ['Name': Value] = 'RootInTES':'' +OddEvents DEBUG Property ['Name': Value] = 'Context':'' OddEvents DEBUG Property ['Name': Value] = 'TypePrint':True OddEvents DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False OddEvents DEBUG Property ['Name': Value] = 'StatPrint':True OddEvents DEBUG Property ['Name': Value] = 'PropertiesPrint':False OddEvents DEBUG Property ['Name': Value] = 'ErrorsPrint':True +OddEvents DEBUG Property ['Name': Value] = 'FilterCircularDependencies':True OddEvents DEBUG Property ['Name': Value] = 'IsIOBound':False OddEvents DEBUG Property ['Name': Value] = 'NeededResources':[ ] OddEvents DEBUG Property ['Name': Value] = 'Cardinality':1 OddEvents DEBUG Property ['Name': Value] = 'RegisterForContextService':True -OddEvents DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +OddEvents DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' OddEvents DEBUG Property ['Name': Value] = 'Timeline':False OddEvents DEBUG Property ['Name': Value] = 'AuditStop':False OddEvents DEBUG Property ['Name': Value] = 'AuditStart':False @@ -169,27 +171,28 @@ EvenEvents VERBOSE ServiceLocatorHelper::service: found service EventData EvenEvents VERBOSE ServiceLocatorHelper::service: found service TimelineSvc EvenEvents DEBUG Initialize base class GaudiCommon EvenEvents DEBUG could not locate CounterSummarySvc, no counter summary will be made -EvenEvents DEBUG List of ALL properties of GaudiTesting::EvenEventsFilter/EvenEvents #properties = 35 +EvenEvents DEBUG List of ALL properties of GaudiTesting::EvenEventsFilter/EvenEvents #properties = 36 EvenEvents DEBUG Property ['Name': Value] = 'RequireObjects':[ ] EvenEvents DEBUG Property ['Name': Value] = 'VetoObjects':[ ] EvenEvents DEBUG Property ['Name': Value] = 'StatEntityList':[ ] EvenEvents DEBUG Property ['Name': Value] = 'CounterList':[ '.*' ] EvenEvents DEBUG Property ['Name': Value] = 'UseEfficiencyRowFormat':True -EvenEvents DEBUG Property ['Name': Value] = 'EfficiencyRowFormat': |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- | -EvenEvents DEBUG Property ['Name': Value] = 'RegularRowFormat': | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| | -EvenEvents DEBUG Property ['Name': Value] = 'StatTableHeader': | Counter | # | sum | mean/eff^* | rms/err^* | min | max | -EvenEvents DEBUG Property ['Name': Value] = 'RootInTES': -EvenEvents DEBUG Property ['Name': Value] = 'Context': +EvenEvents DEBUG Property ['Name': Value] = 'EfficiencyRowFormat':' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +EvenEvents DEBUG Property ['Name': Value] = 'RegularRowFormat':' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +EvenEvents DEBUG Property ['Name': Value] = 'StatTableHeader':' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +EvenEvents DEBUG Property ['Name': Value] = 'RootInTES':'' +EvenEvents DEBUG Property ['Name': Value] = 'Context':'' EvenEvents DEBUG Property ['Name': Value] = 'TypePrint':True EvenEvents DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False EvenEvents DEBUG Property ['Name': Value] = 'StatPrint':True EvenEvents DEBUG Property ['Name': Value] = 'PropertiesPrint':False EvenEvents DEBUG Property ['Name': Value] = 'ErrorsPrint':True +EvenEvents DEBUG Property ['Name': Value] = 'FilterCircularDependencies':True EvenEvents DEBUG Property ['Name': Value] = 'IsIOBound':False EvenEvents DEBUG Property ['Name': Value] = 'NeededResources':[ ] EvenEvents DEBUG Property ['Name': Value] = 'Cardinality':1 EvenEvents DEBUG Property ['Name': Value] = 'RegisterForContextService':True -EvenEvents DEBUG Property ['Name': Value] = 'MonitorService':MonitorSvc +EvenEvents DEBUG Property ['Name': Value] = 'MonitorService':'MonitorSvc' EvenEvents DEBUG Property ['Name': Value] = 'Timeline':False EvenEvents DEBUG Property ['Name': Value] = 'AuditStop':False EvenEvents DEBUG Property ['Name': Value] = 'AuditStart':False diff --git a/GaudiKernel/Gaudi/Parsers/Grammars.h b/GaudiKernel/Gaudi/Parsers/Grammars.h index c4c104c5f6..5a82c025a6 100644 --- a/GaudiKernel/Gaudi/Parsers/Grammars.h +++ b/GaudiKernel/Gaudi/Parsers/Grammars.h @@ -97,6 +97,7 @@ namespace Gaudi str = qi::lexeme[begin_quote[qi::_a = qi::_1] > *( ( enc::char_( '\\' ) >> quote( qi::_a ) )[qi::_val += qi::_a] | + ( enc::char_( '\\' ) >> enc::char_( '\\' ) )[qi::_val += '\\'] | ( enc::char_[qi::_val += qi::_1] - quote( qi::_a ) ) ) > quote( qi::_a )]; } //------------------------------------------------------------------------------ diff --git a/GaudiKernel/GaudiKernel/Property.h b/GaudiKernel/GaudiKernel/Property.h index f7c543de5e..5fd480d076 100644 --- a/GaudiKernel/GaudiKernel/Property.h +++ b/GaudiKernel/GaudiKernel/Property.h @@ -195,12 +195,6 @@ namespace Gaudi } } }; - // Specialization of toString for strings (identity function) - template <> - inline std::string DefaultStringConverterImpl::toString( const std::string& v ) - { - return v; - } // This class provides a default implementation of StringConverter based // on the overloadable parse() and toStream() global Gaudi methods. diff --git a/GaudiKernel/src/Lib/StringKey.cpp b/GaudiKernel/src/Lib/StringKey.cpp index 0c296c14ea..3c4cdbf2d2 100644 --- a/GaudiKernel/src/Lib/StringKey.cpp +++ b/GaudiKernel/src/Lib/StringKey.cpp @@ -34,7 +34,7 @@ std::string Gaudi::StringKey::toString() const { return Gaudi::Utils::toString( // ============================================================================ // the representation of the object // ============================================================================ -std::string Gaudi::StringKey::__str__() const { return toString(); } +std::string Gaudi::StringKey::__str__() const { return m_str; } // ============================================================================ // the representation of the object // ============================================================================ diff --git a/GaudiKernel/src/Util/genconf.cpp b/GaudiKernel/src/Util/genconf.cpp index 3a6092d1cd..ba436050c9 100644 --- a/GaudiKernel/src/Util/genconf.cpp +++ b/GaudiKernel/src/Util/genconf.cpp @@ -767,7 +767,7 @@ void configGenerator::pythonizeValue( const PropertyBase* p, string& pvalue, str } ptype = "float"; } else if ( ti == typeIndex() ) { - pvalue = "'" + cvalue + "'"; + pvalue = cvalue; ptype = "str"; } else if ( ti == typeIndex() ) { const GaudiHandleProperty& hdl = dynamic_cast( *p ); diff --git a/GaudiKernel/tests/src/test_Property.cpp b/GaudiKernel/tests/src/test_Property.cpp index eb1655e584..477fc9db0b 100644 --- a/GaudiKernel/tests/src/test_Property.cpp +++ b/GaudiKernel/tests/src/test_Property.cpp @@ -82,9 +82,9 @@ BOOST_AUTO_TEST_CASE( string_conversion ) BOOST_CHECK( p1.value() == "" ); p1 = "abc"; BOOST_CHECK( p1.value() == "abc" ); - BOOST_CHECK( p1.fromString( "xyz" ) ); + BOOST_CHECK( p1.fromString( "'xyz'" ) ); BOOST_CHECK( p1.value() == "xyz" ); - BOOST_CHECK( p1.toString() == "xyz" ); + BOOST_CHECK( p1.toString() == "'xyz'" ); } { Gaudi::Property p2{"p2", 10}; @@ -104,33 +104,6 @@ BOOST_AUTO_TEST_CASE( string_conversion ) BOOST_CHECK( p3.value() == true ); BOOST_CHECK( p3.toString() == "True" ); } - { - Gaudi::Property dst{0}; - Gaudi::Property src{"321"}; - BOOST_CHECK( dst.value() == 0 ); - BOOST_CHECK( dst.assign( src ) ); - BOOST_CHECK( dst.value() == 321 ); - dst = 100; - BOOST_CHECK( dst.value() == 100 ); - BOOST_CHECK( dst.load( src ) ); - BOOST_CHECK( src.value() == "100" ); - } - { - // string property as from options - Gaudi::Property opt{"\"NONE\""}; - Gaudi::Property p{}; - BOOST_CHECK( opt.load( p ) ); - BOOST_CHECK( p.value() == "NONE" ); - } - { - // string property as from options - Gaudi::Property opt{"\"NONE\""}; - std::string dst; - Gaudi::Property p{"test", dst}; - BOOST_CHECK( opt.load( p ) ); - BOOST_CHECK( p.value() == "NONE" ); - BOOST_CHECK( dst == "NONE" ); - } } template diff --git a/GaudiPolicy/python/GaudiTesting/BaseTest.py b/GaudiPolicy/python/GaudiTesting/BaseTest.py index 64aa8105b7..b0acf7071d 100644 --- a/GaudiPolicy/python/GaudiTesting/BaseTest.py +++ b/GaudiPolicy/python/GaudiTesting/BaseTest.py @@ -872,6 +872,7 @@ for w, o, r in [ (None, r"^(.*(DEBUG|SUCCESS) List of ALL properties of .*#properties = )\d+", r"\1NN"), ('ApplicationMgr', r'(declareMultiSvcType|addMultiSvc): ', ''), + ("Property", r"( = '[^']+':)'(.*)'", r'\1\2'), ]: # [ ("TIMER.TIMER","[0-9]+[0-9.]*", "") ] normalizeExamples += RegexpReplacer(o, r, w) -- GitLab From 00c5f2fee5d02ebde07cd20e0adb134a188cdec9 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Sat, 30 Dec 2017 11:53:17 +0100 Subject: [PATCH 12/53] Add Doxygen comments. --- .../src/JobOptionsSvc/JobOptionsSvc.h | 5 +++- GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h index b3386aa0f8..8c5b0648f1 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h @@ -33,9 +33,12 @@ private: mutable std::map> m_old_iface_compat; mutable std::map m_old_iface_compat_2; + /// Find an option key in the options storage using case insensitive comparison. + /// If the found key does not match the case of the requested one, a warning is printed. StorageType::const_iterator find( const std::string& key, bool warn ) const; protected: + /// @{ void set( const std::string& key, const std::string& value ) override { m_options[key] = value; } std::string get( const std::string& key, const std::string& default_ = {} ) const override { @@ -61,7 +64,7 @@ protected: std::for_each( begin( m_options ), end( m_options ), [&v]( const auto& item ) { v.emplace_back( item ); } ); return v; } - + /// @} public: // Constructor JobOptionsSvc( const std::string& name, ISvcLocator* svc ); diff --git a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h index 8b9f60a979..ba62f9f07a 100644 --- a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h +++ b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h @@ -8,14 +8,41 @@ namespace Gaudi { namespace Interfaces { + /** Interface for a component that manages application configuration options. + + Options are to be recorded as pairs of strings: option id and value. + The value must be the string representation of the a value, as understood by + `Gaudi::Property::fromString()`. + + For example, if an Algorithm defines two properties as in + \code + class MyAlg: public Algorithm { + Gaudi::Property m_hname{this, "HistoName", "none"}; + Gaudi::Property m_threshold{this, "Threshold", 1.0}; + }; + \endcode + + The IOptionsSvc instance should be populated with something like + \code + auto& optsSvc = sericeLocator()->getOptsSvc(); + optsSvc.set("AlgInstanceName.HistoName", "'my_histogram'"); + optsSvc.set("AlgInstanceName.Threshold", "2.345"); + \endcode + */ class IOptionsSvc { public: + /// Set the value of an option, overriding the old value, if any. virtual void set( const std::string& key, const std::string& value ) = 0; + /// Get the value of an options, returning the specified _default_ value if not found. virtual std::string get( const std::string& key, const std::string& default_ = {} ) const = 0; + /// Get the value of an options, removing it from the storage, returning the specified _default_ value if not + /// found. virtual std::string pop( const std::string& key, const std::string& default_ = {} ) = 0; + /// Test if an option key is availble in the catalog. virtual bool has( const std::string& key ) const = 0; + /// Return all known options with their values. virtual std::vector> items() const = 0; protected: -- GitLab From a9eb4e184fc176aaa44e35b22b8745f24277a127 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Mon, 5 Mar 2018 12:40:20 +0100 Subject: [PATCH 13/53] Fixed use of property in ViewTester --- GaudiHive/src/ViewTester.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GaudiHive/src/ViewTester.cpp b/GaudiHive/src/ViewTester.cpp index 447ed0a308..af3a4e8f59 100644 --- a/GaudiHive/src/ViewTester.cpp +++ b/GaudiHive/src/ViewTester.cpp @@ -81,11 +81,11 @@ StatusCode ViewTester::execute() // the execution of the algorithm StatusCode sc = scheduler->scheduleEventView( &context, m_viewNodeName, std::move( viewContext ) ); if ( sc.isSuccess() ) - info() << "Attached view " << viewName << " to node " << m_viewNodeName.toString() << " for " << context + info() << "Attached view " << viewName << " to node " << m_viewNodeName.value() << " for " << context << endmsg; else - error() << "Unable to attach view " << viewName << " to node " << m_viewNodeName.toString() << " for " - << context << endmsg; + error() << "Unable to attach view " << viewName << " to node " << m_viewNodeName.value() << " for " << context + << endmsg; } } else { // Disable the view node if there are no views -- GitLab From 0ede4fa41be147b37f5e99962633499efb23bda6 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Mon, 5 Mar 2018 17:08:30 +0100 Subject: [PATCH 14/53] Make new PropertyHolder methods public --- GaudiKernel/GaudiKernel/PropertyHolder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GaudiKernel/GaudiKernel/PropertyHolder.h b/GaudiKernel/GaudiKernel/PropertyHolder.h index aaa069f5c8..2c3abfb218 100644 --- a/GaudiKernel/GaudiKernel/PropertyHolder.h +++ b/GaudiKernel/GaudiKernel/PropertyHolder.h @@ -285,7 +285,7 @@ public: } ); } // ========================================================================== -protected: + /// \fixme property and setPropertiesFrom should be protected // get local or remote property by name Gaudi::Details::PropertyBase* property( const std::string& name ) const { -- GitLab From 824ff71da97ac61d02a42765912155a54044fd1c Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Mon, 5 Mar 2018 17:10:00 +0100 Subject: [PATCH 15/53] Add macro to detect presence of Gaudi::Interfaces::IOptionsSvc --- GaudiKernel/GaudiKernel/ISvcLocator.h | 1 + 1 file changed, 1 insertion(+) diff --git a/GaudiKernel/GaudiKernel/ISvcLocator.h b/GaudiKernel/GaudiKernel/ISvcLocator.h index a20a8a5f8a..0bb0fd6959 100644 --- a/GaudiKernel/GaudiKernel/ISvcLocator.h +++ b/GaudiKernel/GaudiKernel/ISvcLocator.h @@ -20,6 +20,7 @@ namespace Gaudi class IOptionsSvc; } } +#define GAUDI_HAS_IOPTIONS_SVC /** @class ISvcLocator ISvcLocator.h GaudiKernel/ISvcLocator.h The ISvcLocator is the interface implemented by the Service Factory in the -- GitLab From 14df877909bafe4fdc8caeee3a4dae695a3f6e52 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Tue, 11 Sep 2018 11:34:06 +0200 Subject: [PATCH 16/53] Fix small typo in THistSvc --- GaudiExamples/tests/qmtest/refs/THistRead.ref | 2 +- GaudiExamples/tests/qmtest/refs/THistRead.ref.dbg | 2 +- GaudiExamples/tests/qmtest/refs/THistWrite.ref | 2 +- GaudiExamples/tests/qmtest/refs/THistWrite.ref.dbg | 2 +- GaudiSvc/src/THistSvc/THistSvc.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/GaudiExamples/tests/qmtest/refs/THistRead.ref b/GaudiExamples/tests/qmtest/refs/THistRead.ref index 2c4e8fff0a..a22ff610ed 100644 --- a/GaudiExamples/tests/qmtest/refs/THistRead.ref +++ b/GaudiExamples/tests/qmtest/refs/THistRead.ref @@ -32,7 +32,7 @@ ApplicationMgr INFO Application Manager Configured successfully THistSvc DEBUG Property update for OutputLevel : new value = 2 THistSvc DEBUG Delaying connection of Input Files until Initialize. now in OFFLINE THistSvc DEBUG Service base class initialized successfully -THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED +THistSvc DEBUG Delaying connection of Output Files until Initialize. now in CONFIGURED THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED THistSvc DEBUG got the FileMgr THistSvc DEBUG Now connecting of Input Files diff --git a/GaudiExamples/tests/qmtest/refs/THistRead.ref.dbg b/GaudiExamples/tests/qmtest/refs/THistRead.ref.dbg index 70cad8994a..9fb934d8a6 100644 --- a/GaudiExamples/tests/qmtest/refs/THistRead.ref.dbg +++ b/GaudiExamples/tests/qmtest/refs/THistRead.ref.dbg @@ -31,7 +31,7 @@ ApplicationMgr VERBOSE addMultiSvc: added service EventLoopMgr/EventLoopMgr[ ApplicationMgr INFO Application Manager Configured successfully THistSvc DEBUG Property update for OutputLevel : new value = 2 THistSvc DEBUG Service base class initialized successfully -THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED +THistSvc DEBUG Delaying connection of Output Files until Initialize. now in CONFIGURED THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED THistSvc DEBUG got the FileMgr THistSvc DEBUG Now connecting of Input Files diff --git a/GaudiExamples/tests/qmtest/refs/THistWrite.ref b/GaudiExamples/tests/qmtest/refs/THistWrite.ref index 3882b16c83..fe48e77832 100644 --- a/GaudiExamples/tests/qmtest/refs/THistWrite.ref +++ b/GaudiExamples/tests/qmtest/refs/THistWrite.ref @@ -32,7 +32,7 @@ ApplicationMgr INFO Application Manager Configured successfully THistSvc DEBUG Property update for OutputLevel : new value = 2 THistSvc DEBUG Delaying connection of Input Files until Initialize. now in OFFLINE THistSvc DEBUG Service base class initialized successfully -THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED +THistSvc DEBUG Delaying connection of Output Files until Initialize. now in CONFIGURED THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED THistSvc DEBUG got the FileMgr THistSvc DEBUG Opening TFile "tuple2.rt" stream: "upd" mode: "A" comp level: 1 diff --git a/GaudiExamples/tests/qmtest/refs/THistWrite.ref.dbg b/GaudiExamples/tests/qmtest/refs/THistWrite.ref.dbg index b8b23e6a9a..dc894d2675 100644 --- a/GaudiExamples/tests/qmtest/refs/THistWrite.ref.dbg +++ b/GaudiExamples/tests/qmtest/refs/THistWrite.ref.dbg @@ -31,7 +31,7 @@ ApplicationMgr VERBOSE added service EventLoopMgr/EventLoopMgr ApplicationMgr INFO Application Manager Configured successfully THistSvc DEBUG Property update for OutputLevel : new value = 2 THistSvc DEBUG Service base class initialized successfully -THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED +THistSvc DEBUG Delaying connection of Output Files until Initialize. now in CONFIGURED THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED THistSvc DEBUG got the FileMgr THistSvc DEBUG Opening TFile "tuple2.rt" stream: "upd" mode: "A" comp level: 1 diff --git a/GaudiSvc/src/THistSvc/THistSvc.cpp b/GaudiSvc/src/THistSvc/THistSvc.cpp index c29821dbe3..8e99fe8a03 100644 --- a/GaudiSvc/src/THistSvc/THistSvc.cpp +++ b/GaudiSvc/src/THistSvc/THistSvc.cpp @@ -1779,7 +1779,7 @@ void THistSvc::setupOutputFile( Gaudi::Details::PropertyBase& /*m_outputfile*/ ) { if ( FSMState() < Gaudi::StateMachine::CONFIGURED || !m_okToConnect ) { - debug() << "Delaying connection of Input Files until Initialize" + debug() << "Delaying connection of Output Files until Initialize" << ". now in " << FSMState() << endmsg; m_delayConnect = true; } else { -- GitLab From d91c093f39b2e6999d56ebc7f5612820de42e5ba Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Mon, 10 Sep 2018 23:22:47 +0200 Subject: [PATCH 17/53] Bind properties to entries in options service --- .../src/ApplicationMgr/ApplicationMgr.cpp | 6 +- GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp | 2 +- .../src/JobOptionsSvc/JobOptionsSvc.h | 41 +- GaudiExamples/src/Properties/PropertyAlg.cpp | 12 +- .../gaudiexamples.qms/properties.qms/all.qmt | 5 + .../gaudiexamples.qms/properties.qms/all2.qmt | 5 + .../properties.qms/all_py.qmt | 5 + .../tests/qmtest/refs/MetaDataSvc.ref | 377 +++++++++++++++++- .../tests/qmtest/refs/Properties.ref | 299 ++++++++++++-- .../tests/qmtest/refs/Properties2.ref | 298 ++++++++++++-- .../tests/qmtest/refs/Properties_py.ref | 285 +++++++++++-- .../tests/qmtest/refs/THistRead.ref.dbg | 1 + .../tests/qmtest/refs/THistWrite.ref | 2 +- .../tests/qmtest/refs/THistWrite.ref.dbg | 1 + GaudiKernel/CMakeLists.txt | 3 + GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h | 6 + GaudiKernel/GaudiKernel/AlgTool.h | 2 +- GaudiKernel/GaudiKernel/Algorithm.h | 2 +- GaudiKernel/GaudiKernel/Auditor.h | 2 +- GaudiKernel/GaudiKernel/Property.h | 91 ++++- GaudiKernel/GaudiKernel/PropertyHolder.h | 12 +- GaudiKernel/GaudiKernel/Service.h | 2 +- GaudiKernel/src/Lib/Algorithm.cpp | 2 +- GaudiKernel/src/Lib/Auditor.cpp | 2 +- GaudiKernel/src/Lib/Service.cpp | 2 +- .../tests/src/test_WeekPropertyRef.cpp | 133 ++++++ GaudiPython/python/GaudiPython/Bindings.py | 33 +- GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp | 69 ---- 28 files changed, 1452 insertions(+), 248 deletions(-) create mode 100644 GaudiKernel/tests/src/test_WeekPropertyRef.cpp diff --git a/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp b/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp index 5df568cf36..55ab678a62 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp @@ -265,7 +265,7 @@ StatusCode ApplicationMgr::configure() MsgStream log( m_messageSvc, name() ); // Get my own options using the Job options service if ( log.level() <= MSG::DEBUG ) log << MSG::DEBUG << "Getting my own properties" << endmsg; - setPropertiesFrom( serviceLocator()->getOptsSvc() ); + bindPropertiesTo( serviceLocator()->getOptsSvc() ); } // Make sure that the OutputLevel is in sync @@ -1109,7 +1109,9 @@ void ApplicationMgr::pluginDebugPropertyHandler( Gaudi::Details::PropertyBase& ) { // Setup debug level for the plugin system MsgStream log( m_messageSvc, name() ); - log << MSG::INFO << "Updating Gaudi::PluginService::SetDebug(level) to level=" << m_pluginDebugLevel << endmsg; + if ( m_pluginDebugLevel.value() ) + log << MSG::INFO << "Updating Gaudi::PluginService::SetDebug(level) to level=" << m_pluginDebugLevel.value() + << endmsg; Gaudi::PluginService::SetDebug( m_pluginDebugLevel ); } diff --git a/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp b/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp index 881a191dd3..b1cffe9f77 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp @@ -502,7 +502,7 @@ StatusCode ToolSvc::create( const std::string& tooltype, const std::string& tool // to downcast IAlgTool to AlgTool in order to set the properties via the JobOptions // service AlgTool* mytool = dynamic_cast( toolguard.get() ); - if ( mytool ) mytool->setPropertiesFrom( serviceLocator()->getOptsSvc() ); + if ( mytool ) mytool->bindPropertiesTo( serviceLocator()->getOptsSvc() ); // Initialize the Tool StatusCode sc( StatusCode::FAILURE, true ); diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h index 8c5b0648f1..9781e41b9a 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h @@ -27,9 +27,10 @@ public: typedef std::vector PropertiesT; private: - using StorageType = std::map; + using StorageType = std::map; StorageType m_options; + mutable std::map> m_old_iface_compat; mutable std::map m_old_iface_compat_2; @@ -39,11 +40,25 @@ private: protected: /// @{ - void set( const std::string& key, const std::string& value ) override { m_options[key] = value; } + void set( const std::string& key, const std::string& value ) override + { + auto item = find( key, true ); + if ( item != m_options.end() && key != item->first ) { + if ( !item->second.isBound() ) { // do not remove references to properties + m_options.erase( item ); // Storage is case insensitive, and I want to use the latest version of the case + item = m_options.end(); + } + } + if ( item == m_options.end() ) { + m_options.emplace( key, value ); + } else { + m_options.find( item->first )->second = value; + } + } std::string get( const std::string& key, const std::string& default_ = {} ) const override { auto item = find( key, true ); - return item != m_options.end() ? item->second : default_; + return item != m_options.end() ? std::string{item->second} : default_; } std::string pop( const std::string& key, const std::string& default_ = {} ) override { @@ -51,8 +66,8 @@ protected: auto item = find( key, true ); if ( item != m_options.end() ) { - m_options.erase( item ); result = std::move( item->second ); + m_options.erase( item ); } return result; } @@ -64,7 +79,25 @@ protected: std::for_each( begin( m_options ), end( m_options ), [&v]( const auto& item ) { v.emplace_back( item ); } ); return v; } + void bind( const std::string& prefix, Gaudi::Details::PropertyBase* property ) override + { + const auto key = prefix + '.' + property->name(); + + auto item = find( key, true ); + if ( item != m_options.end() && key != item->first ) { + // Storage is case insensitive, and I want to use the what the property dictates + auto new_item = m_options.emplace( key, std::move( m_options.find( item->first )->second ) ); + m_options.erase( item ); + item = new_item.first; + } + if ( item == m_options.end() ) { + m_options.emplace( key, *property ); + } else { + m_options.find( key )->second = *property; + } + } /// @} + public: // Constructor JobOptionsSvc( const std::string& name, ISvcLocator* svc ); diff --git a/GaudiExamples/src/Properties/PropertyAlg.cpp b/GaudiExamples/src/Properties/PropertyAlg.cpp index 23c44c85b7..412e8aaefd 100644 --- a/GaudiExamples/src/Properties/PropertyAlg.cpp +++ b/GaudiExamples/src/Properties/PropertyAlg.cpp @@ -253,13 +253,13 @@ StatusCode PropertyAlg::initialize() info() << "=================================================" << endmsg; // Change an option of my own.... - opts.set( name() + '.' + "PInt", "155" ); - setPropertiesFrom( opts ); - // trying to use an invalid value - opts.set( name() + '.' + "DoubleArray", "{\"12.12\", \"13.13\"}" ); - info() << "Changed property DoubleArray in catalogue" << endmsg; + opts.set( name() + '.' + "PInt", "154" ); + info() << "PInt= " << p_int << " [should be 154]" << endmsg; + try { - setPropertiesFrom( opts ); + info() << "Try to assign invalid value to DoubleArray" << endmsg; + // trying to use an invalid value + opts.set( name() + '.' + "DoubleArray", "{\"12.12\", \"13.13\"}" ); } catch ( const std::invalid_argument& exc ) { error() << "got invalid_argument exception: " << exc.what() << endmsg; } diff --git a/GaudiExamples/tests/qmtest/gaudiexamples.qms/properties.qms/all.qmt b/GaudiExamples/tests/qmtest/gaudiexamples.qms/properties.qms/all.qmt index 022a14e632..08751fb4c0 100644 --- a/GaudiExamples/tests/qmtest/gaudiexamples.qms/properties.qms/all.qmt +++ b/GaudiExamples/tests/qmtest/gaudiexamples.qms/properties.qms/all.qmt @@ -3,4 +3,9 @@ $GAUDIEXAMPLESROOT/options/Properties.opts true refs/Properties.ref + +preprocessor = (normalizeExamples + + RegexpReplacer(r"(JobOptionsSvc\.(SEARCH)?PATH|ApplicationMgr\.JobOptionsPath): '.*'", r"\1: '...'")) +validateWithReference(preproc=preprocessor) + diff --git a/GaudiExamples/tests/qmtest/gaudiexamples.qms/properties.qms/all2.qmt b/GaudiExamples/tests/qmtest/gaudiexamples.qms/properties.qms/all2.qmt index 1c7f6e336d..c1ad8e502e 100644 --- a/GaudiExamples/tests/qmtest/gaudiexamples.qms/properties.qms/all2.qmt +++ b/GaudiExamples/tests/qmtest/gaudiexamples.qms/properties.qms/all2.qmt @@ -4,4 +4,9 @@ $GAUDIEXAMPLESROOT/options/Properties.opts true refs/Properties2.ref + +preprocessor = (normalizeExamples + + RegexpReplacer(r"(JobOptionsSvc\.(SEARCH)?PATH|ApplicationMgr\.JobOptionsPath): '.*'", r"\1: '...'")) +validateWithReference(preproc=preprocessor) + diff --git a/GaudiExamples/tests/qmtest/gaudiexamples.qms/properties.qms/all_py.qmt b/GaudiExamples/tests/qmtest/gaudiexamples.qms/properties.qms/all_py.qmt index 93ce1e3ec4..223f4175e0 100644 --- a/GaudiExamples/tests/qmtest/gaudiexamples.qms/properties.qms/all_py.qmt +++ b/GaudiExamples/tests/qmtest/gaudiexamples.qms/properties.qms/all_py.qmt @@ -4,4 +4,9 @@ $GAUDIEXAMPLESROOT/options/Properties.py true refs/Properties_py.ref + +preprocessor = (normalizeExamples + + RegexpReplacer(r"(JobOptionsSvc\.(SEARCH)?PATH|ApplicationMgr\.JobOptionsPath): '.*'", r"\1: '...'")) +validateWithReference(preproc=preprocessor) + diff --git a/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref b/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref index 124e3fff6c..7af9b68c94 100644 --- a/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref +++ b/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref @@ -1,9 +1,10 @@ -# --> Including file '/workspace/build/GAUDI/GAUDI_HEAD/GaudiExamples/options/TupleEx.py' -# <-- End of file '/workspace/build/GAUDI/GAUDI_HEAD/GaudiExamples/options/TupleEx.py' +# setting LC_ALL to "C" +# --> Including file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/TupleEx.py' +# <-- End of file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/TupleEx.py' ApplicationMgr SUCCESS ==================================================================================================================================== - Welcome to ApplicationMgr (GaudiCoreSvc v999r999) - running on lbbuild41.cern.ch on Wed Jul 18 05:29:14 2018 + Welcome to ApplicationMgr (GaudiCoreSvc v30r3) + running on pclhcb117 on Tue Sep 18 16:59:46 2018 ==================================================================================================================================== ApplicationMgr INFO Application Manager Configured successfully RndmGenSvc.Engine INFO Generator engine type:CLHEP::RanluxEngine @@ -19,6 +20,33 @@ EventLoopMgr WARNING No events will be processed from external input. ApplicationMgr INFO Application Manager Initialized successfully Gaudi::MetaDataSvc DEBUG started Gaudi::MetaDataSvc DEBUG Metadata collected: +AlgContextSvc.AuditFinalize:False +AlgContextSvc.AuditInitialize:False +AlgContextSvc.AuditReinitialize:False +AlgContextSvc.AuditRestart:False +AlgContextSvc.AuditServices:False +AlgContextSvc.AuditStart:False +AlgContextSvc.AuditStop:False +AlgContextSvc.BypassIncidents:False +AlgContextSvc.Check:True +AlgContextSvc.OutputLevel:3 +AlgExecStateSvc.AuditFinalize:False +AlgExecStateSvc.AuditInitialize:False +AlgExecStateSvc.AuditReinitialize:False +AlgExecStateSvc.AuditRestart:False +AlgExecStateSvc.AuditServices:False +AlgExecStateSvc.AuditStart:False +AlgExecStateSvc.AuditStop:False +AlgExecStateSvc.OutputLevel:3 +AppMgrRunable.AuditFinalize:False +AppMgrRunable.AuditInitialize:False +AppMgrRunable.AuditReinitialize:False +AppMgrRunable.AuditRestart:False +AppMgrRunable.AuditServices:False +AppMgrRunable.AuditStart:False +AppMgrRunable.AuditStop:False +AppMgrRunable.EvtMax:10 +AppMgrRunable.OutputLevel:3 ApplicationMgr.ActivateHistory:False ApplicationMgr.AlgTypeAliases:{ } ApplicationMgr.AppName:'ApplicationMgr' @@ -57,9 +85,95 @@ ApplicationMgr.StopOnSignal:False ApplicationMgr.SvcMapping:[ 'EvtDataSvc/EventDataSvc' , 'DetDataSvc/DetectorDataSvc' , 'HistogramSvc/HistogramDataSvc' , 'HbookCnv::PersSvc/HbookHistSvc' , 'RootHistCnv::PersSvc/RootHistSvc' , 'EvtPersistencySvc/EventPersistencySvc' , 'DetPersistencySvc/DetectorPersistencySvc' , 'HistogramPersistencySvc/HistogramPersistencySvc' ] ApplicationMgr.SvcOptMapping:[ ] ApplicationMgr.TopAlg:[ 'TupleAlg/Tuple' , 'TupleAlg2/Tuple2' , 'TupleAlg3/Tuple3' ] +EventDataSvc.AuditFinalize:False +EventDataSvc.AuditInitialize:False +EventDataSvc.AuditReinitialize:False +EventDataSvc.AuditRestart:False +EventDataSvc.AuditServices:False +EventDataSvc.AuditStart:False +EventDataSvc.AuditStop:False +EventDataSvc.DataAccessName:'DataAccess' +EventDataSvc.DataFaultName:'DataFault' +EventDataSvc.EnableAccessHandler:False +EventDataSvc.EnableFaultHandler:False +EventDataSvc.ForceLeaves:False +EventDataSvc.InhibitPathes:[ ] +EventDataSvc.OutputLevel:3 +EventDataSvc.RootCLID:110 +EventDataSvc.RootName:'/Event' +EventLoopMgr.AuditFinalize:False +EventLoopMgr.AuditInitialize:False +EventLoopMgr.AuditReinitialize:False +EventLoopMgr.AuditRestart:False +EventLoopMgr.AuditServices:False +EventLoopMgr.AuditStart:False +EventLoopMgr.AuditStop:False +EventLoopMgr.EvtSel:'NONE' +EventLoopMgr.HistogramPersistency:'' +EventLoopMgr.OutStream:[ ] +EventLoopMgr.OutStreamType:'OutputStream' +EventLoopMgr.OutputLevel:3 +EventLoopMgr.PrintControlFlowExpression:False +EventLoopMgr.TopAlg:[ 'TupleAlg/Tuple' , 'TupleAlg2/Tuple2' , 'TupleAlg3/Tuple3' ] +EventLoopMgr.Warnings:True +EventPersistencySvc.AuditFinalize:False +EventPersistencySvc.AuditInitialize:False +EventPersistencySvc.AuditReinitialize:False +EventPersistencySvc.AuditRestart:False +EventPersistencySvc.AuditServices:False +EventPersistencySvc.AuditStart:False +EventPersistencySvc.AuditStop:False +EventPersistencySvc.CnvServices:[ ] +EventPersistencySvc.OutputLevel:3 +Gaudi::MetaDataSvc.AuditFinalize:False +Gaudi::MetaDataSvc.AuditInitialize:False +Gaudi::MetaDataSvc.AuditReinitialize:False +Gaudi::MetaDataSvc.AuditRestart:False +Gaudi::MetaDataSvc.AuditServices:False +Gaudi::MetaDataSvc.AuditStart:False +Gaudi::MetaDataSvc.AuditStop:False +Gaudi::MetaDataSvc.Enabled:True Gaudi::MetaDataSvc.OutputLevel:2 -IAlgManager.Algorithms:Tuple, Tuple2, Tuple3 -ISvcLocator.Services:MessageSvc, JobOptionsSvc, RndmGenSvc.Engine, RndmGenSvc, Gaudi::MetaDataSvc, AppMgrRunable, IncidentSvc, EventPersistencySvc, EventDataSvc, AlgContextSvc, TimelineSvc, RootHistSvc, HistogramPersistencySvc, HistogramDataSvc, NTupleSvc, AlgExecStateSvc, EventLoopMgr, ToolSvc +HistogramDataSvc.AuditFinalize:False +HistogramDataSvc.AuditInitialize:False +HistogramDataSvc.AuditReinitialize:False +HistogramDataSvc.AuditRestart:False +HistogramDataSvc.AuditServices:False +HistogramDataSvc.AuditStart:False +HistogramDataSvc.AuditStop:False +HistogramDataSvc.DataAccessName:'DataAccess' +HistogramDataSvc.DataFaultName:'DataFault' +HistogramDataSvc.EnableAccessHandler:False +HistogramDataSvc.EnableFaultHandler:False +HistogramDataSvc.ForceLeaves:False +HistogramDataSvc.InhibitPathes:[ ] +HistogramDataSvc.Input:[ ] +HistogramDataSvc.OutputLevel:3 +HistogramDataSvc.Predefined1DHistos:{ } +HistogramDataSvc.RootCLID:1 +HistogramDataSvc.RootName:'/stat' +HistogramPersistencySvc.AuditFinalize:False +HistogramPersistencySvc.AuditInitialize:False +HistogramPersistencySvc.AuditReinitialize:False +HistogramPersistencySvc.AuditRestart:False +HistogramPersistencySvc.AuditServices:False +HistogramPersistencySvc.AuditStart:False +HistogramPersistencySvc.AuditStop:False +HistogramPersistencySvc.CnvServices:[ 'RootHistSvc' ] +HistogramPersistencySvc.ConvertHistos:[ ] +HistogramPersistencySvc.ExcludeHistos:[ ] +HistogramPersistencySvc.HistogramPersistency:'ROOT' +HistogramPersistencySvc.OutputFile:'' +HistogramPersistencySvc.OutputLevel:3 +HistogramPersistencySvc.Warnings:True +IncidentSvc.AuditFinalize:False +IncidentSvc.AuditInitialize:False +IncidentSvc.AuditReinitialize:False +IncidentSvc.AuditRestart:False +IncidentSvc.AuditServices:False +IncidentSvc.AuditStart:False +IncidentSvc.AuditStop:False +IncidentSvc.OutputLevel:3 JobOptionsSvc.AuditFinalize:False JobOptionsSvc.AuditInitialize:False JobOptionsSvc.AuditReinitialize:False @@ -131,11 +245,259 @@ NTupleSvc.Output:[ "MYLUN DATAFILE='TupleEx.root' OPT='NEW' TYP='ROOT'" ] NTupleSvc.OutputLevel:3 NTupleSvc.RootCLID:1 NTupleSvc.RootName:'/NTUPLES' +NTupleSvcConversions.AuditFinalize:False +NTupleSvcConversions.AuditInitialize:False +NTupleSvcConversions.AuditReinitialize:False +NTupleSvcConversions.AuditRestart:False +NTupleSvcConversions.AuditServices:False +NTupleSvcConversions.AuditStart:False +NTupleSvcConversions.AuditStop:False +NTupleSvcConversions.OutputLevel:3 RFileCnv.GlobalCompression:'LZMA:6' -ToolSvc: +RndmGenSvc.AuditFinalize:False +RndmGenSvc.AuditInitialize:False +RndmGenSvc.AuditReinitialize:False +RndmGenSvc.AuditRestart:False +RndmGenSvc.AuditServices:False +RndmGenSvc.AuditStart:False +RndmGenSvc.AuditStop:False +RndmGenSvc.Engine:'HepRndm::Engine' +RndmGenSvc.Engine.AuditFinalize:False +RndmGenSvc.Engine.AuditInitialize:False +RndmGenSvc.Engine.AuditReinitialize:False +RndmGenSvc.Engine.AuditRestart:False +RndmGenSvc.Engine.AuditServices:False +RndmGenSvc.Engine.AuditStart:False +RndmGenSvc.Engine.AuditStop:False +RndmGenSvc.Engine.Column:0 +RndmGenSvc.Engine.Luxury:3 +RndmGenSvc.Engine.OutputLevel:3 +RndmGenSvc.Engine.Row:1 +RndmGenSvc.Engine.Seeds:[ 1234567 , 0 ] +RndmGenSvc.Engine.SetSingleton:False +RndmGenSvc.Engine.UseTable:False +RndmGenSvc.OutputLevel:3 +RootHistSvc.AuditFinalize:False +RootHistSvc.AuditInitialize:False +RootHistSvc.AuditReinitialize:False +RootHistSvc.AuditRestart:False +RootHistSvc.AuditServices:False +RootHistSvc.AuditStart:False +RootHistSvc.AuditStop:False +RootHistSvc.ForceAlphaIds:False +RootHistSvc.OutputEnabled:True +RootHistSvc.OutputFile:'UndefinedROOTOutputFileName' +RootHistSvc.OutputLevel:3 +TimelineSvc.AuditFinalize:False +TimelineSvc.AuditInitialize:False +TimelineSvc.AuditReinitialize:False +TimelineSvc.AuditRestart:False +TimelineSvc.AuditServices:False +TimelineSvc.AuditStart:False +TimelineSvc.AuditStop:False +TimelineSvc.DumpTimeline:False +TimelineSvc.OutputLevel:3 +TimelineSvc.Partial:False +TimelineSvc.RecordTimeline:False +TimelineSvc.TimelineFile:'timeline.csv' +Tuple.AuditAlgorithms:False +Tuple.AuditBeginRun:False +Tuple.AuditEndRun:False +Tuple.AuditExecute:False +Tuple.AuditFinalize:False +Tuple.AuditInitialize:False +Tuple.AuditReinitialize:False +Tuple.AuditRestart:False +Tuple.AuditStart:False +Tuple.AuditStop:False +Tuple.AutoStringIDPurgeMap:{ '/' : '=SLASH=' } +Tuple.Cardinality:1 +Tuple.Context:'' +Tuple.CounterList:[ '.*' ] +Tuple.EfficiencyRowFormat:' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +Tuple.Enable:True +Tuple.ErrorMax:1 +Tuple.ErrorsPrint:True +Tuple.EvtColDir:'Tuple' +Tuple.EvtColLUN:'EVTCOL' +Tuple.EvtColOffSet:0 +Tuple.EvtColSplitDir:False +Tuple.EvtColTopDir:'' +Tuple.EvtColsPrint:False +Tuple.EvtColsProduce:False +Tuple.ExtraInputs:[] +Tuple.ExtraOutputs:[] +Tuple.FilterCircularDependencies:True +Tuple.FormatFor1DHistoTable:'| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g |' +Tuple.FullDetail:False +Tuple.HeaderFor1DHistoTable:'| Title | # | Mean | RMS | Skewness | Kurtosis |' +Tuple.HistoCheckForNaN:True +Tuple.HistoCountersPrint:True +Tuple.HistoDir:'Tuple' +Tuple.HistoOffSet:0 +Tuple.HistoPrint:False +Tuple.HistoProduce:True +Tuple.HistoSplitDir:False +Tuple.HistoTopDir:'' +Tuple.IsIOBound:False +Tuple.MonitorHistograms:True +Tuple.MonitorService:'MonitorSvc' +Tuple.NTupleDir:'Tuple' Tuple.NTupleLUN:'MYLUN' +Tuple.NTupleOffSet:0 +Tuple.NTuplePrint:True +Tuple.NTupleProduce:True +Tuple.NTupleSplitDir:False +Tuple.NTupleTopDir:'' +Tuple.NeededResources:[ ] +Tuple.OutputLevel:3 +Tuple.PrintEmptyCounters:False +Tuple.PropertiesPrint:False +Tuple.RegisterForContextService:True +Tuple.RegularRowFormat:' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +Tuple.RequireObjects:[ ] +Tuple.RootInTES:'' +Tuple.ShortFormatFor1DHistoTable:' | %1$-25.25s %2%' +Tuple.StatEntityList:[ ] +Tuple.StatPrint:True +Tuple.StatTableHeader:' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +Tuple.Timeline:False +Tuple.TypePrint:True +Tuple.UseEfficiencyRowFormat:True +Tuple.UseSequencialNumericAutoIDs:False +Tuple.VetoObjects:[ ] +Tuple2.AuditAlgorithms:False +Tuple2.AuditBeginRun:False +Tuple2.AuditEndRun:False +Tuple2.AuditExecute:False +Tuple2.AuditFinalize:False +Tuple2.AuditInitialize:False +Tuple2.AuditReinitialize:False +Tuple2.AuditRestart:False +Tuple2.AuditStart:False +Tuple2.AuditStop:False +Tuple2.AutoStringIDPurgeMap:{ '/' : '=SLASH=' } +Tuple2.Cardinality:1 +Tuple2.Context:'' +Tuple2.CounterList:[ '.*' ] +Tuple2.EfficiencyRowFormat:' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +Tuple2.Enable:True +Tuple2.ErrorMax:1 +Tuple2.ErrorsPrint:True +Tuple2.EvtColDir:'Tuple2' +Tuple2.EvtColLUN:'EVTCOL' +Tuple2.EvtColOffSet:0 +Tuple2.EvtColSplitDir:False +Tuple2.EvtColTopDir:'' +Tuple2.EvtColsPrint:False +Tuple2.EvtColsProduce:False +Tuple2.ExtraInputs:[] +Tuple2.ExtraOutputs:[] +Tuple2.FilterCircularDependencies:True +Tuple2.FormatFor1DHistoTable:'| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g |' +Tuple2.FullDetail:False +Tuple2.HeaderFor1DHistoTable:'| Title | # | Mean | RMS | Skewness | Kurtosis |' +Tuple2.HistoCheckForNaN:True +Tuple2.HistoCountersPrint:True +Tuple2.HistoDir:'Tuple2' +Tuple2.HistoOffSet:0 +Tuple2.HistoPrint:False +Tuple2.HistoProduce:True +Tuple2.HistoSplitDir:False +Tuple2.HistoTopDir:'' +Tuple2.IsIOBound:False +Tuple2.MonitorHistograms:True +Tuple2.MonitorService:'MonitorSvc' +Tuple2.NTupleDir:'Tuple2' Tuple2.NTupleLUN:'MYLUN' +Tuple2.NTupleOffSet:0 +Tuple2.NTuplePrint:True +Tuple2.NTupleProduce:True +Tuple2.NTupleSplitDir:False +Tuple2.NTupleTopDir:'' +Tuple2.NeededResources:[ ] +Tuple2.OutputLevel:3 +Tuple2.PrintEmptyCounters:False +Tuple2.PropertiesPrint:False +Tuple2.RegisterForContextService:True +Tuple2.RegularRowFormat:' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +Tuple2.RequireObjects:[ ] +Tuple2.RootInTES:'' +Tuple2.ShortFormatFor1DHistoTable:' | %1$-25.25s %2%' +Tuple2.StatEntityList:[ ] +Tuple2.StatPrint:True +Tuple2.StatTableHeader:' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +Tuple2.Timeline:False +Tuple2.TypePrint:True +Tuple2.UseEfficiencyRowFormat:True +Tuple2.UseSequencialNumericAutoIDs:False +Tuple2.VetoObjects:[ ] +Tuple3.AuditAlgorithms:False +Tuple3.AuditBeginRun:False +Tuple3.AuditEndRun:False +Tuple3.AuditExecute:False +Tuple3.AuditFinalize:False +Tuple3.AuditInitialize:False +Tuple3.AuditReinitialize:False +Tuple3.AuditRestart:False +Tuple3.AuditStart:False +Tuple3.AuditStop:False +Tuple3.AutoStringIDPurgeMap:{ '/' : '=SLASH=' } +Tuple3.Cardinality:1 +Tuple3.Context:'' +Tuple3.CounterList:[ '.*' ] +Tuple3.EfficiencyRowFormat:' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |' +Tuple3.Enable:True +Tuple3.ErrorMax:1 +Tuple3.ErrorsPrint:True +Tuple3.EvtColDir:'Tuple3' +Tuple3.EvtColLUN:'EVTCOL' +Tuple3.EvtColOffSet:0 +Tuple3.EvtColSplitDir:False +Tuple3.EvtColTopDir:'' +Tuple3.EvtColsPrint:False +Tuple3.EvtColsProduce:False +Tuple3.ExtraInputs:[] +Tuple3.ExtraOutputs:[] +Tuple3.FilterCircularDependencies:True +Tuple3.FormatFor1DHistoTable:'| %2$-45.45s | %3$=7d |%8$11.5g | %10$-11.5g|%12$11.5g |%14$11.5g |' +Tuple3.FullDetail:False +Tuple3.HeaderFor1DHistoTable:'| Title | # | Mean | RMS | Skewness | Kurtosis |' +Tuple3.HistoCheckForNaN:True +Tuple3.HistoCountersPrint:True +Tuple3.HistoDir:'Tuple3' +Tuple3.HistoOffSet:0 +Tuple3.HistoPrint:False +Tuple3.HistoProduce:True +Tuple3.HistoSplitDir:False +Tuple3.HistoTopDir:'' +Tuple3.IsIOBound:False +Tuple3.MonitorHistograms:True +Tuple3.MonitorService:'MonitorSvc' +Tuple3.NTupleDir:'Tuple3' Tuple3.NTupleLUN:'MYLUN' +Tuple3.NTupleOffSet:0 +Tuple3.NTuplePrint:True +Tuple3.NTupleProduce:True +Tuple3.NTupleSplitDir:False +Tuple3.NTupleTopDir:'' +Tuple3.NeededResources:[ ] +Tuple3.OutputLevel:3 +Tuple3.PrintEmptyCounters:False +Tuple3.PropertiesPrint:False +Tuple3.RegisterForContextService:True +Tuple3.RegularRowFormat:' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |' +Tuple3.RequireObjects:[ ] +Tuple3.RootInTES:'' +Tuple3.ShortFormatFor1DHistoTable:' | %1$-25.25s %2%' +Tuple3.StatEntityList:[ ] +Tuple3.StatPrint:True +Tuple3.StatTableHeader:' | Counter | # | sum | mean/eff^* | rms/err^* | min | max |' +Tuple3.Timeline:False +Tuple3.TypePrint:True +Tuple3.UseEfficiencyRowFormat:True +Tuple3.UseSequencialNumericAutoIDs:False +Tuple3.VetoObjects:[ ] ApplicationMgr INFO Application Manager Started successfully RFileCnv INFO opening Root file "TupleEx.root" for writing, CompressionLevel='LZMA:6' @@ -246,7 +608,6 @@ Tuple3 SUCCESS ID=VectorMaps Title="Tuple with VectorMaps/'ExtraI Tuple3 SUCCESS ID=Vectors-3D Title="Tuple with Vectors in 3D " #items=6 {p3X,p3Y,p3Z,v3X,v3Y,v3Z} RootHistSvc WARNING no ROOT output file name, Histograms cannot be persistified EventLoopMgr INFO Histograms converted successfully according to request. -ToolSvc INFO Removing all tools created by ToolSvc RFileCnv INFO dumping contents of /NTUPLES/MYLUN TFile: name=TupleEx.root, title=Gaudi Trees, option=CREATE ****************************************************************************** diff --git a/GaudiExamples/tests/qmtest/refs/Properties.ref b/GaudiExamples/tests/qmtest/refs/Properties.ref index ff70fa4a33..4c7bde309d 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties.ref @@ -1,17 +1,17 @@ -JobOptionsSvc INFO # =======> /home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/Services.opts +JobOptionsSvc INFO # =======> /home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Services.opts JobOptionsSvc INFO # (12,1): AuditorSvc.Auditors = ["ChronoAuditor"] -JobOptionsSvc INFO # =======> /home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/Common.opts +JobOptionsSvc INFO # =======> /home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Common.opts JobOptionsSvc INFO # (9,1): ApplicationMgr.StatusCodeCheck = 1 -JobOptionsSvc INFO # =======> /home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/units.opts +JobOptionsSvc INFO # =======> /home/marco/Devel/workspace/Gaudi/GaudiExamples/options/units.opts JobOptionsSvc INFO # (1,1): 1 m = 1000 JobOptionsSvc INFO # (2,1): 1 cm = 10 JobOptionsSvc INFO # (3,1): 1 mm = 1 JobOptionsSvc INFO # (4,1): 1 m2 = 1e+06 -JobOptionsSvc INFO # =======> /home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/optsub1/dummy1.opts +JobOptionsSvc INFO # =======> /home/marco/Devel/workspace/Gaudi/GaudiExamples/options/optsub1/dummy1.opts JobOptionsSvc INFO # (2,1): Dummy1.Property = 1 -JobOptionsSvc INFO # =======> /home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/optsub2/dummy2.opts +JobOptionsSvc INFO # =======> /home/marco/Devel/workspace/Gaudi/GaudiExamples/options/optsub2/dummy2.opts JobOptionsSvc INFO # (2,1): Dummy2.Property = 1 -JobOptionsSvc INFO # =======> /home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/Properties.opts +JobOptionsSvc INFO # =======> /home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Properties.opts JobOptionsSvc INFO # (14,1): ApplicationMgr.TopAlg = ["PropertyAlg"] JobOptionsSvc INFO # (16,1): ApplicationMgr.TopAlg += ["PropertyAlg", "PropertyProxy"] JobOptionsSvc INFO # (18,1): ApplicationMgr.TopAlg -= ["PropertyAlg"] @@ -49,11 +49,11 @@ JobOptionsSvc INFO # (71,1): PropertyProxy.String = "This is set by the p JobOptionsSvc INFO # (74,1): MessageSvc.setDebug += ["EventLoopMgr"] JobOptionsSvc INFO # (75,1): MessageSvc.setVerbose += ["MsgTest"] JobOptionsSvc INFO # (79,1): MessageSvc.setWarning += ["MsgTest"] -JobOptionsSvc INFO Job options successfully read in from /home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/Properties.opts +JobOptionsSvc INFO Job options successfully read in from /home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Properties.opts ApplicationMgr SUCCESS ==================================================================================================================================== - Welcome to ApplicationMgr (GaudiCoreSvc v4r1) - running on pclhcb117 on Fri Jun 24 17:52:45 2016 + Welcome to ApplicationMgr (GaudiCoreSvc v30r3) + running on marco-XPS-13 on Mon Sep 10 17:45:22 2018 ==================================================================================================================================== ApplicationMgr INFO Application Manager Configured successfully StatusCodeSvc INFO initialize @@ -146,50 +146,265 @@ MsgTest ERROR This should be printed if threshold is ERROR MsgTest FATAL This should be printed if threshold is FATAL MsgTest SUCCESS This should be printed ALWAYS PropertyAlg INFO ================================================= +PropertyAlg INFO Read handler called for property: 'PDouble':999.00000 PropertyAlg INFO Dump of the property catalogue: +AppMgrRunable.AuditFinalize: False +AppMgrRunable.AuditInitialize: False +AppMgrRunable.AuditReinitialize: False +AppMgrRunable.AuditRestart: False +AppMgrRunable.AuditServices: False +AppMgrRunable.AuditStart: False +AppMgrRunable.AuditStop: False +AppMgrRunable.EvtMax: 1 +AppMgrRunable.OutputLevel: 3 +ApplicationMgr.ActivateHistory: False +ApplicationMgr.AlgTypeAliases: { } +ApplicationMgr.AppName: 'ApplicationMgr' +ApplicationMgr.AppVersion: '' +ApplicationMgr.AuditAlgorithms: False +ApplicationMgr.AuditServices: False +ApplicationMgr.AuditTools: False +ApplicationMgr.CreateSvc: [ ] +ApplicationMgr.Dlls: [ ] +ApplicationMgr.Environment: { } +ApplicationMgr.EventLoop: 'EventLoopMgr' ApplicationMgr.EvtMax: 1 -ApplicationMgr.EvtSel: "NONE" -ApplicationMgr.HistogramPersistency: "NONE" -ApplicationMgr.StatusCodeCheck: 1 -ApplicationMgr.TopAlg: ["PropertyAlg", "PropertyProxy"] +ApplicationMgr.EvtSel: 'NONE' +ApplicationMgr.Exit: 0 +ApplicationMgr.ExtSvc: [ 'EventDataSvc' , 'DetectorDataSvc' ] +ApplicationMgr.ExtSvcCreates: True +ApplicationMgr.Go: 0 +ApplicationMgr.HistogramPersistency: 'NONE' +ApplicationMgr.InitializationLoopCheck: True +ApplicationMgr.JobOptionsPath: '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Properties.opts' +ApplicationMgr.JobOptionsPostAction: '' +ApplicationMgr.JobOptionsPreAction: '' +ApplicationMgr.JobOptionsSvcType: 'JobOptionsSvc' +ApplicationMgr.JobOptionsType: 'FILE' +ApplicationMgr.MessageSvcType: 'MessageSvc' +ApplicationMgr.OutStream: [ ] +ApplicationMgr.OutStreamType: 'OutputStream' +ApplicationMgr.OutputLevel: 3 +ApplicationMgr.PluginDebugLevel: 0 +ApplicationMgr.PropertiesPrint: False +ApplicationMgr.ReturnCode: 0 +ApplicationMgr.Runable: 'AppMgrRunable' +ApplicationMgr.StalledEventMonitoring: False +ApplicationMgr.StatusCodeCheck: True +ApplicationMgr.StopOnSignal: False +ApplicationMgr.SvcMapping: [ 'EvtDataSvc/EventDataSvc' , 'DetDataSvc/DetectorDataSvc' , 'HistogramSvc/HistogramDataSvc' , 'HbookCnv::PersSvc/HbookHistSvc' , 'RootHistCnv::PersSvc/RootHistSvc' , 'EvtPersistencySvc/EventPersistencySvc' , 'DetPersistencySvc/DetectorPersistencySvc' , 'HistogramPersistencySvc/HistogramPersistencySvc' ] +ApplicationMgr.SvcOptMapping: [ ] +ApplicationMgr.TopAlg: [ 'PropertyAlg' , 'PropertyProxy' ] AuditorSvc.Auditors: ["ChronoAuditor"] +DetectorDataSvc.AllowLoadInRunning: True +DetectorDataSvc.AuditFinalize: False +DetectorDataSvc.AuditInitialize: False +DetectorDataSvc.AuditReinitialize: False +DetectorDataSvc.AuditRestart: False +DetectorDataSvc.AuditServices: False +DetectorDataSvc.AuditStart: False +DetectorDataSvc.AuditStop: False +DetectorDataSvc.DataAccessName: 'DataAccess' +DetectorDataSvc.DataFaultName: 'DataFault' +DetectorDataSvc.DetDbLocation: 'empty' +DetectorDataSvc.DetDbRootName: 'dd' +DetectorDataSvc.DetStorageType: 7 +DetectorDataSvc.EnableAccessHandler: False +DetectorDataSvc.EnableFaultHandler: False +DetectorDataSvc.ForceLeaves: False +DetectorDataSvc.InhibitPathes: [ ] +DetectorDataSvc.OutputLevel: 3 +DetectorDataSvc.PersistencySvc: 'DetectorPersistencySvc' +DetectorDataSvc.RootCLID: 3 +DetectorDataSvc.RootName: '/dd' +DetectorDataSvc.UsePersistency: False +DetectorPersistencySvc.AuditFinalize: False +DetectorPersistencySvc.AuditInitialize: False +DetectorPersistencySvc.AuditReinitialize: False +DetectorPersistencySvc.AuditRestart: False +DetectorPersistencySvc.AuditServices: False +DetectorPersistencySvc.AuditStart: False +DetectorPersistencySvc.AuditStop: False +DetectorPersistencySvc.CnvServices: [ ] +DetectorPersistencySvc.OutputLevel: 3 Dummy1.Property: 1 Dummy2.Property: 1 +EventDataSvc.AuditFinalize: False +EventDataSvc.AuditInitialize: False +EventDataSvc.AuditReinitialize: False +EventDataSvc.AuditRestart: False +EventDataSvc.AuditServices: False +EventDataSvc.AuditStart: False +EventDataSvc.AuditStop: False +EventDataSvc.DataAccessName: 'DataAccess' +EventDataSvc.DataFaultName: 'DataFault' +EventDataSvc.EnableAccessHandler: False +EventDataSvc.EnableFaultHandler: False +EventDataSvc.ForceLeaves: False +EventDataSvc.InhibitPathes: [ ] +EventDataSvc.OutputLevel: 3 +EventDataSvc.RootCLID: 110 +EventDataSvc.RootName: '/Event' +EventLoopMgr.AuditFinalize: False +EventLoopMgr.AuditInitialize: False +EventLoopMgr.AuditReinitialize: False +EventLoopMgr.AuditRestart: False +EventLoopMgr.AuditServices: False +EventLoopMgr.AuditStart: False +EventLoopMgr.AuditStop: False +EventLoopMgr.EvtSel: '' +EventLoopMgr.HistogramPersistency: '' +EventLoopMgr.OutStream: [ ] +EventLoopMgr.OutStreamType: 'OutputStream' +EventLoopMgr.OutputLevel: 2 +EventLoopMgr.PrintControlFlowExpression: False +EventLoopMgr.TopAlg: [ 'PropertyAlg' , 'PropertyProxy' ] +EventLoopMgr.Warnings: True +EventPersistencySvc.AuditFinalize: False +EventPersistencySvc.AuditInitialize: False +EventPersistencySvc.AuditReinitialize: False +EventPersistencySvc.AuditRestart: False +EventPersistencySvc.AuditServices: False +EventPersistencySvc.AuditStart: False +EventPersistencySvc.AuditStop: False +EventPersistencySvc.CnvServices: [ ] +EventPersistencySvc.OutputLevel: 3 +IncidentSvc.AuditFinalize: False +IncidentSvc.AuditInitialize: False +IncidentSvc.AuditReinitialize: False +IncidentSvc.AuditRestart: False +IncidentSvc.AuditServices: False +IncidentSvc.AuditStart: False +IncidentSvc.AuditStop: False +IncidentSvc.OutputLevel: 3 +JobOptionsSvc.AuditFinalize: False +JobOptionsSvc.AuditInitialize: False +JobOptionsSvc.AuditReinitialize: False +JobOptionsSvc.AuditRestart: False +JobOptionsSvc.AuditServices: False +JobOptionsSvc.AuditStart: False +JobOptionsSvc.AuditStop: False +JobOptionsSvc.DUMPFILE: '' +JobOptionsSvc.OutputLevel: 3 +JobOptionsSvc.PATH: '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Properties.opts' +JobOptionsSvc.PYTHONACTION: '' +JobOptionsSvc.PYTHONPARAMS: '' +JobOptionsSvc.SEARCHPATH: '/home/marco/Devel/workspace/Gaudi/GaudiExamples/tests/qmtest:/home/marco/Devel/workspace/Gaudi/GaudiExamples/options' +JobOptionsSvc.TYPE: 'FILE' +MessageSvc.AuditFinalize: False +MessageSvc.AuditInitialize: False +MessageSvc.AuditReinitialize: False +MessageSvc.AuditRestart: False +MessageSvc.AuditServices: False +MessageSvc.AuditStart: False +MessageSvc.AuditStop: False +MessageSvc.Format: '% F%18W%S%7W%R%T %0W%M' MessageSvc.OutputLevel: 3 -MessageSvc.setDebug: ["EventLoopMgr"] -MessageSvc.setVerbose: ["MsgTest"] -MessageSvc.setWarning: ["MsgTest"] -PropertyAlg.Bool: 0 -PropertyAlg.BoolArray: [0, 1, 0] -PropertyAlg.Double: 101.1e+10 -PropertyAlg.DoubleArray: [-11.0, 2., 3.3, 0.4e-03] -PropertyAlg.DoubleArrayWithUnits: [1100000.000000, -20.000000, 33.000000, 0.400000] -PropertyAlg.DoubleArrayWithoutUnits: [1100000.0, -20., 33.0, 0.4] -PropertyAlg.DoublePairArray: [[1.1, 2.1], [2.3, 4.5], [5.6, 6.7]] -PropertyAlg.EmptyArray: {} +MessageSvc.alwaysColorCode: [ ] +MessageSvc.alwaysLimit: 0 +MessageSvc.countInactive: False +MessageSvc.debugColorCode: [ ] +MessageSvc.debugLimit: 500 +MessageSvc.defaultLimit: 500 +MessageSvc.enableSuppression: False +MessageSvc.errorColorCode: [ 'white' , 'red' ] +MessageSvc.errorLimit: 500 +MessageSvc.fatalColorCode: [ 'blue' , 'red' ] +MessageSvc.fatalLimit: 500 +MessageSvc.infoColorCode: [ ] +MessageSvc.infoLimit: 500 +MessageSvc.loggedStreams: { } +MessageSvc.setAlways: [ ] +MessageSvc.setDebug: [ 'EventLoopMgr' ] +MessageSvc.setError: [ ] +MessageSvc.setFatal: [ ] +MessageSvc.setInfo: [ ] +MessageSvc.setVerbose: [ 'MsgTest' ] +MessageSvc.setWarning: [ 'MsgTest' ] +MessageSvc.showStats: False +MessageSvc.statLevel: 0 +MessageSvc.timeFormat: '%Y-%m-%d %H:%M:%S,%f' +MessageSvc.tracedInactiveSources: [ ] +MessageSvc.useColors: False +MessageSvc.verboseColorCode: [ ] +MessageSvc.verboseLimit: 500 +MessageSvc.warningColorCode: [ 'yellow' ] +MessageSvc.warningLimit: 500 +PropertyAlg.AuditAlgorithms: False +PropertyAlg.AuditBeginRun: False +PropertyAlg.AuditEndRun: False +PropertyAlg.AuditExecute: False +PropertyAlg.AuditFinalize: False +PropertyAlg.AuditInitialize: False +PropertyAlg.AuditReinitialize: False +PropertyAlg.AuditRestart: False +PropertyAlg.AuditStart: False +PropertyAlg.AuditStop: False +PropertyAlg.Bool: False +PropertyAlg.BoolArray: [ False , True , False ] +PropertyAlg.Cardinality: 1 +PropertyAlg.Double: 1.0110000e+12 +PropertyAlg.DoubleArray: [ -11.000000 , 2.0000000 , 3.3000000 , 0.00040000000 ] +PropertyAlg.DoubleArrayWithUnits: [ 1100000.0 , -20.000000 , 33.000000 , 0.40000000 ] +PropertyAlg.DoubleArrayWithoutUnits: [ 1100000.0 , -20.000000 , 33.000000 , 0.40000000 ] +PropertyAlg.DoublePairArray: [ ( 1.1000000 , 2.1000000 ) , ( 2.3000000 , 4.5000000 ) , ( 5.6000000 , 6.7000000 ) ] +PropertyAlg.EmptyArray: [ ] +PropertyAlg.Enable: True +PropertyAlg.ErrorMax: 1 +PropertyAlg.ExtraInputs: [] +PropertyAlg.ExtraOutputs: [] +PropertyAlg.FilterCircularDependencies: True PropertyAlg.Int: 101 PropertyAlg.Int64: 4294967296 -PropertyAlg.Int64Array: [4294967296] -PropertyAlg.IntArray: [1, 2, 3, 5] -PropertyAlg.IntPairArray: [[1, 2], [3, 4], [5, 6]] +PropertyAlg.Int64Array: [ 4294967296 ] +PropertyAlg.IntArray: [ 1 , 2 , 3 , 5 ] +PropertyAlg.IntPairArray: [ ( 1 , 2 ) , ( 3 , 4 ) , ( 5 , 6 ) ] +PropertyAlg.IsIOBound: False +PropertyAlg.MonitorService: 'MonitorSvc' +PropertyAlg.NeededResources: [ ] PropertyAlg.OutputLevel: 3 -PropertyAlg.PBool: 1 -PropertyAlg.PBoolArray: [1, 0, 1, 0] -PropertyAlg.PDouble: 101.E5 -PropertyAlg.PDoubleArray: [1.1, 2., 3.3] -PropertyAlg.PInt: 101 -PropertyAlg.PIntArray: [1, 2, 3, 5] -PropertyAlg.PString: "hundred one" -PropertyAlg.PStringArray: ["one", "two", "four"] -PropertyAlg.String: "hundred one" -PropertyAlg.StringArray: ["one", "two", "four"] +PropertyAlg.PBool: False +PropertyAlg.PBoolArray: [ True , False , True , False ] +PropertyAlg.PDouble: 999.00000 +PropertyAlg.PDoubleArray: [ 1.1000000 , 2.0000000 , 3.3000000 ] +PropertyAlg.PInt: 155 +PropertyAlg.PIntArray: [ 1 , 2 , 3 , 5 ] +PropertyAlg.PString: 'hundred one' +PropertyAlg.PStringArray: [ 'one' , 'two' , 'four' ] +PropertyAlg.RegisterForContextService: False +PropertyAlg.String: 'hundred one' +PropertyAlg.StringArray: [ 'one' , 'two' , 'four' ] +PropertyAlg.Timeline: False PropertyAlg.UInt64: 4294967296 -PropertyAlg.UInt64Array: [4294967296] +PropertyAlg.UInt64Array: [ 4294967296 ] PropertyProxy.String: "This is set by the proxy" +StatusCodeSvc.AbortOnError: False +StatusCodeSvc.AuditFinalize: False +StatusCodeSvc.AuditInitialize: False +StatusCodeSvc.AuditReinitialize: False +StatusCodeSvc.AuditRestart: False +StatusCodeSvc.AuditServices: False +StatusCodeSvc.AuditStart: False +StatusCodeSvc.AuditStop: False +StatusCodeSvc.Filter: [ ] +StatusCodeSvc.IgnoreDicts: True +StatusCodeSvc.OutputLevel: 3 +StatusCodeSvc.SuppressCheck: False +TimelineSvc.AuditFinalize: False +TimelineSvc.AuditInitialize: False +TimelineSvc.AuditReinitialize: False +TimelineSvc.AuditRestart: False +TimelineSvc.AuditServices: False +TimelineSvc.AuditStart: False +TimelineSvc.AuditStop: False +TimelineSvc.DumpTimeline: False +TimelineSvc.OutputLevel: 3 +TimelineSvc.Partial: False +TimelineSvc.RecordTimeline: False +TimelineSvc.TimelineFile: 'timeline.csv' PropertyAlg INFO ================================================= -PropertyAlg INFO Read handler called for property: 'PDouble':10100000. -PropertyAlg INFO Update handler called for property: 'PDouble':10100000. -PropertyAlg INFO Changed property DoubleArray in catalogue +PropertyAlg INFO PInt= 'PInt':154 [should be 154] +PropertyAlg INFO Try to assign invalid value to DoubleArray PropertyAlg ERROR got invalid_argument exception: cannot parse '{"12.12", "13.13"}' to std::vector > PropertyAlg INFO DoubleArray = [-11, 2, 3.3, 0.0004] PropertyAlg INFO ================================================= @@ -204,7 +419,7 @@ ApplicationMgr INFO Application Manager Initialized successfully ApplicationMgr INFO Application Manager Started successfully PropertyAlg INFO executing.... PropertyProxy INFO executing.... -EventLoopMgr DEBUG ---> Loop Finished - WSS 41.0586 | total time (skipping 1st evt) 92116 ns +EventLoopMgr DEBUG ---> Loop Finished - WSS 48.9531 | total time (skipping 1st evt) 153636 ns ApplicationMgr INFO Application Manager Stopped successfully PropertyAlg INFO finalizing.... PropertyProxy INFO finalizing.... diff --git a/GaudiExamples/tests/qmtest/refs/Properties2.ref b/GaudiExamples/tests/qmtest/refs/Properties2.ref index 3ee558369b..098e759409 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties2.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties2.ref @@ -1,19 +1,19 @@ # setting LC_ALL to "C" -# --> Including file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/Properties.opts' -# --> Including file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/Common.opts' -# --> Including file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/Services.opts' +# --> Including file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Properties.opts' +# --> Including file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Common.opts' +# --> Including file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Services.opts' # AuditorSvc.Auditors = { "ChronoAuditor" }; -# <-- End of file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/Services.opts' +# <-- End of file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Services.opts' # ApplicationMgr.StatusCodeCheck = true; -# <-- End of file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/Common.opts' -# --> Including file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/units.opts' -# <-- End of file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/units.opts' -# --> Including file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/optsub1/dummy1.opts' +# <-- End of file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Common.opts' +# --> Including file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/units.opts' +# <-- End of file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/units.opts' +# --> Including file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/optsub1/dummy1.opts' # Dummy1.Property=true; -# --> Including file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/optsub2/dummy2.opts' +# --> Including file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/optsub2/dummy2.opts' # Dummy2.Property=true; -# <-- End of file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/optsub2/dummy2.opts' -# <-- End of file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/optsub1/dummy1.opts' +# <-- End of file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/optsub2/dummy2.opts' +# <-- End of file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/optsub1/dummy1.opts' # ApplicationMgr.TopAlg = { "PropertyAlg" }; # ApplicationMgr.TopAlg += { "PropertyAlg", "PropertyProxy" }; # ApplicationMgr.TopAlg -= { "PropertyAlg" }; @@ -51,11 +51,11 @@ # MessageSvc.setDebug += {"EventLoopMgr"}; # MessageSvc.setVerbose += {"MsgTest"}; # MessageSvc.setWarning += {"MsgTest"}; -# <-- End of file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/Properties.opts' +# <-- End of file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Properties.opts' ApplicationMgr SUCCESS ==================================================================================================================================== - Welcome to ApplicationMgr (GaudiCoreSvc v4r1) - running on pclhcb117 on Fri Jun 24 17:52:46 2016 + Welcome to ApplicationMgr (GaudiCoreSvc v30r3) + running on marco-XPS-13 on Mon Sep 10 17:45:23 2018 ==================================================================================================================================== ApplicationMgr INFO Application Manager Configured successfully StatusCodeSvc INFO initialize @@ -148,41 +148,265 @@ MsgTest ERROR This should be printed if threshold is ERROR MsgTest FATAL This should be printed if threshold is FATAL MsgTest SUCCESS This should be printed ALWAYS PropertyAlg INFO ================================================= +PropertyAlg INFO Read handler called for property: 'PDouble':999.00000 PropertyAlg INFO Dump of the property catalogue: +AppMgrRunable.AuditFinalize: False +AppMgrRunable.AuditInitialize: False +AppMgrRunable.AuditReinitialize: False +AppMgrRunable.AuditRestart: False +AppMgrRunable.AuditServices: False +AppMgrRunable.AuditStart: False +AppMgrRunable.AuditStop: False +AppMgrRunable.EvtMax: 1 +AppMgrRunable.OutputLevel: 3 +ApplicationMgr.ActivateHistory: False +ApplicationMgr.AlgTypeAliases: { } +ApplicationMgr.AppName: 'ApplicationMgr' +ApplicationMgr.AppVersion: '' +ApplicationMgr.AuditAlgorithms: False +ApplicationMgr.AuditServices: False +ApplicationMgr.AuditTools: False +ApplicationMgr.CreateSvc: [ ] +ApplicationMgr.Dlls: [ ] +ApplicationMgr.Environment: { } +ApplicationMgr.EventLoop: 'EventLoopMgr' +ApplicationMgr.EvtMax: 1 +ApplicationMgr.EvtSel: 'NONE' +ApplicationMgr.Exit: 0 +ApplicationMgr.ExtSvc: [ 'EventDataSvc' , 'DetectorDataSvc' ] +ApplicationMgr.ExtSvcCreates: True +ApplicationMgr.Go: 0 +ApplicationMgr.HistogramPersistency: 'NONE' +ApplicationMgr.InitializationLoopCheck: True +ApplicationMgr.JobOptionsPath: '' +ApplicationMgr.JobOptionsPostAction: '' +ApplicationMgr.JobOptionsPreAction: '' +ApplicationMgr.JobOptionsSvcType: 'JobOptionsSvc' +ApplicationMgr.JobOptionsType: 'NONE' +ApplicationMgr.MessageSvcType: 'MessageSvc' +ApplicationMgr.OutStream: [ ] +ApplicationMgr.OutStreamType: 'OutputStream' +ApplicationMgr.OutputLevel: 3 +ApplicationMgr.PluginDebugLevel: 0 +ApplicationMgr.PropertiesPrint: False +ApplicationMgr.ReturnCode: 0 +ApplicationMgr.Runable: 'AppMgrRunable' +ApplicationMgr.StalledEventMonitoring: False +ApplicationMgr.StatusCodeCheck: True +ApplicationMgr.StopOnSignal: False +ApplicationMgr.SvcMapping: [ 'EvtDataSvc/EventDataSvc' , 'DetDataSvc/DetectorDataSvc' , 'HistogramSvc/HistogramDataSvc' , 'HbookCnv::PersSvc/HbookHistSvc' , 'RootHistCnv::PersSvc/RootHistSvc' , 'EvtPersistencySvc/EventPersistencySvc' , 'DetPersistencySvc/DetectorPersistencySvc' , 'HistogramPersistencySvc/HistogramPersistencySvc' ] +ApplicationMgr.SvcOptMapping: [ ] +ApplicationMgr.TopAlg: [ 'PropertyAlg' , 'PropertyProxy' ] AuditorSvc.Auditors: ['ChronoAuditor'] +DetectorDataSvc.AllowLoadInRunning: True +DetectorDataSvc.AuditFinalize: False +DetectorDataSvc.AuditInitialize: False +DetectorDataSvc.AuditReinitialize: False +DetectorDataSvc.AuditRestart: False +DetectorDataSvc.AuditServices: False +DetectorDataSvc.AuditStart: False +DetectorDataSvc.AuditStop: False +DetectorDataSvc.DataAccessName: 'DataAccess' +DetectorDataSvc.DataFaultName: 'DataFault' +DetectorDataSvc.DetDbLocation: 'empty' +DetectorDataSvc.DetDbRootName: 'dd' +DetectorDataSvc.DetStorageType: 7 +DetectorDataSvc.EnableAccessHandler: False +DetectorDataSvc.EnableFaultHandler: False +DetectorDataSvc.ForceLeaves: False +DetectorDataSvc.InhibitPathes: [ ] +DetectorDataSvc.OutputLevel: 3 +DetectorDataSvc.PersistencySvc: 'DetectorPersistencySvc' +DetectorDataSvc.RootCLID: 3 +DetectorDataSvc.RootName: '/dd' +DetectorDataSvc.UsePersistency: False +DetectorPersistencySvc.AuditFinalize: False +DetectorPersistencySvc.AuditInitialize: False +DetectorPersistencySvc.AuditReinitialize: False +DetectorPersistencySvc.AuditRestart: False +DetectorPersistencySvc.AuditServices: False +DetectorPersistencySvc.AuditStart: False +DetectorPersistencySvc.AuditStop: False +DetectorPersistencySvc.CnvServices: [ ] +DetectorPersistencySvc.OutputLevel: 3 Dummy1.Property: True Dummy2.Property: True +EventDataSvc.AuditFinalize: False +EventDataSvc.AuditInitialize: False +EventDataSvc.AuditReinitialize: False +EventDataSvc.AuditRestart: False +EventDataSvc.AuditServices: False +EventDataSvc.AuditStart: False +EventDataSvc.AuditStop: False +EventDataSvc.DataAccessName: 'DataAccess' +EventDataSvc.DataFaultName: 'DataFault' +EventDataSvc.EnableAccessHandler: False +EventDataSvc.EnableFaultHandler: False +EventDataSvc.ForceLeaves: False +EventDataSvc.InhibitPathes: [ ] +EventDataSvc.OutputLevel: 3 +EventDataSvc.RootCLID: 110 +EventDataSvc.RootName: '/Event' +EventLoopMgr.AuditFinalize: False +EventLoopMgr.AuditInitialize: False +EventLoopMgr.AuditReinitialize: False +EventLoopMgr.AuditRestart: False +EventLoopMgr.AuditServices: False +EventLoopMgr.AuditStart: False +EventLoopMgr.AuditStop: False +EventLoopMgr.EvtSel: '' +EventLoopMgr.HistogramPersistency: '' +EventLoopMgr.OutStream: [ ] +EventLoopMgr.OutStreamType: 'OutputStream' +EventLoopMgr.OutputLevel: 2 +EventLoopMgr.PrintControlFlowExpression: False +EventLoopMgr.TopAlg: [ 'PropertyAlg' , 'PropertyProxy' ] +EventLoopMgr.Warnings: True +EventPersistencySvc.AuditFinalize: False +EventPersistencySvc.AuditInitialize: False +EventPersistencySvc.AuditReinitialize: False +EventPersistencySvc.AuditRestart: False +EventPersistencySvc.AuditServices: False +EventPersistencySvc.AuditStart: False +EventPersistencySvc.AuditStop: False +EventPersistencySvc.CnvServices: [ ] +EventPersistencySvc.OutputLevel: 3 +IncidentSvc.AuditFinalize: False +IncidentSvc.AuditInitialize: False +IncidentSvc.AuditReinitialize: False +IncidentSvc.AuditRestart: False +IncidentSvc.AuditServices: False +IncidentSvc.AuditStart: False +IncidentSvc.AuditStop: False +IncidentSvc.OutputLevel: 3 +JobOptionsSvc.AuditFinalize: False +JobOptionsSvc.AuditInitialize: False +JobOptionsSvc.AuditReinitialize: False +JobOptionsSvc.AuditRestart: False +JobOptionsSvc.AuditServices: False +JobOptionsSvc.AuditStart: False +JobOptionsSvc.AuditStop: False +JobOptionsSvc.DUMPFILE: '' +JobOptionsSvc.OutputLevel: 3 +JobOptionsSvc.PATH: '../options/job.opts' +JobOptionsSvc.PYTHONACTION: '' +JobOptionsSvc.PYTHONPARAMS: '' +JobOptionsSvc.SEARCHPATH: '/home/marco/Devel/workspace/Gaudi/GaudiExamples/tests/qmtest:/home/marco/Devel/workspace/Gaudi/GaudiExamples/options' +JobOptionsSvc.TYPE: 'NONE' +MessageSvc.AuditFinalize: False +MessageSvc.AuditInitialize: False +MessageSvc.AuditReinitialize: False +MessageSvc.AuditRestart: False +MessageSvc.AuditServices: False +MessageSvc.AuditStart: False +MessageSvc.AuditStop: False +MessageSvc.Format: '% F%18W%S%7W%R%T %0W%M' +MessageSvc.OutputLevel: 3 +MessageSvc.alwaysColorCode: [ ] +MessageSvc.alwaysLimit: 0 +MessageSvc.countInactive: False +MessageSvc.debugColorCode: [ ] +MessageSvc.debugLimit: 500 +MessageSvc.defaultLimit: 500 +MessageSvc.enableSuppression: False +MessageSvc.errorColorCode: [ 'white' , 'red' ] +MessageSvc.errorLimit: 500 +MessageSvc.fatalColorCode: [ 'blue' , 'red' ] +MessageSvc.fatalLimit: 500 +MessageSvc.infoColorCode: [ ] +MessageSvc.infoLimit: 500 +MessageSvc.loggedStreams: { } +MessageSvc.setAlways: [ ] +MessageSvc.setDebug: [ 'EventLoopMgr' ] +MessageSvc.setError: [ ] +MessageSvc.setFatal: [ ] +MessageSvc.setInfo: [ ] +MessageSvc.setVerbose: [ 'MsgTest' ] +MessageSvc.setWarning: [ 'MsgTest' ] +MessageSvc.showStats: False +MessageSvc.statLevel: 0 +MessageSvc.timeFormat: '%Y-%m-%d %H:%M:%S,%f' +MessageSvc.tracedInactiveSources: [ ] +MessageSvc.useColors: False +MessageSvc.verboseColorCode: [ ] +MessageSvc.verboseLimit: 500 +MessageSvc.warningColorCode: [ 'yellow' ] +MessageSvc.warningLimit: 500 +PropertyAlg.AuditAlgorithms: False +PropertyAlg.AuditBeginRun: False +PropertyAlg.AuditEndRun: False +PropertyAlg.AuditExecute: False +PropertyAlg.AuditFinalize: False +PropertyAlg.AuditInitialize: False +PropertyAlg.AuditReinitialize: False +PropertyAlg.AuditRestart: False +PropertyAlg.AuditStart: False +PropertyAlg.AuditStop: False PropertyAlg.Bool: False -PropertyAlg.BoolArray: [False, True, False] -PropertyAlg.Double: 1.011e+12 -PropertyAlg.DoubleArray: [-11.0, 2.0, 3.3, 0.0004] -PropertyAlg.DoubleArrayWithUnits: [1100000.0, -20.0, 33.0, 0.4] -PropertyAlg.DoubleArrayWithoutUnits: [1100000.0, -20.0, 33.0, 0.4] -PropertyAlg.DoublePairArray: [(1.1, 2.1), (2.3, 4.5), (5.6, 6.7)] -PropertyAlg.EmptyArray: [] +PropertyAlg.BoolArray: [ False , True , False ] +PropertyAlg.Cardinality: 1 +PropertyAlg.Double: 1.0110000e+12 +PropertyAlg.DoubleArray: [ -11.000000 , 2.0000000 , 3.3000000 , 0.00040000000 ] +PropertyAlg.DoubleArrayWithUnits: [ 1100000.0 , -20.000000 , 33.000000 , 0.40000000 ] +PropertyAlg.DoubleArrayWithoutUnits: [ 1100000.0 , -20.000000 , 33.000000 , 0.40000000 ] +PropertyAlg.DoublePairArray: [ ( 1.1000000 , 2.1000000 ) , ( 2.3000000 , 4.5000000 ) , ( 5.6000000 , 6.7000000 ) ] +PropertyAlg.EmptyArray: [ ] +PropertyAlg.Enable: True +PropertyAlg.ErrorMax: 1 +PropertyAlg.ExtraInputs: [] +PropertyAlg.ExtraOutputs: [] +PropertyAlg.FilterCircularDependencies: True PropertyAlg.Int: 101 PropertyAlg.Int64: 4294967296 -PropertyAlg.Int64Array: [4294967296] -PropertyAlg.IntArray: [1, 2, 3, 5] -PropertyAlg.IntPairArray: [(1, 2), (3, 4), (5, 6)] +PropertyAlg.Int64Array: [ 4294967296 ] +PropertyAlg.IntArray: [ 1 , 2 , 3 , 5 ] +PropertyAlg.IntPairArray: [ ( 1 , 2 ) , ( 3 , 4 ) , ( 5 , 6 ) ] +PropertyAlg.IsIOBound: False +PropertyAlg.MonitorService: 'MonitorSvc' +PropertyAlg.NeededResources: [ ] PropertyAlg.OutputLevel: 3 -PropertyAlg.PBool: True -PropertyAlg.PBoolArray: [True, False, True, False] -PropertyAlg.PDouble: 10100000.0 -PropertyAlg.PDoubleArray: [1.1, 2.0, 3.3] -PropertyAlg.PInt: 101 -PropertyAlg.PIntArray: [1, 2, 3, 5] +PropertyAlg.PBool: False +PropertyAlg.PBoolArray: [ True , False , True , False ] +PropertyAlg.PDouble: 999.00000 +PropertyAlg.PDoubleArray: [ 1.1000000 , 2.0000000 , 3.3000000 ] +PropertyAlg.PInt: 155 +PropertyAlg.PIntArray: [ 1 , 2 , 3 , 5 ] PropertyAlg.PString: 'hundred one' -PropertyAlg.PStringArray: ['one', 'two', 'four'] +PropertyAlg.PStringArray: [ 'one' , 'two' , 'four' ] +PropertyAlg.RegisterForContextService: False PropertyAlg.String: 'hundred one' -PropertyAlg.StringArray: ['one', 'two', 'four'] +PropertyAlg.StringArray: [ 'one' , 'two' , 'four' ] +PropertyAlg.Timeline: False PropertyAlg.UInt64: 4294967296 -PropertyAlg.UInt64Array: [4294967296] +PropertyAlg.UInt64Array: [ 4294967296 ] PropertyProxy.String: 'This is set by the proxy' +StatusCodeSvc.AbortOnError: False +StatusCodeSvc.AuditFinalize: False +StatusCodeSvc.AuditInitialize: False +StatusCodeSvc.AuditReinitialize: False +StatusCodeSvc.AuditRestart: False +StatusCodeSvc.AuditServices: False +StatusCodeSvc.AuditStart: False +StatusCodeSvc.AuditStop: False +StatusCodeSvc.Filter: [ ] +StatusCodeSvc.IgnoreDicts: True +StatusCodeSvc.OutputLevel: 3 +StatusCodeSvc.SuppressCheck: False +TimelineSvc.AuditFinalize: False +TimelineSvc.AuditInitialize: False +TimelineSvc.AuditReinitialize: False +TimelineSvc.AuditRestart: False +TimelineSvc.AuditServices: False +TimelineSvc.AuditStart: False +TimelineSvc.AuditStop: False +TimelineSvc.DumpTimeline: False +TimelineSvc.OutputLevel: 3 +TimelineSvc.Partial: False +TimelineSvc.RecordTimeline: False +TimelineSvc.TimelineFile: 'timeline.csv' PropertyAlg INFO ================================================= -PropertyAlg INFO Read handler called for property: 'PDouble':10100000. -PropertyAlg INFO Update handler called for property: 'PDouble':10100000. -PropertyAlg INFO Changed property DoubleArray in catalogue +PropertyAlg INFO PInt= 'PInt':154 [should be 154] +PropertyAlg INFO Try to assign invalid value to DoubleArray PropertyAlg ERROR got invalid_argument exception: cannot parse '{"12.12", "13.13"}' to std::vector > PropertyAlg INFO DoubleArray = [-11, 2, 3.3, 0.0004] PropertyAlg INFO ================================================= @@ -197,7 +421,7 @@ ApplicationMgr INFO Application Manager Initialized successfully ApplicationMgr INFO Application Manager Started successfully PropertyAlg INFO executing.... PropertyProxy INFO executing.... -EventLoopMgr DEBUG ---> Loop Finished - WSS 51.3164 | total time (skipping 1st evt) 75895 ns +EventLoopMgr DEBUG ---> Loop Finished - WSS 58.9219 | total time (skipping 1st evt) 201140 ns ApplicationMgr INFO Application Manager Stopped successfully PropertyAlg INFO finalizing.... PropertyProxy INFO finalizing.... diff --git a/GaudiExamples/tests/qmtest/refs/Properties_py.ref b/GaudiExamples/tests/qmtest/refs/Properties_py.ref index bab7cec0a1..8f144df897 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties_py.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties_py.ref @@ -1,12 +1,12 @@ # setting LC_ALL to "C" -# --> Including file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/Properties.py' -# --> Including file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/optsub1/dummy1.opts' +# --> Including file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Properties.py' +# --> Including file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/optsub1/dummy1.opts' # Dummy1.Property=true; -# --> Including file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/optsub2/dummy2.opts' +# --> Including file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/optsub2/dummy2.opts' # Dummy2.Property=true; -# <-- End of file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/optsub2/dummy2.opts' -# <-- End of file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/optsub1/dummy1.opts' -# <-- End of file '/home/marcocle/Devel/workspace/Gaudi/GaudiExamples/options/Properties.py' +# <-- End of file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/optsub2/dummy2.opts' +# <-- End of file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/optsub1/dummy1.opts' +# <-- End of file '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Properties.py' # applying configuration of GaudiExamplesCommonConf # /***** User GaudiExamplesCommonConf/GaudiExamplesCommonConf **************************************** # |-OutputLevel = 3 (default: 3) @@ -14,8 +14,8 @@ # \----- (End of User GaudiExamplesCommonConf/GaudiExamplesCommonConf) ------------------------------- ApplicationMgr SUCCESS ==================================================================================================================================== - Welcome to ApplicationMgr (GaudiCoreSvc v4r1) - running on pclhcb117 on Fri Jun 24 17:52:46 2016 + Welcome to ApplicationMgr (GaudiCoreSvc v30r3) + running on marco-XPS-13 on Mon Sep 10 17:45:23 2018 ==================================================================================================================================== ApplicationMgr INFO Application Manager Configured successfully StatusCodeSvc INFO initialize @@ -108,39 +108,264 @@ MsgTest ERROR This should be printed if threshold is ERROR MsgTest FATAL This should be printed if threshold is FATAL MsgTest SUCCESS This should be printed ALWAYS PropertyAlg INFO ================================================= +PropertyAlg INFO Read handler called for property: 'PDouble':999.00000 PropertyAlg INFO Dump of the property catalogue: +AppMgrRunable.AuditFinalize: False +AppMgrRunable.AuditInitialize: False +AppMgrRunable.AuditReinitialize: False +AppMgrRunable.AuditRestart: False +AppMgrRunable.AuditServices: False +AppMgrRunable.AuditStart: False +AppMgrRunable.AuditStop: False +AppMgrRunable.EvtMax: 1 +AppMgrRunable.OutputLevel: 3 +ApplicationMgr.ActivateHistory: False +ApplicationMgr.AlgTypeAliases: { } +ApplicationMgr.AppName: 'ApplicationMgr' +ApplicationMgr.AppVersion: '' +ApplicationMgr.AuditAlgorithms: False +ApplicationMgr.AuditServices: False +ApplicationMgr.AuditTools: False +ApplicationMgr.CreateSvc: [ ] +ApplicationMgr.Dlls: [ ] +ApplicationMgr.Environment: { } +ApplicationMgr.EventLoop: 'EventLoopMgr' +ApplicationMgr.EvtMax: 1 +ApplicationMgr.EvtSel: 'NONE' +ApplicationMgr.Exit: 0 +ApplicationMgr.ExtSvc: [ 'EventDataSvc' , 'DetectorDataSvc' ] +ApplicationMgr.ExtSvcCreates: True +ApplicationMgr.Go: 0 +ApplicationMgr.HistogramPersistency: 'NONE' +ApplicationMgr.InitializationLoopCheck: True +ApplicationMgr.JobOptionsPath: '' +ApplicationMgr.JobOptionsPostAction: '' +ApplicationMgr.JobOptionsPreAction: '' +ApplicationMgr.JobOptionsSvcType: 'JobOptionsSvc' +ApplicationMgr.JobOptionsType: 'NONE' +ApplicationMgr.MessageSvcType: 'MessageSvc' +ApplicationMgr.OutStream: [ ] +ApplicationMgr.OutStreamType: 'OutputStream' +ApplicationMgr.OutputLevel: 3 +ApplicationMgr.PluginDebugLevel: 0 +ApplicationMgr.PropertiesPrint: False +ApplicationMgr.ReturnCode: 0 +ApplicationMgr.Runable: 'AppMgrRunable' +ApplicationMgr.StalledEventMonitoring: False +ApplicationMgr.StatusCodeCheck: True +ApplicationMgr.StopOnSignal: False +ApplicationMgr.SvcMapping: [ 'EvtDataSvc/EventDataSvc' , 'DetDataSvc/DetectorDataSvc' , 'HistogramSvc/HistogramDataSvc' , 'HbookCnv::PersSvc/HbookHistSvc' , 'RootHistCnv::PersSvc/RootHistSvc' , 'EvtPersistencySvc/EventPersistencySvc' , 'DetPersistencySvc/DetectorPersistencySvc' , 'HistogramPersistencySvc/HistogramPersistencySvc' ] +ApplicationMgr.SvcOptMapping: [ ] +ApplicationMgr.TopAlg: [ 'PropertyAlg/PropertyAlg' , 'PropertyProxy/PropertyProxy' ] AuditorSvc.Auditors: ['ChronoAuditor/ChronoAuditor'] +DetectorDataSvc.AllowLoadInRunning: True +DetectorDataSvc.AuditFinalize: False +DetectorDataSvc.AuditInitialize: False +DetectorDataSvc.AuditReinitialize: False +DetectorDataSvc.AuditRestart: False +DetectorDataSvc.AuditServices: False +DetectorDataSvc.AuditStart: False +DetectorDataSvc.AuditStop: False +DetectorDataSvc.DataAccessName: 'DataAccess' +DetectorDataSvc.DataFaultName: 'DataFault' +DetectorDataSvc.DetDbLocation: 'empty' +DetectorDataSvc.DetDbRootName: 'dd' +DetectorDataSvc.DetStorageType: 7 +DetectorDataSvc.EnableAccessHandler: False +DetectorDataSvc.EnableFaultHandler: False +DetectorDataSvc.ForceLeaves: False +DetectorDataSvc.InhibitPathes: [ ] +DetectorDataSvc.OutputLevel: 3 +DetectorDataSvc.PersistencySvc: 'DetectorPersistencySvc' +DetectorDataSvc.RootCLID: 3 +DetectorDataSvc.RootName: '/dd' +DetectorDataSvc.UsePersistency: False +DetectorPersistencySvc.AuditFinalize: False +DetectorPersistencySvc.AuditInitialize: False +DetectorPersistencySvc.AuditReinitialize: False +DetectorPersistencySvc.AuditRestart: False +DetectorPersistencySvc.AuditServices: False +DetectorPersistencySvc.AuditStart: False +DetectorPersistencySvc.AuditStop: False +DetectorPersistencySvc.CnvServices: [ ] +DetectorPersistencySvc.OutputLevel: 3 Dummy1.Property: True Dummy2.Property: True +EventDataSvc.AuditFinalize: False +EventDataSvc.AuditInitialize: False +EventDataSvc.AuditReinitialize: False +EventDataSvc.AuditRestart: False +EventDataSvc.AuditServices: False +EventDataSvc.AuditStart: False +EventDataSvc.AuditStop: False +EventDataSvc.DataAccessName: 'DataAccess' +EventDataSvc.DataFaultName: 'DataFault' +EventDataSvc.EnableAccessHandler: False +EventDataSvc.EnableFaultHandler: False +EventDataSvc.ForceLeaves: False +EventDataSvc.InhibitPathes: [ ] +EventDataSvc.OutputLevel: 3 +EventDataSvc.RootCLID: 110 +EventDataSvc.RootName: '/Event' +EventLoopMgr.AuditFinalize: False +EventLoopMgr.AuditInitialize: False +EventLoopMgr.AuditReinitialize: False +EventLoopMgr.AuditRestart: False +EventLoopMgr.AuditServices: False +EventLoopMgr.AuditStart: False +EventLoopMgr.AuditStop: False +EventLoopMgr.EvtSel: '' +EventLoopMgr.HistogramPersistency: '' +EventLoopMgr.OutStream: [ ] +EventLoopMgr.OutStreamType: 'OutputStream' +EventLoopMgr.OutputLevel: 2 +EventLoopMgr.PrintControlFlowExpression: False +EventLoopMgr.TopAlg: [ 'PropertyAlg/PropertyAlg' , 'PropertyProxy/PropertyProxy' ] +EventLoopMgr.Warnings: True +EventPersistencySvc.AuditFinalize: False +EventPersistencySvc.AuditInitialize: False +EventPersistencySvc.AuditReinitialize: False +EventPersistencySvc.AuditRestart: False +EventPersistencySvc.AuditServices: False +EventPersistencySvc.AuditStart: False +EventPersistencySvc.AuditStop: False +EventPersistencySvc.CnvServices: [ ] +EventPersistencySvc.OutputLevel: 3 +IncidentSvc.AuditFinalize: False +IncidentSvc.AuditInitialize: False +IncidentSvc.AuditReinitialize: False +IncidentSvc.AuditRestart: False +IncidentSvc.AuditServices: False +IncidentSvc.AuditStart: False +IncidentSvc.AuditStop: False +IncidentSvc.OutputLevel: 3 +JobOptionsSvc.AuditFinalize: False +JobOptionsSvc.AuditInitialize: False +JobOptionsSvc.AuditReinitialize: False +JobOptionsSvc.AuditRestart: False +JobOptionsSvc.AuditServices: False +JobOptionsSvc.AuditStart: False +JobOptionsSvc.AuditStop: False +JobOptionsSvc.DUMPFILE: '' +JobOptionsSvc.OutputLevel: 3 +JobOptionsSvc.PATH: '../options/job.opts' +JobOptionsSvc.PYTHONACTION: '' +JobOptionsSvc.PYTHONPARAMS: '' +JobOptionsSvc.SEARCHPATH: '/home/marco/Devel/workspace/Gaudi/GaudiExamples/tests/qmtest:/home/marco/Devel/workspace/Gaudi/GaudiExamples/options' +JobOptionsSvc.TYPE: 'NONE' +MessageSvc.AuditFinalize: False +MessageSvc.AuditInitialize: False +MessageSvc.AuditReinitialize: False +MessageSvc.AuditRestart: False +MessageSvc.AuditServices: False +MessageSvc.AuditStart: False +MessageSvc.AuditStop: False +MessageSvc.Format: '% F%18W%S%7W%R%T %0W%M' +MessageSvc.OutputLevel: 3 +MessageSvc.alwaysColorCode: [ ] +MessageSvc.alwaysLimit: 0 +MessageSvc.countInactive: False +MessageSvc.debugColorCode: [ ] +MessageSvc.debugLimit: 500 +MessageSvc.defaultLimit: 500 +MessageSvc.enableSuppression: False +MessageSvc.errorColorCode: [ 'white' , 'red' ] +MessageSvc.errorLimit: 500 +MessageSvc.fatalColorCode: [ 'blue' , 'red' ] +MessageSvc.fatalLimit: 500 +MessageSvc.infoColorCode: [ ] +MessageSvc.infoLimit: 500 +MessageSvc.loggedStreams: { } +MessageSvc.setAlways: [ ] +MessageSvc.setDebug: [ 'EventLoopMgr' ] +MessageSvc.setError: [ ] +MessageSvc.setFatal: [ ] +MessageSvc.setInfo: [ ] +MessageSvc.setVerbose: [ 'MsgTest' ] +MessageSvc.setWarning: [ 'MsgTest' ] +MessageSvc.showStats: False +MessageSvc.statLevel: 0 +MessageSvc.timeFormat: '%Y-%m-%d %H:%M:%S,%f' +MessageSvc.tracedInactiveSources: [ ] +MessageSvc.useColors: False +MessageSvc.verboseColorCode: [ ] +MessageSvc.verboseLimit: 500 +MessageSvc.warningColorCode: [ 'yellow' ] +MessageSvc.warningLimit: 500 +PropertyAlg.AuditAlgorithms: False +PropertyAlg.AuditBeginRun: False +PropertyAlg.AuditEndRun: False +PropertyAlg.AuditExecute: False +PropertyAlg.AuditFinalize: False +PropertyAlg.AuditInitialize: False +PropertyAlg.AuditReinitialize: False +PropertyAlg.AuditRestart: False +PropertyAlg.AuditStart: False +PropertyAlg.AuditStop: False PropertyAlg.Bool: False -PropertyAlg.BoolArray: [False, True, False] -PropertyAlg.Double: 1.011e+12 -PropertyAlg.DoubleArray: [-11.0, 2.0, 3.3, 0.0004, 1e-20, 1e+20] -PropertyAlg.DoubleArrayWithUnits: [1100000.0, -20.0, 33.0, 0.4] -PropertyAlg.DoubleArrayWithoutUnits: [1100000.0, -20.0, 33.0, 0.4] -PropertyAlg.DoublePairArray: [(1.1, 2.1), (2.3, 4.5), (5.6, 6.7)] +PropertyAlg.BoolArray: [ False , True , False ] +PropertyAlg.Cardinality: 1 +PropertyAlg.Double: 1.0110000e+12 +PropertyAlg.DoubleArray: [ -11.000000 , 2.0000000 , 3.3000000 , 0.00040000000 , 1.0000000e-20 , 1.0000000e+20 ] +PropertyAlg.DoubleArrayWithUnits: [ 1100000.0 , -20.000000 , 33.000000 , 0.40000000 ] +PropertyAlg.DoubleArrayWithoutUnits: [ 1100000.0 , -20.000000 , 33.000000 , 0.40000000 ] +PropertyAlg.DoublePairArray: [ ( 1.1000000 , 2.1000000 ) , ( 2.3000000 , 4.5000000 ) , ( 5.6000000 , 6.7000000 ) ] +PropertyAlg.EmptyArray: [ ] +PropertyAlg.Enable: True +PropertyAlg.ErrorMax: 1 +PropertyAlg.ExtraInputs: [] +PropertyAlg.ExtraOutputs: [] +PropertyAlg.FilterCircularDependencies: True PropertyAlg.Int: 101 PropertyAlg.Int64: 4294967296 -PropertyAlg.Int64Array: [4294967296] -PropertyAlg.IntArray: [1, 2, 3, 5] -PropertyAlg.IntPairArray: [(1, 2), (3, 4), (5, 6)] +PropertyAlg.Int64Array: [ 4294967296 ] +PropertyAlg.IntArray: [ 1 , 2 , 3 , 5 ] +PropertyAlg.IntPairArray: [ ( 1 , 2 ) , ( 3 , 4 ) , ( 5 , 6 ) ] +PropertyAlg.IsIOBound: False +PropertyAlg.MonitorService: 'MonitorSvc' +PropertyAlg.NeededResources: [ ] PropertyAlg.OutputLevel: 3 -PropertyAlg.PBool: True -PropertyAlg.PBoolArray: [True, False, True, False] -PropertyAlg.PDouble: 10100000.0 -PropertyAlg.PDoubleArray: [1.1, 2.0, 3.3, 1e-20, 1e+20] -PropertyAlg.PInt: 101 -PropertyAlg.PIntArray: [1, 2, 3, 5] +PropertyAlg.PBool: False +PropertyAlg.PBoolArray: [ True , False , True , False ] +PropertyAlg.PDouble: 999.00000 +PropertyAlg.PDoubleArray: [ 1.1000000 , 2.0000000 , 3.3000000 , 1.0000000e-20 , 1.0000000e+20 ] +PropertyAlg.PInt: 155 +PropertyAlg.PIntArray: [ 1 , 2 , 3 , 5 ] PropertyAlg.PString: 'hundred one' -PropertyAlg.PStringArray: ['one', 'two', 'four'] +PropertyAlg.PStringArray: [ 'one' , 'two' , 'four' ] +PropertyAlg.RegisterForContextService: False PropertyAlg.String: 'hundred one' -PropertyAlg.StringArray: ['one', 'two', 'four'] +PropertyAlg.StringArray: [ 'one' , 'two' , 'four' ] +PropertyAlg.Timeline: False PropertyAlg.UInt64: 4294967296 -PropertyAlg.UInt64Array: [4294967296L] +PropertyAlg.UInt64Array: [ 4294967296 ] +StatusCodeSvc.AbortOnError: False +StatusCodeSvc.AuditFinalize: False +StatusCodeSvc.AuditInitialize: False +StatusCodeSvc.AuditReinitialize: False +StatusCodeSvc.AuditRestart: False +StatusCodeSvc.AuditServices: False +StatusCodeSvc.AuditStart: False +StatusCodeSvc.AuditStop: False +StatusCodeSvc.Filter: [ ] +StatusCodeSvc.IgnoreDicts: True +StatusCodeSvc.OutputLevel: 3 +StatusCodeSvc.SuppressCheck: False +TimelineSvc.AuditFinalize: False +TimelineSvc.AuditInitialize: False +TimelineSvc.AuditReinitialize: False +TimelineSvc.AuditRestart: False +TimelineSvc.AuditServices: False +TimelineSvc.AuditStart: False +TimelineSvc.AuditStop: False +TimelineSvc.DumpTimeline: False +TimelineSvc.OutputLevel: 3 +TimelineSvc.Partial: False +TimelineSvc.RecordTimeline: False +TimelineSvc.TimelineFile: 'timeline.csv' PropertyAlg INFO ================================================= -PropertyAlg INFO Read handler called for property: 'PDouble':10100000. -PropertyAlg INFO Update handler called for property: 'PDouble':10100000. -PropertyAlg INFO Changed property DoubleArray in catalogue +PropertyAlg INFO PInt= 'PInt':154 [should be 154] +PropertyAlg INFO Try to assign invalid value to DoubleArray PropertyAlg ERROR got invalid_argument exception: cannot parse '{"12.12", "13.13"}' to std::vector > PropertyAlg INFO DoubleArray = [-11, 2, 3.3, 0.0004, 1e-20, 1e+20] PropertyAlg INFO ================================================= @@ -155,7 +380,7 @@ ApplicationMgr INFO Application Manager Initialized successfully ApplicationMgr INFO Application Manager Started successfully PropertyAlg INFO executing.... PropertyProxy INFO executing.... -EventLoopMgr DEBUG ---> Loop Finished - WSS 55.8086 | total time (skipping 1st evt) 78452 ns +EventLoopMgr DEBUG ---> Loop Finished - WSS 65.7539 | total time (skipping 1st evt) 210934 ns ApplicationMgr INFO Application Manager Stopped successfully PropertyAlg INFO finalizing.... PropertyProxy INFO finalizing.... diff --git a/GaudiExamples/tests/qmtest/refs/THistRead.ref.dbg b/GaudiExamples/tests/qmtest/refs/THistRead.ref.dbg index 9fb934d8a6..5def8f13a4 100644 --- a/GaudiExamples/tests/qmtest/refs/THistRead.ref.dbg +++ b/GaudiExamples/tests/qmtest/refs/THistRead.ref.dbg @@ -30,6 +30,7 @@ ApplicationMgr DEBUG Loading declared DLL's ApplicationMgr VERBOSE addMultiSvc: added service EventLoopMgr/EventLoopMgr ApplicationMgr INFO Application Manager Configured successfully THistSvc DEBUG Property update for OutputLevel : new value = 2 +THistSvc DEBUG Delaying connection of Input Files until Initialize. now in OFFLINE THistSvc DEBUG Service base class initialized successfully THistSvc DEBUG Delaying connection of Output Files until Initialize. now in CONFIGURED THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED diff --git a/GaudiExamples/tests/qmtest/refs/THistWrite.ref b/GaudiExamples/tests/qmtest/refs/THistWrite.ref index fe48e77832..31f336fc17 100644 --- a/GaudiExamples/tests/qmtest/refs/THistWrite.ref +++ b/GaudiExamples/tests/qmtest/refs/THistWrite.ref @@ -30,7 +30,7 @@ ApplicationMgr DEBUG Loading declared DLL's ApplicationMgr VERBOSE added service EventLoopMgr/EventLoopMgr ApplicationMgr INFO Application Manager Configured successfully THistSvc DEBUG Property update for OutputLevel : new value = 2 -THistSvc DEBUG Delaying connection of Input Files until Initialize. now in OFFLINE +THistSvc DEBUG Delaying connection of Output Files until Initialize. now in OFFLINE THistSvc DEBUG Service base class initialized successfully THistSvc DEBUG Delaying connection of Output Files until Initialize. now in CONFIGURED THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED diff --git a/GaudiExamples/tests/qmtest/refs/THistWrite.ref.dbg b/GaudiExamples/tests/qmtest/refs/THistWrite.ref.dbg index dc894d2675..07f3254e78 100644 --- a/GaudiExamples/tests/qmtest/refs/THistWrite.ref.dbg +++ b/GaudiExamples/tests/qmtest/refs/THistWrite.ref.dbg @@ -30,6 +30,7 @@ ApplicationMgr DEBUG Loading declared DLL's ApplicationMgr VERBOSE added service EventLoopMgr/EventLoopMgr ApplicationMgr INFO Application Manager Configured successfully THistSvc DEBUG Property update for OutputLevel : new value = 2 +THistSvc DEBUG Delaying connection of Output Files until Initialize. now in OFFLINE THistSvc DEBUG Service base class initialized successfully THistSvc DEBUG Delaying connection of Output Files until Initialize. now in CONFIGURED THistSvc DEBUG Delaying connection of Input Files until Initialize. now in CONFIGURED diff --git a/GaudiKernel/CMakeLists.txt b/GaudiKernel/CMakeLists.txt index 480ffbc2f9..cb9ed4fe69 100644 --- a/GaudiKernel/CMakeLists.txt +++ b/GaudiKernel/CMakeLists.txt @@ -144,6 +144,9 @@ gaudi_add_unit_test(test_PropertyHolder tests/src/test_PropertyHolder.cpp gaudi_add_unit_test(test_Property tests/src/test_Property.cpp LINK_LIBRARIES GaudiKernel TYPE Boost) +gaudi_add_unit_test(test_WeekPropertyRef tests/src/test_WeekPropertyRef.cpp + LINK_LIBRARIES GaudiKernel + TYPE Boost) gaudi_add_unit_test(test_StatusCode tests/src/test_StatusCode.cpp LINK_LIBRARIES GaudiKernel TYPE Boost) diff --git a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h index ba62f9f07a..820302da13 100644 --- a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h +++ b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h @@ -6,6 +6,10 @@ namespace Gaudi { + namespace Details + { + class PropertyBase; + } namespace Interfaces { /** Interface for a component that manages application configuration options. @@ -45,6 +49,8 @@ namespace Gaudi /// Return all known options with their values. virtual std::vector> items() const = 0; + virtual void bind( const std::string& prefix, Gaudi::Details::PropertyBase* property ) = 0; + protected: virtual ~IOptionsSvc() = default; }; diff --git a/GaudiKernel/GaudiKernel/AlgTool.h b/GaudiKernel/GaudiKernel/AlgTool.h index 76a4a49ac5..88f58e4031 100644 --- a/GaudiKernel/GaudiKernel/AlgTool.h +++ b/GaudiKernel/GaudiKernel/AlgTool.h @@ -121,7 +121,7 @@ public: [[deprecated( "it should not be called explicitely" )]] StatusCode setProperties() { if ( !serviceLocator() ) return StatusCode::FAILURE; - setPropertiesFrom( serviceLocator()->getOptsSvc() ); + bindPropertiesTo( serviceLocator()->getOptsSvc() ); return StatusCode::SUCCESS; } diff --git a/GaudiKernel/GaudiKernel/Algorithm.h b/GaudiKernel/GaudiKernel/Algorithm.h index b29141a46c..c089fcd4b7 100644 --- a/GaudiKernel/GaudiKernel/Algorithm.h +++ b/GaudiKernel/GaudiKernel/Algorithm.h @@ -356,7 +356,7 @@ public: [[deprecated( "it should not be called explicitely" )]] StatusCode setProperties() { if ( !serviceLocator() ) return StatusCode::FAILURE; - setPropertiesFrom( serviceLocator()->getOptsSvc() ); + bindPropertiesTo( serviceLocator()->getOptsSvc() ); return StatusCode::SUCCESS; } diff --git a/GaudiKernel/GaudiKernel/Auditor.h b/GaudiKernel/GaudiKernel/Auditor.h index cd55d3ef4b..fcb7d70491 100644 --- a/GaudiKernel/GaudiKernel/Auditor.h +++ b/GaudiKernel/GaudiKernel/Auditor.h @@ -125,7 +125,7 @@ public: [[deprecated( "it should not be called explicitely" )]] StatusCode setProperties() { if ( !serviceLocator() ) return StatusCode::FAILURE; - setPropertiesFrom( serviceLocator()->getOptsSvc() ); + bindPropertiesTo( serviceLocator()->getOptsSvc() ); return StatusCode::SUCCESS; } diff --git a/GaudiKernel/GaudiKernel/Property.h b/GaudiKernel/GaudiKernel/Property.h index 5fd480d076..80c0db0bc0 100644 --- a/GaudiKernel/GaudiKernel/Property.h +++ b/GaudiKernel/GaudiKernel/Property.h @@ -22,6 +22,8 @@ namespace Gaudi { namespace Details { + class WeekPropertyRef; + // ============================================================================ /** PropertyBase base class allowing PropertyBase* collections to be "homogeneous" * @@ -86,7 +88,7 @@ namespace Gaudi public: /// virtual destructor - virtual ~PropertyBase() = default; + virtual inline ~PropertyBase(); /// set the new value for the property name void setName( std::string value ) { m_name = to_view( std::move( value ) ); } /// set the documentation string @@ -142,8 +144,95 @@ namespace Gaudi const std::type_info* m_typeinfo; /// type of owner of the property (if defined) const std::type_info* m_ownerType = nullptr; + + friend WeekPropertyRef; + std::set m_weekReferences; + void add( WeekPropertyRef* ref ) + { + if ( ref ) m_weekReferences.insert( ref ); + } + void remove( WeekPropertyRef* ref ) { m_weekReferences.erase( ref ); } + }; + + /// Optional reference to a property that can be used to refer to a sting or + /// to the strin representation of a property instance value + class GAUDI_API WeekPropertyRef + { + friend PropertyBase; + + public: + WeekPropertyRef() = default; + WeekPropertyRef( std::string value ) : m_value{std::move( value )}, m_unset{false} {} + WeekPropertyRef( PropertyBase& property ) : m_property{&property} { property.add( this ); } + WeekPropertyRef( const WeekPropertyRef& other ) = delete; + WeekPropertyRef( WeekPropertyRef&& other ) + : m_property{other.m_property}, m_value{std::move( other.m_value )}, m_unset{other.m_unset} + { + if ( m_property ) { + other.m_property = nullptr; + m_property->remove( &other ); + m_property->add( this ); + } + } + ~WeekPropertyRef() + { + if ( m_property ) m_property->remove( this ); + } + WeekPropertyRef& operator=( WeekPropertyRef&& other ) + { + if ( this != &other ) { + if ( m_property ) m_property->remove( this ); + m_property = other.m_property; + other.m_property = nullptr; + if ( m_property ) { + m_property->remove( &other ); + m_property->add( this ); + } + m_value = std::move( other.m_value ); + m_unset = other.m_unset; + } + return *this; + } + WeekPropertyRef& operator=( PropertyBase& value ) + { + if ( m_property != &value ) { + if ( m_property ) { + m_property->remove( this ); + if ( !m_unset ) m_value = m_property->toString(); + } + if ( !m_unset ) value.fromString( m_value ).ignore(); + m_property = &value; + value.add( this ); + } + return *this; + } + WeekPropertyRef& operator=( const std::string& value ) + { + if ( m_property ) m_property->fromString( value ).ignore(); + m_value = value; + m_unset = false; + return *this; + } + operator std::string() const { return m_property ? m_property->toString() : m_value; } + + inline bool isBound() const { return m_property; } + inline bool isSet() const { return !m_unset; } + + private: + PropertyBase* m_property = nullptr; + std::string m_value; + bool m_unset = true; + + void detach() { m_property = nullptr; } }; + inline PropertyBase::~PropertyBase() + { + for ( auto ref : m_weekReferences ) { + ref->detach(); + } + } + inline std::ostream& operator<<( std::ostream& stream, const PropertyBase& prop ) { return prop.fillStream( stream ); diff --git a/GaudiKernel/GaudiKernel/PropertyHolder.h b/GaudiKernel/GaudiKernel/PropertyHolder.h index 2c3abfb218..be04f634f4 100644 --- a/GaudiKernel/GaudiKernel/PropertyHolder.h +++ b/GaudiKernel/GaudiKernel/PropertyHolder.h @@ -285,7 +285,7 @@ public: } ); } // ========================================================================== - /// \fixme property and setPropertiesFrom should be protected + /// \fixme property and bindPropertiesTo should be protected // get local or remote property by name Gaudi::Details::PropertyBase* property( const std::string& name ) const { @@ -302,15 +302,9 @@ public: return nullptr; // RETURN } - void setPropertiesFrom( const Gaudi::Interfaces::IOptionsSvc& optsSvc ) + void bindPropertiesTo( Gaudi::Interfaces::IOptionsSvc& optsSvc ) { - auto set_prop = [&optsSvc, this]( auto prop ) { - const std::string prop_full_name = this->name() + '.' + prop->name(); - if ( optsSvc.has( prop_full_name ) ) { - if ( !prop->fromString( optsSvc.get( prop_full_name ) ) ) - throw std::invalid_argument( "cannot set " + prop->name() + " of " + this->name() ); - } - }; + auto set_prop = [&optsSvc, this]( auto prop ) { optsSvc.bind( this->name(), prop ); }; std::for_each( begin( m_properties ), end( m_properties ), set_prop ); std::for_each( begin( m_remoteProperties ), end( m_remoteProperties ), [&set_prop, this]( auto& rem ) { if ( rem.owner ) set_prop( this->property( rem.remName, rem.owner->getProperties() ) ); diff --git a/GaudiKernel/GaudiKernel/Service.h b/GaudiKernel/GaudiKernel/Service.h index fc5f5dbd90..49e3f67bff 100644 --- a/GaudiKernel/GaudiKernel/Service.h +++ b/GaudiKernel/GaudiKernel/Service.h @@ -76,7 +76,7 @@ public: [[deprecated( "it should not be called explicitely" )]] StatusCode setProperties() { if ( !serviceLocator() ) return StatusCode::FAILURE; - setPropertiesFrom( serviceLocator()->getOptsSvc() ); + bindPropertiesTo( serviceLocator()->getOptsSvc() ); return StatusCode::SUCCESS; } diff --git a/GaudiKernel/src/Lib/Algorithm.cpp b/GaudiKernel/src/Lib/Algorithm.cpp index 12ccf40521..4557f1a14b 100644 --- a/GaudiKernel/src/Lib/Algorithm.cpp +++ b/GaudiKernel/src/Lib/Algorithm.cpp @@ -91,7 +91,7 @@ StatusCode Algorithm::sysInitialize() m_outputLevel.value() = setUpMessaging(); // Set the Algorithm's properties - setPropertiesFrom( serviceLocator()->getOptsSvc() ); + bindPropertiesTo( serviceLocator()->getOptsSvc() ); // Bypass the initialization if the algorithm is disabled. // Need to do this after setProperties. diff --git a/GaudiKernel/src/Lib/Auditor.cpp b/GaudiKernel/src/Lib/Auditor.cpp index 5da920d99f..8aaebdc210 100644 --- a/GaudiKernel/src/Lib/Auditor.cpp +++ b/GaudiKernel/src/Lib/Auditor.cpp @@ -33,7 +33,7 @@ StatusCode Auditor::sysInitialize() m_outputLevel.value() = setUpMessaging(); // Set the Algorithm's properties - setPropertiesFrom( serviceLocator()->getOptsSvc() ); + bindPropertiesTo( serviceLocator()->getOptsSvc() ); if ( !sc.isSuccess() ) return StatusCode::FAILURE; diff --git a/GaudiKernel/src/Lib/Service.cpp b/GaudiKernel/src/Lib/Service.cpp index 55bc2f335b..56d70f1246 100644 --- a/GaudiKernel/src/Lib/Service.cpp +++ b/GaudiKernel/src/Lib/Service.cpp @@ -44,7 +44,7 @@ void Service::sysInitialize_imp() m_outputLevel.value() = setUpMessaging(); } - setPropertiesFrom( serviceLocator()->getOptsSvc() ); + bindPropertiesTo( serviceLocator()->getOptsSvc() ); m_initSC = initialize(); // This should change the state to Gaudi::StateMachine::CONFIGURED if ( m_initSC.isSuccess() ) m_state = m_targetState; diff --git a/GaudiKernel/tests/src/test_WeekPropertyRef.cpp b/GaudiKernel/tests/src/test_WeekPropertyRef.cpp new file mode 100644 index 0000000000..f4f1840e38 --- /dev/null +++ b/GaudiKernel/tests/src/test_WeekPropertyRef.cpp @@ -0,0 +1,133 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE test_PropertyHolder +#include + +#include "GaudiKernel/Property.h" + +struct MyClass { +}; + +using WPR = Gaudi::Details::WeekPropertyRef; + +BOOST_AUTO_TEST_CASE( default_constructor ) +{ + WPR r; + BOOST_CHECK( !r.isBound() ); + BOOST_CHECK( !r.isSet() ); + BOOST_CHECK_EQUAL( std::string{r}, "" ); + r = "42"; + BOOST_CHECK( r.isSet() ); + BOOST_CHECK_EQUAL( std::string{r}, "42" ); +} + +BOOST_AUTO_TEST_CASE( construct_from_string ) +{ + WPR r{"42"}; + BOOST_CHECK( !r.isBound() ); + BOOST_CHECK( r.isSet() ); + BOOST_CHECK_EQUAL( std::string{r}, "42" ); +} + +BOOST_AUTO_TEST_CASE( construct_from_property ) +{ + Gaudi::Property p; + + WPR r{p}; + + BOOST_CHECK( r.isBound() ); + BOOST_CHECK( !r.isSet() ); +} + +BOOST_AUTO_TEST_CASE( assignment ) +{ + { + WPR r; + r = "42"; + BOOST_CHECK( r.isSet() ); + BOOST_CHECK_EQUAL( std::string{r}, "42" ); + } +} + +BOOST_AUTO_TEST_CASE( binding ) +{ + { + Gaudi::Property p; + { + WPR r{p}; + r = "42"; + BOOST_CHECK( r.isSet() ); + BOOST_CHECK_EQUAL( p.value(), 42 ); + } + // it would be nice to check that p knows about r, until r goes out of scope + } + + { + WPR r; + { + Gaudi::Property p; + BOOST_CHECK_EQUAL( p.value(), 0 ); + r = p; + BOOST_CHECK( r.isBound() ); + BOOST_CHECK( !r.isSet() ); + } + BOOST_CHECK( !r.isBound() ); + + r = "42"; + { + Gaudi::Property p; + r = p; + BOOST_CHECK( r.isBound() ); + BOOST_CHECK( r.isSet() ); + BOOST_CHECK_EQUAL( p.value(), 42 ); + + p = 100; + BOOST_CHECK_EQUAL( std::string{r}, "100" ); + } + + BOOST_CHECK_EQUAL( std::string{r}, "42" ); + } +} + +BOOST_AUTO_TEST_CASE( moving ) +{ + { + WPR r; + BOOST_CHECK( !r.isBound() ); + BOOST_CHECK( !r.isSet() ); + BOOST_CHECK_EQUAL( std::string{r}, "" ); + + r = WPR{"42"}; + BOOST_CHECK( !r.isBound() ); + BOOST_CHECK( r.isSet() ); + BOOST_CHECK_EQUAL( std::string{r}, "42" ); + } + { + WPR r{WPR{"42"}}; + BOOST_CHECK( !r.isBound() ); + BOOST_CHECK( r.isSet() ); + BOOST_CHECK_EQUAL( std::string{r}, "42" ); + } + { + Gaudi::Property p{42}; + WPR r{WPR{p}}; + BOOST_CHECK( r.isBound() ); + BOOST_CHECK( !r.isSet() ); + BOOST_CHECK_EQUAL( std::string{r}, "42" ); + } +} + +BOOST_AUTO_TEST_CASE( exceptions ) +{ + { + Gaudi::Property p{42}; + WPR r{p}; + BOOST_CHECK_THROW( r = "'abc'", std::invalid_argument ); + BOOST_CHECK_EQUAL( p.value(), 42 ); + } + { + WPR r{"'abc'"}; + Gaudi::Property p{42}; + BOOST_CHECK_THROW( r = p, std::invalid_argument ); + BOOST_CHECK_EQUAL( p.value(), 42 ); + } +} diff --git a/GaudiPython/python/GaudiPython/Bindings.py b/GaudiPython/python/GaudiPython/Bindings.py index 6c49d4b31f..4399f266e0 100644 --- a/GaudiPython/python/GaudiPython/Bindings.py +++ b/GaudiPython/python/GaudiPython/Bindings.py @@ -1189,37 +1189,8 @@ class AppMgr(iService): if sc.isFailure(): raise RuntimeError, ' Unable to read file "' + tmpfilename + '" ' os.remove(tmpfilename) - # We need to make sure that the options are taken by the ApplicationMgr - # The state is already configured, so we need to do something.... - if self.FSMState() != Gaudi.StateMachine.OFFLINE: - - # get job-options-service, @see class iJobOptSvc - jos = self.optSvc() - - # list of all libraries - _dlls = jos.getProperty(self.name(), 'DLLs') - # take care about libraries : APPEND if not done yet - if _dlls: - libs = [l for l in _dlls if not l in self.DLLs] - if libs: - self.DLLs += libs - - # all external services - _svcs = jos.getProperty(self.name(), 'ExtSvc') - # take care about services : APPEND if not done yet - if _svcs: - svcs = [s for s in _svcs if not s in self.ExtSvc] - if svcs: - self.ExtSvc += svcs - - # get all properties - props = jos.getProperties(self.name()) - # finally treat all other properties (presumably scalar properties) - for key in props: - if 'DLLS' == key or 'EXTSVC' == key: - continue - self.__setattr__(key, props[key]) - return SUCCESS # RETURN + + return SUCCESS def configure(self): return self._appmgr.configure() diff --git a/GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp b/GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp index 47ad864b04..f99d196685 100644 --- a/GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp +++ b/GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp @@ -18,36 +18,6 @@ using Gaudi::MetaDataSvc; -namespace -{ - const auto get_name = []( const auto* i ) { return i->name(); }; - - struct Identity { - template - auto operator()( T&& t ) const -> decltype( auto ) - { - return std::forward( t ); - } - }; - - template - std::string join( Iterator first, Iterator last, Sep sep, Projection proj = {} ) - { - std::string s; - if ( first != last ) s += proj( *first++ ); - for ( ; first != last; ++first ) { - s += sep; - s += proj( *first ); - } - return s; - } - template - std::string join( const Container& c, Sep sep, Projection proj = {} ) - { - return join( begin( c ), end( c ), std::move( sep ), std::move( proj ) ); - } -} - DECLARE_COMPONENT( MetaDataSvc ) StatusCode MetaDataSvc::start() @@ -66,45 +36,6 @@ StatusCode MetaDataSvc::collectData() m_metadata[std::get<0>( p )] = std::get<1>( p ); } - for ( const auto* name : {"ApplicationMgr", "MessageSvc", "NTupleSvc"} ) { - auto svc = service( name ); - if ( !svc.isValid() ) continue; - const auto prefix = name + std::string{"."}; - for ( const auto* prop : svc->getProperties() ) { - m_metadata[prefix + prop->name()] = prop->toString(); - } - } - - /* - * TOOLS - * */ - SmartIF tSvc( serviceLocator()->service( "ToolSvc" ) ); - if ( tSvc.isValid() ) { - m_metadata["ToolSvc"] = join( tSvc->getInstances( "" ), ", " ); - } - - /* - * SERVICES - * */ - m_metadata["ISvcLocator.Services"] = join( serviceLocator()->getServices(), ", ", get_name ); - - /* - * ALGORITHMS - * */ - SmartIF algMan( serviceLocator() ); - m_metadata["IAlgManager.Algorithms"] = join( algMan->getAlgorithms(), ", ", get_name ); - - /* - * JOB OPTIONS SERVICE - * */ - { - auto joSvc = service( "JobOptionsSvc" ); - if ( !joSvc.isValid() ) return StatusCode::FAILURE; - for ( const auto* prop : joSvc->getProperties() ) { - m_metadata["JobOptionsSvc." + prop->name()] = prop->toString(); - } - } - if ( msgLevel( MSG::DEBUG ) ) { debug() << "Metadata collected:\n"; for ( const auto& item : m_metadata ) { -- GitLab From 3cf806063196e0c0e2f54b3a00e5c16e9adde2c4 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Tue, 11 Sep 2018 12:53:23 +0200 Subject: [PATCH 18/53] Add warning about properties set in options, but not used --- .../src/JobOptionsSvc/JobOptionsSvc.cpp | 17 +++++++++++++++++ GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h | 1 + 2 files changed, 18 insertions(+) diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp index ae8d5cfe79..5f88b2e089 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp @@ -48,6 +48,23 @@ StatusCode JobOptionsSvc::initialize() } return sc; } +StatusCode JobOptionsSvc::stop() +{ + std::vector unused; + unused.reserve( m_options.size() ); + + for ( const auto& p : m_options ) { + if ( !p.second.isBound() ) unused.emplace_back( p.first ); + } + + if ( !unused.empty() ) { + auto& log = warning(); + log << unused.size() << " unused properties:"; + for ( const auto& k : unused ) log << "\n - " << k; + log << endmsg; + } + return Service::stop(); +} // ============================================================================ StatusCode JobOptionsSvc::addPropertyToCatalogue( const std::string& client, diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h index 9781e41b9a..f6f7be59a9 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h @@ -103,6 +103,7 @@ public: JobOptionsSvc( const std::string& name, ISvcLocator* svc ); StatusCode initialize() override; + StatusCode stop() override; /** Override default properties of the calling client @param client Name of the client algorithm or service -- GitLab From 2e0a71d237fb5a0cfb0a0c47b5d590696c736a99 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Wed, 12 Sep 2018 16:27:53 +0200 Subject: [PATCH 19/53] Allow declaration of defaults for options matching a regular expression --- .../src/JobOptionsSvc/JobOptionsSvc.cpp | 52 ++++++++++++++++++ .../src/JobOptionsSvc/JobOptionsSvc.h | 23 +++----- .../job_opts_svc.qms/global_defaults.qmt | 53 +++++++++++++++++++ .../tests/qmtest/refs/MetaDataSvc.ref | 1 + .../tests/qmtest/refs/Properties.ref | 1 + .../tests/qmtest/refs/Properties2.ref | 1 + .../tests/qmtest/refs/Properties_py.ref | 1 + GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h | 6 +++ 8 files changed, 122 insertions(+), 16 deletions(-) create mode 100644 GaudiExamples/tests/qmtest/gaudiexamples.qms/job_opts_svc.qms/global_defaults.qmt diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp index 5f88b2e089..80aaae321a 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp @@ -15,6 +15,7 @@ // ============================================================================ #include "GaudiKernel/MsgStream.h" #include "GaudiKernel/System.h" +#include #include @@ -29,6 +30,14 @@ JobOptionsSvc::JobOptionsSvc( const std::string& name, ISvcLocator* svc ) : base { if ( System::isEnvSet( "JOBOPTSEARCHPATH" ) ) m_dir_search_path = System::getEnv( "JOBOPTSEARCHPATH" ); if ( System::isEnvSet( "JOBOPTSDUMPFILE" ) ) m_dump = System::getEnv( "JOBOPTSDUMPFILE" ); + + m_globalDefaultsProp.declareUpdateHandler( [this]( Gaudi::Details::PropertyBase& ) { + m_globalDefaults.clear(); + m_globalDefaults.reserve( m_globalDefaultsProp.size() ); + for ( const auto& p : m_globalDefaultsProp ) { + m_globalDefaults.emplace_back( p.first, p.second ); + } + } ); } // ============================================================================ StatusCode JobOptionsSvc::initialize() @@ -208,3 +217,46 @@ StatusCode JobOptionsSvc::readOptions( const std::string& file, const std::strin // ---------------------------------------------------------------------------- return sc; } + +void JobOptionsSvc::bind( const std::string& prefix, Gaudi::Details::PropertyBase* property ) +{ + const auto key = prefix + '.' + property->name(); + + std::tuple defaultValue{false, ""}; + if ( !has( key ) && !m_globalDefaults.empty() ) { // look for a global default only if it was not set + std::smatch match; + for ( const auto& p : m_globalDefaults ) { + if ( regex_match( key, match, p.first ) ) { + defaultValue = {true, p.second}; + } + } + } + + auto item = find( key, true ); + if ( item != m_options.end() && key != item->first ) { + // Storage is case insensitive, and I want to use the what the property dictates + auto new_item = m_options.emplace( key, std::move( m_options.find( item->first )->second ) ); + m_options.erase( item ); + item = new_item.first; + } + if ( item == m_options.end() ) { + m_options.emplace( key, *property ); + } else { + m_options.find( key )->second = *property; + } + + // at this point the property is bound, so we can set the default if needed + if ( std::get<0>( defaultValue ) ) set( key, std::string{std::get<1>( defaultValue )} ); +} + +void JobOptionsSvc::broadcast( const std::regex& filter, const std::string& value, OnlyDefaults defaults_only ) +{ + std::smatch match; + for ( auto& p : m_options ) { + if ( !defaults_only || !p.second.isSet() ) { + if ( regex_match( p.first, match, filter ) ) { + p.second = value; + } + } + } +} diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h index f6f7be59a9..644cbdb584 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h @@ -79,23 +79,9 @@ protected: std::for_each( begin( m_options ), end( m_options ), [&v]( const auto& item ) { v.emplace_back( item ); } ); return v; } - void bind( const std::string& prefix, Gaudi::Details::PropertyBase* property ) override - { - const auto key = prefix + '.' + property->name(); + void bind( const std::string& prefix, Gaudi::Details::PropertyBase* property ) override; - auto item = find( key, true ); - if ( item != m_options.end() && key != item->first ) { - // Storage is case insensitive, and I want to use the what the property dictates - auto new_item = m_options.emplace( key, std::move( m_options.find( item->first )->second ) ); - m_options.erase( item ); - item = new_item.first; - } - if ( item == m_options.end() ) { - m_options.emplace( key, *property ); - } else { - m_options.find( key )->second = *property; - } - } + void broadcast( const std::regex& filter, const std::string& value, OnlyDefaults defaults_only ) override; /// @} public: @@ -156,5 +142,10 @@ private: Gaudi::Property m_dump{this, "DUMPFILE"}; Gaudi::Property m_pythonAction{this, "PYTHONACTION"}; Gaudi::Property m_pythonParams{this, "PYTHONPARAMS"}; + + Gaudi::Property>> m_globalDefaultsProp{ + this, "GlobalDefaults", {}, "Allow definition of global defaults for properties as list of pairs (regex, value)"}; + + std::vector> m_globalDefaults; }; #endif /* JOBOPTIONSSVC_H_ */ diff --git a/GaudiExamples/tests/qmtest/gaudiexamples.qms/job_opts_svc.qms/global_defaults.qmt b/GaudiExamples/tests/qmtest/gaudiexamples.qms/job_opts_svc.qms/global_defaults.qmt new file mode 100644 index 0000000000..1add0e13e6 --- /dev/null +++ b/GaudiExamples/tests/qmtest/gaudiexamples.qms/job_opts_svc.qms/global_defaults.qmt @@ -0,0 +1,53 @@ + + +gaudirun.py + +from Gaudi.Configuration import * +from Configurables import HelloWorld + +app = ApplicationMgr(EvtSel='NONE', EvtMax=1) + +app.TopAlg=[HelloWorld('alg{}'.format(i)) for i in range(10)] +app.TopAlg[5].OutputLevel = 4 + +JobOptionsSvc(GlobalDefaults=[(r'.*[135]\.OutputLevel$', '1'), + (r'.*[24]\.OutputLevel$', '2'), + ]) + + +findReferenceBlock(''' +alg0 INFO initializing.... +alg1 DEBUG Property update for OutputLevel : new value = 1 +alg1 VERBOSE ServiceLocatorHelper::service: found service EventDataSvc +alg1 VERBOSE ServiceLocatorHelper::service: found service TimelineSvc +alg1 INFO initializing.... +alg1 VERBOSE ServiceLocatorHelper::service: found service AlgExecStateSvc +alg1 DEBUG input handles: 0 +alg1 DEBUG output handles: 0 +alg1 DEBUG Data Deps for alg1 +alg2 DEBUG Property update for OutputLevel : new value = 2 +alg2 INFO initializing.... +alg2 DEBUG input handles: 0 +alg2 DEBUG output handles: 0 +alg2 DEBUG Data Deps for alg2 +alg3 DEBUG Property update for OutputLevel : new value = 1 +alg3 VERBOSE ServiceLocatorHelper::service: found service EventDataSvc +alg3 VERBOSE ServiceLocatorHelper::service: found service TimelineSvc +alg3 INFO initializing.... +alg3 VERBOSE ServiceLocatorHelper::service: found service AlgExecStateSvc +alg3 DEBUG input handles: 0 +alg3 DEBUG output handles: 0 +alg3 DEBUG Data Deps for alg3 +alg4 DEBUG Property update for OutputLevel : new value = 2 +alg4 INFO initializing.... +alg4 DEBUG input handles: 0 +alg4 DEBUG output handles: 0 +alg4 DEBUG Data Deps for alg4 +alg6 INFO initializing.... +alg7 INFO initializing.... +alg8 INFO initializing.... +alg9 INFO initializing.... +''') + +true + diff --git a/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref b/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref index 7af9b68c94..d6720232d7 100644 --- a/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref +++ b/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref @@ -182,6 +182,7 @@ JobOptionsSvc.AuditServices:False JobOptionsSvc.AuditStart:False JobOptionsSvc.AuditStop:False JobOptionsSvc.DUMPFILE:'' +JobOptionsSvc.GlobalDefaults:[ ] JobOptionsSvc.OutputLevel:3 JobOptionsSvc.PATH:'../options/job.opts' JobOptionsSvc.PYTHONACTION:'' diff --git a/GaudiExamples/tests/qmtest/refs/Properties.ref b/GaudiExamples/tests/qmtest/refs/Properties.ref index 4c7bde309d..09f73cca33 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties.ref @@ -285,6 +285,7 @@ JobOptionsSvc.AuditServices: False JobOptionsSvc.AuditStart: False JobOptionsSvc.AuditStop: False JobOptionsSvc.DUMPFILE: '' +JobOptionsSvc.GlobalDefaults: [ ] JobOptionsSvc.OutputLevel: 3 JobOptionsSvc.PATH: '/home/marco/Devel/workspace/Gaudi/GaudiExamples/options/Properties.opts' JobOptionsSvc.PYTHONACTION: '' diff --git a/GaudiExamples/tests/qmtest/refs/Properties2.ref b/GaudiExamples/tests/qmtest/refs/Properties2.ref index 098e759409..e73ce1b3ec 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties2.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties2.ref @@ -287,6 +287,7 @@ JobOptionsSvc.AuditServices: False JobOptionsSvc.AuditStart: False JobOptionsSvc.AuditStop: False JobOptionsSvc.DUMPFILE: '' +JobOptionsSvc.GlobalDefaults: [ ] JobOptionsSvc.OutputLevel: 3 JobOptionsSvc.PATH: '../options/job.opts' JobOptionsSvc.PYTHONACTION: '' diff --git a/GaudiExamples/tests/qmtest/refs/Properties_py.ref b/GaudiExamples/tests/qmtest/refs/Properties_py.ref index 8f144df897..fd09ba7d19 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties_py.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties_py.ref @@ -247,6 +247,7 @@ JobOptionsSvc.AuditServices: False JobOptionsSvc.AuditStart: False JobOptionsSvc.AuditStop: False JobOptionsSvc.DUMPFILE: '' +JobOptionsSvc.GlobalDefaults: [ ] JobOptionsSvc.OutputLevel: 3 JobOptionsSvc.PATH: '../options/job.opts' JobOptionsSvc.PYTHONACTION: '' diff --git a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h index 820302da13..82e0ab3392 100644 --- a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h +++ b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h @@ -1,5 +1,7 @@ #pragma once +#include +#include #include #include #include @@ -51,6 +53,10 @@ namespace Gaudi virtual void bind( const std::string& prefix, Gaudi::Details::PropertyBase* property ) = 0; + using OnlyDefaults = Gaudi::tagged_bool; + virtual void broadcast( const std::regex& filter, const std::string& value, + OnlyDefaults defaults = OnlyDefaults{true} ) = 0; + protected: virtual ~IOptionsSvc() = default; }; -- GitLab From ed0bff768eaaddc8ec64a81cf17e0d584745652f Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Thu, 13 Sep 2018 12:06:37 +0200 Subject: [PATCH 20/53] Use string_view instead of boost::string_ref --- .../src/JobOptionsSvc/JobOptionsSvc.cpp | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp index 80aaae321a..e24a10ed75 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp @@ -17,7 +17,27 @@ #include "GaudiKernel/System.h" #include -#include +#if __cplusplus >= 201703 +#include +#else +#include +namespace std +{ + using experimental::string_view; +} +#endif + +namespace +{ +#if __cplusplus >= 202000 + inline bool starts_with( std::string_view s, std::string_view prefix ) { return s.starts_with( prefix ); } +#else + inline bool starts_with( const std::string_view s, const std::string& prefix ) + { + return s.substr( 0, prefix.size() ) == prefix; + } +#endif +} // ============================================================================ DECLARE_COMPONENT( JobOptionsSvc ) @@ -59,7 +79,7 @@ StatusCode JobOptionsSvc::initialize() } StatusCode JobOptionsSvc::stop() { - std::vector unused; + std::vector unused; unused.reserve( m_options.size() ); for ( const auto& p : m_options ) { @@ -96,11 +116,11 @@ const JobOptionsSvc::PropertiesT* JobOptionsSvc::getProperties( const std::strin const std::string key_base = client + '.'; const auto key_base_size = key_base.size(); for ( const auto& elem : m_options ) { - boost::string_ref key = elem.first; + std::string_view key = elem.first; // for keys that are 'client.name' (and name does not contain '.') // we add an entry to the vector - if ( key.starts_with( key_base ) ) { - boost::string_ref name = key.substr( key_base_size ); + if ( starts_with( key, key_base ) ) { + std::string_view name = key.substr( key_base_size ); if ( name.find( '.' ) == std::string::npos ) { props.push_back( getClientProperty( client, static_cast( name ) ) ); } @@ -117,8 +137,8 @@ StatusCode JobOptionsSvc::setMyProperties( const std::string& client, IProperty* bool fail = false; for ( const auto& elem : m_options ) { - boost::string_ref key = elem.first; - if ( key.starts_with( key_base ) ) { + std::string_view key = elem.first; + if ( starts_with( key, key_base ) ) { const auto name = static_cast( key.substr( key_base_size ) ); // \fixme this has to change if we want nested properties // if ( myInt->hasProperty( name ) ) { @@ -222,7 +242,7 @@ void JobOptionsSvc::bind( const std::string& prefix, Gaudi::Details::PropertyBas { const auto key = prefix + '.' + property->name(); - std::tuple defaultValue{false, ""}; + std::tuple defaultValue{false, ""}; if ( !has( key ) && !m_globalDefaults.empty() ) { // look for a global default only if it was not set std::smatch match; for ( const auto& p : m_globalDefaults ) { -- GitLab From e9d915ffab2d047f726290b9f660bad09f545b8c Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Tue, 25 Sep 2018 16:53:39 +0200 Subject: [PATCH 21/53] Prevent CI failures for too big atifacts --- ci-utils/build | 2 +- ci-utils/test_public_headers_build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci-utils/build b/ci-utils/build index d94048685d..796d443188 100755 --- a/ci-utils/build +++ b/ci-utils/build @@ -9,7 +9,7 @@ if [ -n "${CI}" ] ; then unzip -q artifacts.zip '.ccache/*' || true fi -${LCG_release_area}/ccache/${CCACHE_VERSION}/${BINARY_TAG}/bin/ccache -z +${LCG_release_area}/ccache/${CCACHE_VERSION}/${BINARY_TAG}/bin/ccache -z -M 1G echo 'set(CMAKE_USE_CCACHE ON CACHE BOOL "")' >> cache_preload.cmake echo 'set(clang_format_cmd "'$(which lcg-clang-format-${CLANG_FORMAT_VERSION})'" CACHE FILEPATH "")' >> cache_preload.cmake diff --git a/ci-utils/test_public_headers_build b/ci-utils/test_public_headers_build index 1eb9d4f936..9d0a829830 100755 --- a/ci-utils/test_public_headers_build +++ b/ci-utils/test_public_headers_build @@ -12,6 +12,6 @@ fi # make sure we do not re-run cmake find ${BUILDDIR} -type f -exec touch -d $(date +@%s) \{} \; -${LCG_release_area}/ccache/${CCACHE_VERSION}/${BINARY_TAG}/bin/ccache -z +${LCG_release_area}/ccache/${CCACHE_VERSION}/${BINARY_TAG}/bin/ccache -z -M 1G /usr/bin/time -v make BUILDDIR=${BUILDDIR} test_public_headers_build ${LCG_release_area}/ccache/${CCACHE_VERSION}/${BINARY_TAG}/bin/ccache -s -- GitLab From 0237da8cafd7b402ec59a822c2f7361ba58c6030 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Wed, 3 Oct 2018 17:29:23 +0200 Subject: [PATCH 22/53] Add method to check if an option was explicitly set or not. --- GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h | 6 ++++++ GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h index 644cbdb584..fcb4e0706e 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h @@ -79,6 +79,12 @@ protected: std::for_each( begin( m_options ), end( m_options ), [&v]( const auto& item ) { v.emplace_back( item ); } ); return v; } + bool isSet( const std::string& key ) const override + { + const auto& item = find( key, false ); + return item != m_options.end() && item->second.isSet(); + } + void bind( const std::string& prefix, Gaudi::Details::PropertyBase* property ) override; void broadcast( const std::regex& filter, const std::string& value, OnlyDefaults defaults_only ) override; diff --git a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h index 82e0ab3392..fb179cd63b 100644 --- a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h +++ b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h @@ -47,6 +47,8 @@ namespace Gaudi virtual std::string pop( const std::string& key, const std::string& default_ = {} ) = 0; /// Test if an option key is availble in the catalog. virtual bool has( const std::string& key ) const = 0; + /// Test if an option key was explicitly set or not. + virtual bool isSet( const std::string& key ) const = 0; /// Return all known options with their values. virtual std::vector> items() const = 0; -- GitLab From b7d811f9f86b7a5120b606ddd883ce0b9fee8679 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Thu, 4 Oct 2018 14:11:25 +0200 Subject: [PATCH 23/53] Add JobOptionsSvc unit tests --- GaudiCoreSvc/CMakeLists.txt | 5 +++ GaudiCoreSvc/tests/src/test_JOS.cpp | 59 +++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 GaudiCoreSvc/tests/src/test_JOS.cpp diff --git a/GaudiCoreSvc/CMakeLists.txt b/GaudiCoreSvc/CMakeLists.txt index 3b02be3d8e..1140bc2601 100644 --- a/GaudiCoreSvc/CMakeLists.txt +++ b/GaudiCoreSvc/CMakeLists.txt @@ -26,3 +26,8 @@ gaudi_add_module(GaudiCoreSvc src/AlgExecStateSvc/*.cpp LINK_LIBRARIES GaudiKernel Boost TBB PythonLibs ${extralibs} INCLUDE_DIRS TBB PythonLibs) + +gaudi_add_unit_test(test_JOS tests/src/test_JOS.cpp + LINK_LIBRARIES GaudiKernel TYPE Boost) + +add_dependencies(test_JOS GaudiCoreSvc) diff --git a/GaudiCoreSvc/tests/src/test_JOS.cpp b/GaudiCoreSvc/tests/src/test_JOS.cpp new file mode 100644 index 0000000000..4f4a477dcc --- /dev/null +++ b/GaudiCoreSvc/tests/src/test_JOS.cpp @@ -0,0 +1,59 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE test_JOS +#include + +#include +#include +#include +#include +#include + +#include + +#include + +BOOST_AUTO_TEST_CASE( JobOptionsSvc ) +{ + // Load required libraries (bypass PluginService) + { + System::ImageHandle handle; + System::loadDynamicLib( "libGaudiCoreSvc.so", &handle ); + } + + // == Begin Bootstrap + // Instantiate the application + auto app = Gaudi::createApplicationMgr(); + + SmartIF appProp{app}; + BOOST_REQUIRE( appProp ); + + // prevent reading of options file + appProp->setProperty( "JobOptionsType", "'NONE'" ).ignore(); + // prevent printout of ApplicationMgr banner + appProp->setProperty( "AppName", "''" ).ignore(); + appProp->setProperty( "OutputLevel", "6" ).ignore(); + + BOOST_REQUIRE( app->configure() ); + // == End Bootstrap + + auto& jos = Gaudi::svcLocator()->getOptsSvc(); + + BOOST_CHECK( jos.has( "ApplicationMgr.AppName" ) ); + BOOST_CHECK( !jos.isSet( "ApplicationMgr.AppName" ) ); + BOOST_CHECK( jos.get( "ApplicationMgr.AppName" ) == "''" ); + jos.set( "ApplicationMgr.AppName", "'test_JOS.exe'" ); + BOOST_CHECK( jos.has( "ApplicationMgr.AppName" ) ); + BOOST_CHECK( jos.isSet( "ApplicationMgr.AppName" ) ); + BOOST_CHECK( jos.get( "ApplicationMgr.AppName" ) == "'test_JOS.exe'" ); + + BOOST_CHECK( jos.items().size() == 92 ); + + BOOST_CHECK( !jos.has( "MyAlg.SomeOpt" ) ); + BOOST_CHECK( !jos.isSet( "MyAlg.SomeOpt" ) ); + jos.set( "MyAlg.SomeOpt", "42" ); + BOOST_CHECK( jos.has( "MyAlg.SomeOpt" ) ); + BOOST_CHECK( jos.isSet( "MyAlg.SomeOpt" ) ); + BOOST_CHECK( jos.get( "MyAlg.SomeOpt" ) == "42" ); + + BOOST_CHECK( jos.items().size() == 93 ); +} -- GitLab From 57a3a3a4328cc8ac3cb8a944efb4ea81db07b994 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Thu, 4 Oct 2018 14:34:33 +0200 Subject: [PATCH 24/53] Add filtering versions of IOptionsSvc::items --- GaudiCoreSvc/tests/src/test_JOS.cpp | 2 ++ GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/GaudiCoreSvc/tests/src/test_JOS.cpp b/GaudiCoreSvc/tests/src/test_JOS.cpp index 4f4a477dcc..b28e95873d 100644 --- a/GaudiCoreSvc/tests/src/test_JOS.cpp +++ b/GaudiCoreSvc/tests/src/test_JOS.cpp @@ -56,4 +56,6 @@ BOOST_AUTO_TEST_CASE( JobOptionsSvc ) BOOST_CHECK( jos.get( "MyAlg.SomeOpt" ) == "42" ); BOOST_CHECK( jos.items().size() == 93 ); + BOOST_CHECK( jos.items( [&jos]( const auto& p ) { return jos.isSet( std::get<0>( p ) ); } ).size() == 2 ); + BOOST_CHECK( jos.items( std::regex{".*Level"} ).size() == 5 ); } diff --git a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h index fb179cd63b..84ea789dc4 100644 --- a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h +++ b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h @@ -53,6 +53,22 @@ namespace Gaudi /// Return all known options with their values. virtual std::vector> items() const = 0; + template + std::vector> items( UnaryPredicate predicate ) const + { + auto v = this->items(); + v.erase( std::remove_if( begin( v ), end( v ), + [&predicate]( const auto& element ) { return !predicate( element ); } ), + v.end() ); + return v; + } + std::vector> items( const std::regex& filter ) const + { + std::smatch match; + return items( + [&filter, &match]( const auto& element ) { return regex_match( std::get<0>( element ), match, filter ); } ); + } + virtual void bind( const std::string& prefix, Gaudi::Details::PropertyBase* property ) = 0; using OnlyDefaults = Gaudi::tagged_bool; -- GitLab From d292ebfed6b7bf452a5f857bd9e2ff6f850d572c Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Thu, 4 Oct 2018 17:54:13 +0200 Subject: [PATCH 25/53] Make IOptionsSvc inherit from IInterface --- GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h | 2 +- GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h | 7 ++++--- GaudiKernel/GaudiKernel/ISvcLocator.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h index fcb4e0706e..500f01a3a8 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h @@ -21,7 +21,7 @@ namespace Gaudi } } -class JobOptionsSvc : public extends, virtual public Gaudi::Interfaces::IOptionsSvc +class JobOptionsSvc : public extends { public: typedef std::vector PropertiesT; diff --git a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h index 84ea789dc4..f76406c016 100644 --- a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h +++ b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -35,9 +36,9 @@ namespace Gaudi optsSvc.set("AlgInstanceName.Threshold", "2.345"); \endcode */ - class IOptionsSvc - { - public: + struct IOptionsSvc : virtual public IInterface { + DeclareInterfaceID( IOptionsSvc, 1, 0 ); + /// Set the value of an option, overriding the old value, if any. virtual void set( const std::string& key, const std::string& value ) = 0; /// Get the value of an options, returning the specified _default_ value if not found. diff --git a/GaudiKernel/GaudiKernel/ISvcLocator.h b/GaudiKernel/GaudiKernel/ISvcLocator.h index 0bb0fd6959..a7c4a7a1c0 100644 --- a/GaudiKernel/GaudiKernel/ISvcLocator.h +++ b/GaudiKernel/GaudiKernel/ISvcLocator.h @@ -17,7 +17,7 @@ namespace Gaudi { namespace Interfaces { - class IOptionsSvc; + struct IOptionsSvc; } } #define GAUDI_HAS_IOPTIONS_SVC -- GitLab From 619d086adbc563e71b040d3235c411d093167b4c Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Thu, 4 Oct 2018 18:04:19 +0200 Subject: [PATCH 26/53] Update Doxygen documentation --- GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h | 28 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h index f76406c016..60c56ed95c 100644 --- a/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h +++ b/GaudiKernel/Gaudi/Interfaces/IOptionsSvc.h @@ -37,6 +37,7 @@ namespace Gaudi \endcode */ struct IOptionsSvc : virtual public IInterface { + /// InterfaceID declaration. DeclareInterfaceID( IOptionsSvc, 1, 0 ); /// Set the value of an option, overriding the old value, if any. @@ -46,14 +47,17 @@ namespace Gaudi /// Get the value of an options, removing it from the storage, returning the specified _default_ value if not /// found. virtual std::string pop( const std::string& key, const std::string& default_ = {} ) = 0; - /// Test if an option key is availble in the catalog. + /// %Test if an option key is availble in the catalog. virtual bool has( const std::string& key ) const = 0; - /// Test if an option key was explicitly set or not. + /// %Test if an option key was explicitly set or not. virtual bool isSet( const std::string& key ) const = 0; - /// Return all known options with their values. + /// @name Methods to query options. + /// These methods allow to extract the list of know options with their values. + /// @{ + /** Return all known options with their values. */ virtual std::vector> items() const = 0; - + /** Return all known options with their values for which `predicate` evaluates to true. */ template std::vector> items( UnaryPredicate predicate ) const { @@ -63,16 +67,32 @@ namespace Gaudi v.end() ); return v; } + /** Return all known options with their values for which the key matches the given regular expression. */ std::vector> items( const std::regex& filter ) const { std::smatch match; return items( [&filter, &match]( const auto& element ) { return regex_match( std::get<0>( element ), match, filter ); } ); } + /// @} + /// Register a Gaudi::Property instance to the option service. + /// + /// The option will be bound to the property with name `.`, and immediately + /// assigned the value set in the options service, if any. + /// + /// After the binding, setting a property value via IOptionsSvc::set will automatically set the value + /// of the Gaudi::Property instance, and IOptionsSvc::get will return the string representation of the + /// value of the Gaudi::Property instance. virtual void bind( const std::string& prefix, Gaudi::Details::PropertyBase* property ) = 0; using OnlyDefaults = Gaudi::tagged_bool; + + /// Broadcast version of IOptionsSvc::set. + /// + /// With IOptionsSvc::broadcast it is possible to assign one value to all known properties matching a + /// regular expression. By default, only default values are overridden, but explicitly assigned values + /// can also be overridden passing `OnlyDefaults{false}` as third argument to the method. virtual void broadcast( const std::regex& filter, const std::string& value, OnlyDefaults defaults = OnlyDefaults{true} ) = 0; -- GitLab From c1831c47ada69e186197e93fdf8964486cccee10 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Fri, 5 Oct 2018 10:27:23 +0200 Subject: [PATCH 27/53] Rename JobOptionsSvc::find to i_find to clarify it's not std::find --- GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp | 4 ++-- GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp index e24a10ed75..4e3949d747 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp @@ -156,7 +156,7 @@ StatusCode JobOptionsSvc::setMyProperties( const std::string& client, IProperty* return fail ? StatusCode::FAILURE : StatusCode::SUCCESS; } -JobOptionsSvc::StorageType::const_iterator JobOptionsSvc::find( const std::string& key, bool warn ) const +JobOptionsSvc::StorageType::const_iterator JobOptionsSvc::i_find( const std::string& key, bool warn ) const { StorageType::const_iterator iter = m_options.find( key ); if ( iter == m_options.end() ) { // try case insensitive lookup @@ -252,7 +252,7 @@ void JobOptionsSvc::bind( const std::string& prefix, Gaudi::Details::PropertyBas } } - auto item = find( key, true ); + auto item = i_find( key, true ); if ( item != m_options.end() && key != item->first ) { // Storage is case insensitive, and I want to use the what the property dictates auto new_item = m_options.emplace( key, std::move( m_options.find( item->first )->second ) ); diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h index 500f01a3a8..a4076c27dd 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.h @@ -36,13 +36,13 @@ private: /// Find an option key in the options storage using case insensitive comparison. /// If the found key does not match the case of the requested one, a warning is printed. - StorageType::const_iterator find( const std::string& key, bool warn ) const; + StorageType::const_iterator i_find( const std::string& key, bool warn ) const; protected: /// @{ void set( const std::string& key, const std::string& value ) override { - auto item = find( key, true ); + auto item = i_find( key, true ); if ( item != m_options.end() && key != item->first ) { if ( !item->second.isBound() ) { // do not remove references to properties m_options.erase( item ); // Storage is case insensitive, and I want to use the latest version of the case @@ -57,21 +57,21 @@ protected: } std::string get( const std::string& key, const std::string& default_ = {} ) const override { - auto item = find( key, true ); + auto item = i_find( key, true ); return item != m_options.end() ? std::string{item->second} : default_; } std::string pop( const std::string& key, const std::string& default_ = {} ) override { std::string result = default_; - auto item = find( key, true ); + auto item = i_find( key, true ); if ( item != m_options.end() ) { result = std::move( item->second ); m_options.erase( item ); } return result; } - bool has( const std::string& key ) const override { return find( key, false ) != m_options.end(); } + bool has( const std::string& key ) const override { return i_find( key, false ) != m_options.end(); } std::vector> items() const override { std::vector> v; @@ -81,7 +81,7 @@ protected: } bool isSet( const std::string& key ) const override { - const auto& item = find( key, false ); + const auto& item = i_find( key, false ); return item != m_options.end() && item->second.isSet(); } -- GitLab From 7f0606b6eb27c9c1f3e357674174092fdac59ab2 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Fri, 5 Oct 2018 23:11:34 +0200 Subject: [PATCH 28/53] Backward compatibility hack to hide changed behaviour of Property --- .../src/JobOptionsSvc/JobOptionsSvc.cpp | 9 ++- GaudiCoreSvc/tests/src/test_JOS.cpp | 73 ++++++++++++++----- GaudiKernel/GaudiKernel/Property.h | 3 + GaudiKernel/tests/src/test_Property.cpp | 19 +++++ GaudiPolicy/python/GaudiTesting/BaseTest.py | 2 + 5 files changed, 87 insertions(+), 19 deletions(-) diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp index 4e3949d747..bc948185a1 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp @@ -99,7 +99,14 @@ StatusCode JobOptionsSvc::stop() StatusCode JobOptionsSvc::addPropertyToCatalogue( const std::string& client, const Gaudi::Details::PropertyBase& property ) { - set( client + '.' + property.name(), property.toString() ); + if ( property.type_info() == &typeid( std::string ) ) { + // relatively convoluted way to strip unneeded quotes. + Gaudi::Property tmp; + tmp.assign( property ); + set( client + '.' + property.name(), tmp.value() ); + } else { + set( client + '.' + property.name(), property.toString() ); + } return StatusCode::SUCCESS; } // ============================================================================ diff --git a/GaudiCoreSvc/tests/src/test_JOS.cpp b/GaudiCoreSvc/tests/src/test_JOS.cpp index b28e95873d..b3a79995ea 100644 --- a/GaudiCoreSvc/tests/src/test_JOS.cpp +++ b/GaudiCoreSvc/tests/src/test_JOS.cpp @@ -4,37 +4,48 @@ #include #include +#include #include #include +#include #include #include #include -BOOST_AUTO_TEST_CASE( JobOptionsSvc ) -{ - // Load required libraries (bypass PluginService) +struct Fixture { + Fixture() { - System::ImageHandle handle; - System::loadDynamicLib( "libGaudiCoreSvc.so", &handle ); - } + // Load required libraries (bypass PluginService) + { + System::ImageHandle handle; + System::loadDynamicLib( "libGaudiCoreSvc.so", &handle ); + } - // == Begin Bootstrap - // Instantiate the application - auto app = Gaudi::createApplicationMgr(); + // == Begin Bootstrap + // Instantiate the application + auto app = Gaudi::createApplicationMgr(); - SmartIF appProp{app}; - BOOST_REQUIRE( appProp ); + SmartIF appProp{app}; + BOOST_REQUIRE( appProp ); - // prevent reading of options file - appProp->setProperty( "JobOptionsType", "'NONE'" ).ignore(); - // prevent printout of ApplicationMgr banner - appProp->setProperty( "AppName", "''" ).ignore(); - appProp->setProperty( "OutputLevel", "6" ).ignore(); + // prevent reading of options file + appProp->setProperty( "JobOptionsType", "'NONE'" ).ignore(); + // prevent printout of ApplicationMgr banner + appProp->setProperty( "AppName", "''" ).ignore(); + appProp->setProperty( "OutputLevel", "6" ).ignore(); + + BOOST_REQUIRE( app->configure() ); + // == End Bootstrap + } - BOOST_REQUIRE( app->configure() ); - // == End Bootstrap + ~Fixture() {} +}; + +BOOST_AUTO_TEST_CASE( JobOptionsSvc ) +{ + Fixture f; auto& jos = Gaudi::svcLocator()->getOptsSvc(); @@ -59,3 +70,29 @@ BOOST_AUTO_TEST_CASE( JobOptionsSvc ) BOOST_CHECK( jos.items( [&jos]( const auto& p ) { return jos.isSet( std::get<0>( p ) ); } ).size() == 2 ); BOOST_CHECK( jos.items( std::regex{".*Level"} ).size() == 5 ); } + +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +BOOST_AUTO_TEST_CASE( BackwardCompatibility ) +{ + Fixture f; + + auto& jos_new = Gaudi::svcLocator()->getOptsSvc(); + auto jos = Gaudi::svcLocator()->service( "JobOptionsSvc" ).as(); + BOOST_REQUIRE( jos ); + + { + Gaudi::Property bp{true}; + std::string bpv = bp.toString(); + Gaudi::Property sp( "MeasureTime", bpv ); + jos->addPropertyToCatalogue( "SomeClient", sp ); + BOOST_CHECK( jos_new.get( "SomeClient.MeasureTime" ) == "True" ); + } + + { + jos_new.set( "Parent.SomeNumber", "42" ); + auto p = jos->getClientProperty( "Parent", "SomeNumber" ); + BOOST_REQUIRE( p ); + jos->addPropertyToCatalogue( "Parent.Child", *p ); + BOOST_CHECK( jos_new.get( "Parent.Child.SomeNumber" ) == "42" ); + } +} diff --git a/GaudiKernel/GaudiKernel/Property.h b/GaudiKernel/GaudiKernel/Property.h index 80c0db0bc0..f8ec87f5c8 100644 --- a/GaudiKernel/GaudiKernel/Property.h +++ b/GaudiKernel/GaudiKernel/Property.h @@ -789,6 +789,9 @@ namespace Gaudi ( std::is_same::value ) ? nullptr : dynamic_cast( &source ); if ( p ) { *this = p->value(); + } else if ( source.type_info() == &typeid( std::string ) ) { + auto s = dynamic_cast*>( &source ); + this->fromString( s->value() ).ignore(); } else { this->fromString( source.toString() ).ignore(); } diff --git a/GaudiKernel/tests/src/test_Property.cpp b/GaudiKernel/tests/src/test_Property.cpp index 477fc9db0b..b0c3c22d4a 100644 --- a/GaudiKernel/tests/src/test_Property.cpp +++ b/GaudiKernel/tests/src/test_Property.cpp @@ -198,4 +198,23 @@ BOOST_AUTO_TEST_CASE( backward_compatibility ) BOOST_CHECK( ip.updateCallBack() ); BOOST_CHECK( p->updateCallBack() ); } + + { + Gaudi::Property p{"OutputLevel", "6"}; + Gaudi::Property i; + i.assign( p ); + BOOST_CHECK( i.value() == 6 ); + } + { + Gaudi::Property p{"OutputLevel", 6}; + Gaudi::Property i; + i.assign( p ); + BOOST_CHECK( i.value() == 6 ); + } + { + Gaudi::Property p{"OutputLevel", "6"}; + Gaudi::Property i; + i.assign( p ); + BOOST_CHECK( i.value() == "6" ); + } } diff --git a/GaudiPolicy/python/GaudiTesting/BaseTest.py b/GaudiPolicy/python/GaudiTesting/BaseTest.py index b0acf7071d..1a9dc230fa 100644 --- a/GaudiPolicy/python/GaudiTesting/BaseTest.py +++ b/GaudiPolicy/python/GaudiTesting/BaseTest.py @@ -902,6 +902,8 @@ lineSkipper = LineSkipper(["//GP:", 'SIGXCPU', # Message removed with redesing of JobOptionsSvc 'ServiceLocatorHelper::service: found service JobOptionsSvc', + # Ignore warnings for properties case mismatch + 'mismatching case for property name:', ], regexps=[ r"^JobOptionsSvc INFO *$", r"^# ", # Ignore python comments -- GitLab From 3820c88213e388d625e011c47af093ca9fd3c707 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Mon, 8 Oct 2018 14:05:14 +0200 Subject: [PATCH 29/53] Postpone deprecation warnings to Gaudi v30r5 schedule IJobOptionsSvc to be removed in Gaudi v31r0 --- GaudiKernel/Gaudi/DeprecationHelpers.h | 10 +++++++ GaudiKernel/GaudiKernel/AlgTool.h | 3 +- GaudiKernel/GaudiKernel/Algorithm.h | 3 +- GaudiKernel/GaudiKernel/Auditor.h | 3 +- GaudiKernel/GaudiKernel/IJobOptionsSvc.h | 35 ++++++++++++++++-------- GaudiKernel/GaudiKernel/JobHistory.h | 4 ++- GaudiKernel/GaudiKernel/Service.h | 3 +- 7 files changed, 44 insertions(+), 17 deletions(-) create mode 100644 GaudiKernel/Gaudi/DeprecationHelpers.h diff --git a/GaudiKernel/Gaudi/DeprecationHelpers.h b/GaudiKernel/Gaudi/DeprecationHelpers.h new file mode 100644 index 0000000000..daccedbc49 --- /dev/null +++ b/GaudiKernel/Gaudi/DeprecationHelpers.h @@ -0,0 +1,10 @@ +#pragma once +/** @file Declaration of preprocessor macros to help schedule deprecations. */ + +#include + +#if GAUDI_VERSION >= CALC_GAUDI_VERSION( 30, 5 ) && GAUDI_MAJOR_VERSION < 999 +#define GAUDI_DEPRECATED_SINCE_v30r5( REASON ) [[deprecated( REASON )]] +#else +#define GAUDI_DEPRECATED_SINCE_v30r5( REASON ) +#endif diff --git a/GaudiKernel/GaudiKernel/AlgTool.h b/GaudiKernel/GaudiKernel/AlgTool.h index 88f58e4031..834394d785 100644 --- a/GaudiKernel/GaudiKernel/AlgTool.h +++ b/GaudiKernel/GaudiKernel/AlgTool.h @@ -16,6 +16,7 @@ #include "GaudiKernel/IToolSvc.h" #include "GaudiKernel/PropertyHolder.h" #include "GaudiKernel/ToolHandle.h" +#include #include #include "GaudiKernel/DataHandle.h" @@ -118,7 +119,7 @@ public: /// The standard ToolSvc service, Return a pointer to the service if present IToolSvc* toolSvc() const; - [[deprecated( "it should not be called explicitely" )]] StatusCode setProperties() + GAUDI_DEPRECATED_SINCE_v30r5( "it should not be called explicitely" ) StatusCode setProperties() { if ( !serviceLocator() ) return StatusCode::FAILURE; bindPropertiesTo( serviceLocator()->getOptsSvc() ); diff --git a/GaudiKernel/GaudiKernel/Algorithm.h b/GaudiKernel/GaudiKernel/Algorithm.h index c089fcd4b7..56c49a7512 100644 --- a/GaudiKernel/GaudiKernel/Algorithm.h +++ b/GaudiKernel/GaudiKernel/Algorithm.h @@ -34,6 +34,7 @@ #include "GaudiKernel/PropertyHolder.h" #include "GaudiKernel/System.h" #include "GaudiKernel/ToolHandle.h" +#include #include // For concurrency @@ -353,7 +354,7 @@ public: /// List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms std::vector* subAlgorithms(); - [[deprecated( "it should not be called explicitely" )]] StatusCode setProperties() + GAUDI_DEPRECATED_SINCE_v30r5( "it should not be called explicitely" ) StatusCode setProperties() { if ( !serviceLocator() ) return StatusCode::FAILURE; bindPropertiesTo( serviceLocator()->getOptsSvc() ); diff --git a/GaudiKernel/GaudiKernel/Auditor.h b/GaudiKernel/GaudiKernel/Auditor.h index fcb7d70491..7db495f992 100644 --- a/GaudiKernel/GaudiKernel/Auditor.h +++ b/GaudiKernel/GaudiKernel/Auditor.h @@ -9,6 +9,7 @@ #include "GaudiKernel/ISvcLocator.h" /*used by service(..)*/ #include "GaudiKernel/PropertyFwd.h" #include "GaudiKernel/PropertyHolder.h" +#include #include #include #include @@ -122,7 +123,7 @@ public: return serviceLocator()->service( name, createIf ); } - [[deprecated( "it should not be called explicitely" )]] StatusCode setProperties() + GAUDI_DEPRECATED_SINCE_v30r5( "it should not be called explicitely" ) StatusCode setProperties() { if ( !serviceLocator() ) return StatusCode::FAILURE; bindPropertiesTo( serviceLocator()->getOptsSvc() ); diff --git a/GaudiKernel/GaudiKernel/IJobOptionsSvc.h b/GaudiKernel/GaudiKernel/IJobOptionsSvc.h index 77f77e98c0..da9c5966e5 100644 --- a/GaudiKernel/GaudiKernel/IJobOptionsSvc.h +++ b/GaudiKernel/GaudiKernel/IJobOptionsSvc.h @@ -1,9 +1,10 @@ #ifndef KERNEL_IJOBOPTIONSSVC_H #define KERNEL_IJOBOPTIONSSVC_H - // Include files #include "GaudiKernel/IInterface.h" #include "GaudiKernel/PropertyFwd.h" +#include + #include #include @@ -11,6 +12,14 @@ class StatusCode; class IProperty; +#if GAUDI_MAJOR_VERSION < 999 +#if GAUDI_VERSION >= CALC_GAUDI_VERSION( 31, 0 ) +#error "deprecated header: to be removed in v31r0" +#elif GAUDI_VERSION >= CALC_GAUDI_VERSION( 30, 5 ) +#warning "deprecated header: to be removed in v31r0" +#endif +#endif + /** @class IJobOptionsSvc IJobOptionsSvc.h GaudiKernel/IJobOptionsSvc.h Main interface for the JobOptions service @@ -27,24 +36,25 @@ public: @param client Name of the client algorithm or service @param me Address of the interface IProperty of the client */ - [[deprecated]] virtual StatusCode setMyProperties( const std::string& client, IProperty* me ) = 0; + GAUDI_DEPRECATED_SINCE_v30r5( "will be removed" ) virtual StatusCode + setMyProperties( const std::string& client, IProperty* me ) = 0; /// Add a property into the JobOptions catalog - [[deprecated]] virtual StatusCode addPropertyToCatalogue( const std::string& client, - const Gaudi::Details::PropertyBase& property ) = 0; + GAUDI_DEPRECATED_SINCE_v30r5( "will be removed" ) virtual StatusCode + addPropertyToCatalogue( const std::string& client, const Gaudi::Details::PropertyBase& property ) = 0; /// Remove a property from the JobOptions catalog - [[deprecated]] virtual StatusCode removePropertyFromCatalogue( const std::string& client, - const std::string& name ) = 0; + GAUDI_DEPRECATED_SINCE_v30r5( "will be removed" ) virtual StatusCode + removePropertyFromCatalogue( const std::string& client, const std::string& name ) = 0; /// Get the properties associated to a given client - [[deprecated]] virtual const std::vector* - getProperties( const std::string& client ) const = 0; + GAUDI_DEPRECATED_SINCE_v30r5( "will be removed" ) virtual const + std::vector* getProperties( const std::string& client ) const = 0; /// Get a property for a client - [[deprecated]] virtual const Gaudi::Details::PropertyBase* getClientProperty( const std::string& client, - const std::string& name ) const = 0; + GAUDI_DEPRECATED_SINCE_v30r5( "will be removed" ) virtual const Gaudi::Details::PropertyBase* getClientProperty( + const std::string& client, const std::string& name ) const = 0; /// Get the list of clients - [[deprecated]] virtual std::vector getClients() const = 0; + GAUDI_DEPRECATED_SINCE_v30r5( "will be removed" ) virtual std::vector getClients() const = 0; /** look for file 'File' into search path 'Path' * and read it to update existing JobOptionsCatalogue @@ -52,7 +62,8 @@ public: * @param Path search path * @return status code */ - [[deprecated]] virtual StatusCode readOptions( const std::string& file, const std::string& path = "" ) = 0; + GAUDI_DEPRECATED_SINCE_v30r5( "will be removed" ) virtual StatusCode + readOptions( const std::string& file, const std::string& path = "" ) = 0; }; #endif // KERNEL_IJOBOPTIONSSVC_H diff --git a/GaudiKernel/GaudiKernel/JobHistory.h b/GaudiKernel/GaudiKernel/JobHistory.h index f95b20dc37..e92e95d862 100644 --- a/GaudiKernel/GaudiKernel/JobHistory.h +++ b/GaudiKernel/GaudiKernel/JobHistory.h @@ -5,6 +5,7 @@ #include "GaudiKernel/HistoryObj.h" #include "GaudiKernel/IVersHistoryObj.h" #include "GaudiKernel/Property.h" +#include #include #include @@ -58,7 +59,8 @@ public: // functions static const CLID& classID(); // add a global property - [[deprecated]] void addProperty( const std::string&, const Gaudi::Details::PropertyBase* ); + GAUDI_DEPRECATED_SINCE_v30r5( "use addProperty( string, string ) instead" ) void addProperty( + const std::string&, const Gaudi::Details::PropertyBase* ); void addProperty( const std::string& key, const std::string& value ); // Return the job history data. diff --git a/GaudiKernel/GaudiKernel/Service.h b/GaudiKernel/GaudiKernel/Service.h index 49e3f67bff..1b4d6f745c 100644 --- a/GaudiKernel/GaudiKernel/Service.h +++ b/GaudiKernel/GaudiKernel/Service.h @@ -14,6 +14,7 @@ #include "GaudiKernel/ServiceLocatorHelper.h" #include "GaudiKernel/SmartIF.h" #include "GaudiKernel/ToolHandle.h" +#include #include // ============================================================================ @@ -73,7 +74,7 @@ public: /** Retrieve pointer to service locator */ SmartIF& serviceLocator() const override; - [[deprecated( "it should not be called explicitely" )]] StatusCode setProperties() + GAUDI_DEPRECATED_SINCE_v30r5( "it should not be called explicitely" ) StatusCode setProperties() { if ( !serviceLocator() ) return StatusCode::FAILURE; bindPropertiesTo( serviceLocator()->getOptsSvc() ); -- GitLab From a8c9af8b10840bef6c4ed7e0a6e1ba45cec8366a Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Wed, 10 Oct 2018 09:28:57 +0200 Subject: [PATCH 30/53] temporary! avoid c++gsl --- GaudiKernel/src/Lib/ISvcLocator.cpp | 6 ++++-- GaudiPython/python/GaudiPython/Bindings.py | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/GaudiKernel/src/Lib/ISvcLocator.cpp b/GaudiKernel/src/Lib/ISvcLocator.cpp index e6950eb1e5..5337d2f584 100644 --- a/GaudiKernel/src/Lib/ISvcLocator.cpp +++ b/GaudiKernel/src/Lib/ISvcLocator.cpp @@ -2,10 +2,12 @@ #include "Gaudi/Interfaces/IOptionsSvc.h" -#include +#include Gaudi::Interfaces::IOptionsSvc& ISvcLocator::getOptsSvc() { using namespace Gaudi::Interfaces; - return *gsl::not_null( dynamic_cast( service( "JobOptionsSvc" ).get() ) ); + auto p = dynamic_cast( service( "JobOptionsSvc" ).get() ); + if ( !p ) throw std::runtime_error( "cannot dynamic_cast JobOptionsSvc to IOptionsSvc*" ); + return *p; } diff --git a/GaudiPython/python/GaudiPython/Bindings.py b/GaudiPython/python/GaudiPython/Bindings.py index 4399f266e0..0dddfd84be 100644 --- a/GaudiPython/python/GaudiPython/Bindings.py +++ b/GaudiPython/python/GaudiPython/Bindings.py @@ -57,14 +57,15 @@ SUCCESS = gbl.StatusCode(gbl.StatusCode.SUCCESS, True) FAILURE = gbl.StatusCode(gbl.StatusCode.FAILURE, True) # Helper to create a StringProperty cppyy.gbl.gInterpreter.Declare(''' -#include +#include namespace GaudiPython { namespace Helpers { Gaudi::Property mkStringProperty(const std::string &name, const std::string &value) { return Gaudi::Property{name, value}; } void setProperty(ISvcLocator* svcLoc, std::string key, std::string value) { - gsl::not_null(svcLoc)->getOptsSvc().set(key, value); + if ( !svcLoc ) throw std::runtime_error( "invalid ISvcLocator pointer" ); + svcLoc->getOptsSvc().set(key, value); } }} ''') -- GitLab From dffad856d5c3127cf8fbbbea2e08947f1e0410af Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Fri, 19 Oct 2018 07:33:00 +0200 Subject: [PATCH 31/53] Minor fix to printout of TimelineSvc --- GaudiHive/src/TimelineSvc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GaudiHive/src/TimelineSvc.cpp b/GaudiHive/src/TimelineSvc.cpp index ab9fd58fff..3ed066361e 100644 --- a/GaudiHive/src/TimelineSvc.cpp +++ b/GaudiHive/src/TimelineSvc.cpp @@ -41,7 +41,7 @@ StatusCode TimelineSvc::finalize() if ( m_dumpTimeline && m_events.size() > 0 ) { MsgStream log( msgSvc(), name() ); - log << MSG::INFO << "Outputting timeline with " << m_events.size() << " entries to file " << m_timelineFile + log << MSG::INFO << "Outputting timeline with " << m_events.size() << " entries to file " << m_timelineFile.value() << endmsg; outputTimeline(); -- GitLab From 8013cce131b17aa253eb99ea57ba223d994fe5c6 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Wed, 25 Oct 2017 12:26:12 +0200 Subject: [PATCH 32/53] Prototype of a new interface for logging --- GaudiKernel/CMakeLists.txt | 2 + GaudiKernel/Gaudi/Logging.h | 229 ++++++++++++++++++ GaudiKernel/Gaudi/details/LoggingTraits.h | 22 ++ .../tests/qmtest/gaudikernel.qms/logging.qmt | 7 + GaudiKernel/tests/qmtest/refs/Logging.err.ref | 15 ++ GaudiKernel/tests/qmtest/refs/Logging.ref | 31 +++ GaudiKernel/tests/src/test_Logging.cpp | 84 +++++++ 7 files changed, 390 insertions(+) create mode 100644 GaudiKernel/Gaudi/Logging.h create mode 100644 GaudiKernel/Gaudi/details/LoggingTraits.h create mode 100644 GaudiKernel/tests/qmtest/gaudikernel.qms/logging.qmt create mode 100644 GaudiKernel/tests/qmtest/refs/Logging.err.ref create mode 100644 GaudiKernel/tests/qmtest/refs/Logging.ref create mode 100644 GaudiKernel/tests/src/test_Logging.cpp diff --git a/GaudiKernel/CMakeLists.txt b/GaudiKernel/CMakeLists.txt index cb9ed4fe69..166594b14c 100644 --- a/GaudiKernel/CMakeLists.txt +++ b/GaudiKernel/CMakeLists.txt @@ -172,6 +172,8 @@ gaudi_add_unit_test(test_reverse tests/src/test_reverse.cpp gaudi_add_compile_test(test_StatusCodeFail tests/src/test_StatusCode_fail.cxx ERRORS "FAIL01;FAIL02;FAIL03;FAIL04") +add_executable( test_Logging tests/src/test_Logging.cpp ) + #---Dictionaries------------------------------------------------------------ gaudi_add_dictionary(GaudiKernel dict/dictionary.h dict/dictionary.xml LINK_LIBRARIES GaudiKernel) diff --git a/GaudiKernel/Gaudi/Logging.h b/GaudiKernel/Gaudi/Logging.h new file mode 100644 index 0000000000..549e4c32b8 --- /dev/null +++ b/GaudiKernel/Gaudi/Logging.h @@ -0,0 +1,229 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "Gaudi/details/LoggingTraits.h" + +#include "GaudiKernel/Kernel.h" + +namespace Gaudi +{ + template + class Logger; + + class Logging + { + public: + enum class Level { VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS }; + static const std::string& levelName( Level l ) + { + const static std::array names = {"VERBOSE", "DEBUG", "INFO", "WARNING", + "ERROR", "FATAL", "ALWAYS"}; + return names[static_cast>( l )]; + } + + struct Link { + Link() {} + Link( Logging* logging_ ) : logging{logging_} {} + + Link( const Link& ) = delete; + Link& operator=( const Link& ) = delete; + + ~Link() + { + if ( logging ) logging->unregister( this ); + logging = nullptr; + } + + Logging* logging = nullptr; + Level level = Level::INFO; + + inline bool enabled( const Level l ) const { return UNLIKELY( logging && ( l >= level ) ); } + + inline Logging* operator->() const + { + assert( logging ); + return logging; + } + }; + + static constexpr const class + { + public: + template + inline std::string operator()( ARGS&&... args ) const + { + std::stringstream out; + return _impl( out, std::forward( args )... ); + } + + private: + inline std::string _impl( std::stringstream& out ) const { return out.str(); } + + template + inline std::string _impl( std::stringstream& out, ARG&& arg, ARGS&&... args ) const + { + out << arg; + return _impl( out, std::forward( args )... ); + } + } Streamer{}; + + struct Backend { + virtual ~Backend() = default; + virtual void process( std::string msg ) const = 0; + }; + + struct DefaultBackend : Backend { + void process( std::string msg ) const override { std::cout << msg << '\n'; } + }; + + Logging() = default; + Logging( std::unique_ptr b ) { setBackend( std::move( b ) ); } + + std::unique_ptr setBackend( std::unique_ptr b ) + { + auto old_backend = std::move( m_backend ); + m_backend = b ? std::move( b ) : std::make_unique(); + return old_backend; + } + + template ::value>> + void log( const Level l, const SOURCE s, std::string msg ) const + { + if ( !( true /* || traits.enabled( s, l ) */ ) ) return; + i_log( l, s, std::move( msg ) ); + } + + void log( const Level l, std::string s, std::string msg ) const + { + if ( !( true /* || traits.enabled( s, l ) */ ) ) return; + i_log( l, std::move( s ), std::move( msg ) ); + } + + template ::value>> + void log( const Level l, const std::string s, const FORMATTER& formatter, ARGS&&... args ) const + { + if ( !( true /* || traits.enabled( s, l ) */ ) ) return; + i_log( l, std::move( s ), formatter( std::forward( args )... ) ); + } + + template ::value>, + typename = std::enable_if_t::value>> + void log( const Level l, const SOURCE s, const FORMATTER& formatter, ARGS&&... args ) const + { + if ( !( true /* || traits.enabled( s, l ) */ ) ) return; + i_log( l, s, formatter( std::forward( args )... ) ); + } + + template + void registerLogger( Logger& logger ) + { + logger.m_logging.logging = this; + m_loggers.emplace_back( &logger.m_logging ); + } + + void unregister( Link* link ) + { + log( Level::VERBOSE, "Gaudi::Logging", [link]() -> std::string { + std::stringstream out; + out << "unregistering " << link; + return out.str(); + } ); + auto pos = find( begin( m_loggers ), end( m_loggers ), link ); + if ( pos != end( m_loggers ) ) { + m_loggers.erase( pos ); + } + } + + ~Logging() + { + for ( auto& link : m_loggers ) { + link->logging = nullptr; + } + } + + private: + template + void i_log( const Level l, const SOURCE s, std::string msg ) const + { + using Traits = details::LoggingTraits; + // FIXME use https://stackoverflow.com/a/28001459 + std::vector lines; + boost::algorithm::split( lines, msg, []( char c ) { return c == '\n'; } ); + for ( const auto& line : lines ) { + std::stringstream data; + data << std::setw( 20 ) << std::left << Traits::getName( s ) << ' ' << std::setw( 8 ) << levelName( l ) << line; + m_backend->process( data.str() ); + } + } + + std::unique_ptr m_backend = std::make_unique(); + std::list m_loggers; + }; + + template + class Logger + { + friend Logging; + Logging::Link m_logging; + + using Level = Logging::Level; + + template + inline void log( const Level l, ARGS&&... args ) const + { + if ( m_logging.enabled( l ) ) + m_logging->log( l, static_cast( this ), std::forward( args )... ); + } + + public: + template + inline void verbose( ARGS&&... args ) const + { + log( Level::VERBOSE, std::forward( args )... ); + } + template + inline void debug( ARGS&&... args ) const + { + log( Level::DEBUG, std::forward( args )... ); + } + template + inline void info( ARGS&&... args ) const + { + log( Level::INFO, std::forward( args )... ); + } + template + inline void warning( ARGS&&... args ) const + { + log( Level::WARNING, std::forward( args )... ); + } + template + inline void error( ARGS&&... args ) const + { + log( Level::ERROR, std::forward( args )... ); + } + template + inline void fatal( ARGS&&... args ) const + { + log( Level::FATAL, std::forward( args )... ); + } + template + inline void print( ARGS&&... args ) const + { + log( Level::ALWAYS, std::forward( args )... ); + } + }; +} diff --git a/GaudiKernel/Gaudi/details/LoggingTraits.h b/GaudiKernel/Gaudi/details/LoggingTraits.h new file mode 100644 index 0000000000..ecaea2cf12 --- /dev/null +++ b/GaudiKernel/Gaudi/details/LoggingTraits.h @@ -0,0 +1,22 @@ +#pragma once + +namespace Gaudi +{ + namespace details + { + template + struct LoggingTraits { + static inline std::string getName( const T& t ) { return t->name(); } + }; + + template <> + struct LoggingTraits { + static inline std::string getName( const std::string& s ) { return s; } + }; + + template <> + struct LoggingTraits { + static inline std::string getName( const char* s ) { return s; } + }; + } +} diff --git a/GaudiKernel/tests/qmtest/gaudikernel.qms/logging.qmt b/GaudiKernel/tests/qmtest/gaudikernel.qms/logging.qmt new file mode 100644 index 0000000000..e3a06bcc16 --- /dev/null +++ b/GaudiKernel/tests/qmtest/gaudikernel.qms/logging.qmt @@ -0,0 +1,7 @@ + + +test_Logging.exe +true +refs/Logging.ref +refs/Logging.err.ref + diff --git a/GaudiKernel/tests/qmtest/refs/Logging.err.ref b/GaudiKernel/tests/qmtest/refs/Logging.err.ref new file mode 100644 index 0000000000..d4cd092edb --- /dev/null +++ b/GaudiKernel/tests/qmtest/refs/Logging.err.ref @@ -0,0 +1,15 @@ +=== custom backend +sent over network: 'instance-3 ALWAYS over nework' +sent over network: 'instance-3 ALWAYS entering exec()' +sent over network: 'instance-3 INFO plain string' +sent over network: 'instance-3 INFO function without arguments' +sent over network: 'instance-3 INFO function with 1 arguments' +sent over network: 'instance-3 INFO we can use streamers with modifiers: 0x002a' +sent over network: 'instance-3 WARNING and this is a warning' +sent over network: 'instance-3 INFO a printf example: 123.450 ' +sent over network: 'instance-3 INFO what' +sent over network: 'instance-3 INFO about' +sent over network: 'instance-3 INFO multi' +sent over network: 'instance-3 INFO line?' +=== end of scope +sent over network: 'Gaudi::Logging VERBOSE unregistering 0x7ffd7e6cf910' diff --git a/GaudiKernel/tests/qmtest/refs/Logging.ref b/GaudiKernel/tests/qmtest/refs/Logging.ref new file mode 100644 index 0000000000..a9ca643f16 --- /dev/null +++ b/GaudiKernel/tests/qmtest/refs/Logging.ref @@ -0,0 +1,31 @@ +=== construct Logging +=== construct loggers +=== register loggers +=== use loggers +=== run instance-1 +instance-1 ALWAYS entering exec() +instance-1 INFO plain string +instance-1 INFO function without arguments +instance-1 INFO function with 1 arguments +instance-1 INFO we can use streamers with modifiers: 0x002a +instance-1 WARNING and this is a warning +instance-1 INFO a printf example: 123.450 +instance-1 INFO what +instance-1 INFO about +instance-1 INFO multi +instance-1 INFO line? +=== run instance-2 +instance-2 ALWAYS entering exec() +instance-2 INFO plain string +instance-2 INFO function without arguments +instance-2 INFO function with 1 arguments +instance-2 INFO we can use streamers with modifiers: 0x002a +instance-2 WARNING and this is a warning +instance-2 INFO a printf example: 123.450 +instance-2 INFO what +instance-2 INFO about +instance-2 INFO multi +instance-2 INFO line? +=== end of scope +Gaudi::Logging VERBOSE unregistering 0x7ffed6ca4ef0 +Gaudi::Logging VERBOSE unregistering 0x7ffed6ca4ec0 diff --git a/GaudiKernel/tests/src/test_Logging.cpp b/GaudiKernel/tests/src/test_Logging.cpp new file mode 100644 index 0000000000..14befbdf67 --- /dev/null +++ b/GaudiKernel/tests/src/test_Logging.cpp @@ -0,0 +1,84 @@ +#include +#include +#include + +struct C_Rulez { + C_Rulez( const char* format ) : fmt{format} {} + C_Rulez( std::string format ) : fmt{std::move( format )} {} + template + std::string operator()( ARGS&&... args ) const + { + std::array buffer{0}; + snprintf( buffer.data(), buffer.size(), fmt.c_str(), std::forward( args )... ); + return buffer.data(); + } + std::string fmt; +}; + +class MyStuff : public Gaudi::Logger +{ +public: + MyStuff( std::string name ) : m_name{std::move( name )} {} + const std::string& name() const { return m_name; } + + void exec() const + { + print( "entering exec()" ); + info( "plain string" ); + info( []() -> std::string { return "function without arguments"; } ); + info( []( int i ) -> std::string { return "function with " + std::to_string( i ) + " arguments"; }, 1 ); + info( Gaudi::Logging::Streamer, "we can use streamers with modifiers: 0x", std::hex, std::setw( 4 ), + std::setfill( '0' ), 42 ); + warning( "and this is a warning" ); + info( "a printf %s: %-10.3f", "example", 123.45 ); + info( "what\nabout\nmulti\nline?" ); + } + +private: + std::string m_name; +}; + +struct MyBackend : Gaudi::Logging::Backend { + void process( std::string msg ) const override { std::cerr << "sent over network: '" << msg << '\'' << '\n'; } +}; + +int main() +{ + { + std::cout << "=== construct Logging" << '\n'; + + Gaudi::Logging logging; + + std::cout << "=== construct loggers" << '\n'; + + MyStuff m{"instance-1"}; + MyStuff n{"instance-2"}; + + std::cout << "=== register loggers" << '\n'; + + logging.registerLogger( m ); + logging.registerLogger( n ); + + std::cout << "=== use loggers" << '\n'; + + std::cout << "=== run " << m.name() << '\n'; + m.exec(); + + std::cout << "=== run " << n.name() << '\n'; + n.exec(); + + std::cout << "=== end of scope" << '\n'; + } + + { + std::cerr << "=== custom backend" << '\n'; + Gaudi::Logging netLog{std::make_unique()}; + MyStuff netStuff{"instance-3"}; + netLog.registerLogger( netStuff ); + + netStuff.print( "over nework" ); + netStuff.exec(); + + std::cerr << "=== end of scope" << '\n'; + } +} -- GitLab From 1114ccd2e8d61ed47c960b7fe51001dcd78a5ee1 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Wed, 25 Oct 2017 15:41:51 +0200 Subject: [PATCH 33/53] Applied @graven suggestions --- GaudiKernel/Gaudi/Logging.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/GaudiKernel/Gaudi/Logging.h b/GaudiKernel/Gaudi/Logging.h index 549e4c32b8..a68ce14708 100644 --- a/GaudiKernel/Gaudi/Logging.h +++ b/GaudiKernel/Gaudi/Logging.h @@ -31,7 +31,7 @@ namespace Gaudi { const static std::array names = {"VERBOSE", "DEBUG", "INFO", "WARNING", "ERROR", "FATAL", "ALWAYS"}; - return names[static_cast>( l )]; + return names.at( static_cast>( l ) ); } struct Link { @@ -94,9 +94,8 @@ namespace Gaudi std::unique_ptr setBackend( std::unique_ptr b ) { - auto old_backend = std::move( m_backend ); - m_backend = b ? std::move( b ) : std::make_unique(); - return old_backend; + if ( !b ) b = std::make_unique(); + return std::exchange( m_backend, std::move( b ) ); } template ::value>> -- GitLab From 340115102ed08e086aa8a562aeabea6fae0c43aa Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Mon, 30 Oct 2017 14:15:43 +0100 Subject: [PATCH 34/53] Modified helper for iostreams formatting --- GaudiKernel/Gaudi/Logging.h | 26 ++++++++++++-------------- GaudiKernel/tests/src/test_Logging.cpp | 4 ++-- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/GaudiKernel/Gaudi/Logging.h b/GaudiKernel/Gaudi/Logging.h index a68ce14708..9f803f0f16 100644 --- a/GaudiKernel/Gaudi/Logging.h +++ b/GaudiKernel/Gaudi/Logging.h @@ -59,26 +59,24 @@ namespace Gaudi } }; - static constexpr const class - { - public: - template - inline std::string operator()( ARGS&&... args ) const + struct Stream { + template + Stream( ARG&& arg ) { - std::stringstream out; - return _impl( out, std::forward( args )... ); + out << std::forward( arg ); } - private: - inline std::string _impl( std::stringstream& out ) const { return out.str(); } - + inline std::string operator()() const { return out.str(); } template - inline std::string _impl( std::stringstream& out, ARG&& arg, ARGS&&... args ) const + inline std::string operator()( ARG&& arg, ARGS&&... args ) const { - out << arg; - return _impl( out, std::forward( args )... ); + out << std::forward( arg ); + return ( *this )( std::forward( args )... ); } - } Streamer{}; + + private: + mutable std::stringstream out; + }; struct Backend { virtual ~Backend() = default; diff --git a/GaudiKernel/tests/src/test_Logging.cpp b/GaudiKernel/tests/src/test_Logging.cpp index 14befbdf67..44d2197ce8 100644 --- a/GaudiKernel/tests/src/test_Logging.cpp +++ b/GaudiKernel/tests/src/test_Logging.cpp @@ -27,8 +27,8 @@ public: info( "plain string" ); info( []() -> std::string { return "function without arguments"; } ); info( []( int i ) -> std::string { return "function with " + std::to_string( i ) + " arguments"; }, 1 ); - info( Gaudi::Logging::Streamer, "we can use streamers with modifiers: 0x", std::hex, std::setw( 4 ), - std::setfill( '0' ), 42 ); + info( "we can use streamers with modifiers: 0x", std::hex, std::setw( 4 ), + std::setfill( '0' ), 42 ); warning( "and this is a warning" ); info( "a printf %s: %-10.3f", "example", 123.45 ); info( "what\nabout\nmulti\nline?" ); -- GitLab From 88ac9ce0e9805d5140a62a9cd2fe4dbcd4ea42df Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Tue, 31 Oct 2017 10:39:04 +0100 Subject: [PATCH 35/53] Moved Logging formatters to dedicated header --- GaudiKernel/Gaudi/Logging.h | 20 ------------- GaudiKernel/Gaudi/LoggingFormatters.h | 28 +++++++++++++++++++ GaudiKernel/tests/qmtest/refs/Logging.err.ref | 2 +- GaudiKernel/tests/qmtest/refs/Logging.ref | 4 +-- GaudiKernel/tests/src/test_Logging.cpp | 9 ++++-- 5 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 GaudiKernel/Gaudi/LoggingFormatters.h diff --git a/GaudiKernel/Gaudi/Logging.h b/GaudiKernel/Gaudi/Logging.h index 9f803f0f16..cacc1d0072 100644 --- a/GaudiKernel/Gaudi/Logging.h +++ b/GaudiKernel/Gaudi/Logging.h @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -59,25 +58,6 @@ namespace Gaudi } }; - struct Stream { - template - Stream( ARG&& arg ) - { - out << std::forward( arg ); - } - - inline std::string operator()() const { return out.str(); } - template - inline std::string operator()( ARG&& arg, ARGS&&... args ) const - { - out << std::forward( arg ); - return ( *this )( std::forward( args )... ); - } - - private: - mutable std::stringstream out; - }; - struct Backend { virtual ~Backend() = default; virtual void process( std::string msg ) const = 0; diff --git a/GaudiKernel/Gaudi/LoggingFormatters.h b/GaudiKernel/Gaudi/LoggingFormatters.h new file mode 100644 index 0000000000..e5241f4417 --- /dev/null +++ b/GaudiKernel/Gaudi/LoggingFormatters.h @@ -0,0 +1,28 @@ +#pragma once + +#include + +namespace Gaudi +{ + namespace LoggingFormatters + { + struct Stream { + template + Stream( ARG&& arg ) + { + out << std::forward( arg ); + } + + inline std::string operator()() const { return out.str(); } + template + inline std::string operator()( ARG&& arg, ARGS&&... args ) const + { + out << std::forward( arg ); + return ( *this )( std::forward( args )... ); + } + + private: + mutable std::stringstream out; + }; + } +} diff --git a/GaudiKernel/tests/qmtest/refs/Logging.err.ref b/GaudiKernel/tests/qmtest/refs/Logging.err.ref index d4cd092edb..018d0f56f9 100644 --- a/GaudiKernel/tests/qmtest/refs/Logging.err.ref +++ b/GaudiKernel/tests/qmtest/refs/Logging.err.ref @@ -6,7 +6,7 @@ sent over network: 'instance-3 INFO function without arguments' sent over network: 'instance-3 INFO function with 1 arguments' sent over network: 'instance-3 INFO we can use streamers with modifiers: 0x002a' sent over network: 'instance-3 WARNING and this is a warning' -sent over network: 'instance-3 INFO a printf example: 123.450 ' +sent over network: 'instance-3 INFO a printf example: 123.450' sent over network: 'instance-3 INFO what' sent over network: 'instance-3 INFO about' sent over network: 'instance-3 INFO multi' diff --git a/GaudiKernel/tests/qmtest/refs/Logging.ref b/GaudiKernel/tests/qmtest/refs/Logging.ref index a9ca643f16..beffdde4a1 100644 --- a/GaudiKernel/tests/qmtest/refs/Logging.ref +++ b/GaudiKernel/tests/qmtest/refs/Logging.ref @@ -9,7 +9,7 @@ instance-1 INFO function without arguments instance-1 INFO function with 1 arguments instance-1 INFO we can use streamers with modifiers: 0x002a instance-1 WARNING and this is a warning -instance-1 INFO a printf example: 123.450 +instance-1 INFO a printf example: 123.450 instance-1 INFO what instance-1 INFO about instance-1 INFO multi @@ -21,7 +21,7 @@ instance-2 INFO function without arguments instance-2 INFO function with 1 arguments instance-2 INFO we can use streamers with modifiers: 0x002a instance-2 WARNING and this is a warning -instance-2 INFO a printf example: 123.450 +instance-2 INFO a printf example: 123.450 instance-2 INFO what instance-2 INFO about instance-2 INFO multi diff --git a/GaudiKernel/tests/src/test_Logging.cpp b/GaudiKernel/tests/src/test_Logging.cpp index 44d2197ce8..21acd0ac04 100644 --- a/GaudiKernel/tests/src/test_Logging.cpp +++ b/GaudiKernel/tests/src/test_Logging.cpp @@ -1,4 +1,7 @@ #include + +#include + #include #include @@ -23,14 +26,14 @@ public: void exec() const { + using namespace Gaudi::LoggingFormatters; print( "entering exec()" ); info( "plain string" ); info( []() -> std::string { return "function without arguments"; } ); info( []( int i ) -> std::string { return "function with " + std::to_string( i ) + " arguments"; }, 1 ); - info( "we can use streamers with modifiers: 0x", std::hex, std::setw( 4 ), - std::setfill( '0' ), 42 ); + info( "we can use streamers with modifiers: 0x", std::hex, std::setw( 4 ), std::setfill( '0' ), 42 ); warning( "and this is a warning" ); - info( "a printf %s: %-10.3f", "example", 123.45 ); + info( "a %-12s example: %10.3f", "printf", 123.45 ); info( "what\nabout\nmulti\nline?" ); } -- GitLab From fb67d7896cbd1523eb847c57683dcf3c1af2e77a Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Tue, 31 Oct 2017 07:48:04 +0100 Subject: [PATCH 36/53] Made fmtlib available to Gaudi see http://fmtlib.net/latest/index.html --- GaudiKernel/CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/GaudiKernel/CMakeLists.txt b/GaudiKernel/CMakeLists.txt index 166594b14c..1027dbc9ac 100644 --- a/GaudiKernel/CMakeLists.txt +++ b/GaudiKernel/CMakeLists.txt @@ -39,6 +39,37 @@ message(STATUS "Using VectorClass instrset_detect ${VectorClass_VERSION} at ${Ve include_directories(${VectorClass_INCLUDE_DIR}) +# get [fmt](http://fmtlib.net/latest/index.html) +set(fmt_DEFAULT_VERSION 5.2.0) +if(NOT USE_INTERNAL_fmt) + find_package(fmt ${fmt_DEFAULT_VERSION} QUIET) + if(fmt_FOUND) + message(STATUS "Found fmtlib ${fmt_VERSION}") + get_property(fmt_INCLUDE_DIRS TARGET fmt::fmt-header-only PROPERTY INTERFACE_INCLUDE_DIRECTORIES) + else() + message(STATUS "fmtlib not found") + set(USE_INTERNAL_fmt YES CACHE BOOL "using internal build of fmt") + endif() +endif() + +if(USE_INTERNAL_fmt) + set(fmt_VERSION ${fmt_DEFAULT_VERSION}) + message(STATUS "Building fmtlib ${fmt_VERSION}") + include(ExternalProject) + ExternalProject_Add(fmt + GIT_REPOSITORY https://github.com/fmtlib/fmt.git + GIT_TAG ${fmt_VERSION} + CMAKE_ARGS -DFMT_DOC=OFF -DFMT_TEST=OFF + -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} + -DCMAKE_BUILD_TYPE=Release + ) + # Ideally we could install directly to ${CMAKE_INSTALL_PREFIX}, but it + # would not be available in this project. + install(DIRECTORY ${CMAKE_BINARY_DIR}/include/fmt DESTINATION include) + install(DIRECTORY ${CMAKE_BINARY_DIR}/lib/cmake/fmt DESTINATION lib/cmake) + install(FILES ${CMAKE_BINARY_DIR}/lib/libfmt.a DESTINATION lib) +endif() + # Extra settings when building on MacOS: set( extra_sources ) set( extra_libraries ) @@ -63,6 +94,11 @@ gaudi_add_library(GaudiKernel src/Lib/*.cpp ${extra_sources} INCLUDE_DIRS Boost ROOT TBB cppgsl PUBLIC_HEADERS Gaudi GaudiKernel) +if(USE_INTERNAL_fmt) + # make sure fmt is built before GaudiKernel + add_dependencies(GaudiKernel fmt) +endif() + #---Tests------------------------------------------------------------------- if( CPPUNIT_FOUND ) gaudi_add_unit_test(DirSearchPath_test tests/src/DirSearchPath_test.cpp -- GitLab From 38e18c599602d2028ddf7481e1f54b4c91a31c1a Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Tue, 31 Oct 2017 10:43:31 +0100 Subject: [PATCH 37/53] Use fmtlib in Gaudi::Logging and added a formatter based on `fmt::format` --- GaudiKernel/CMakeLists.txt | 9 +++++++++ GaudiKernel/Gaudi/Logging.h | 19 ++++++++----------- GaudiKernel/Gaudi/LoggingFormatters.h | 16 ++++++++++++++++ GaudiKernel/tests/qmtest/refs/Logging.err.ref | 1 + GaudiKernel/tests/qmtest/refs/Logging.ref | 2 ++ GaudiKernel/tests/src/test_Logging.cpp | 2 ++ GaudiMP/CMakeLists.txt | 3 +++ GaudiPython/CMakeLists.txt | 3 +++ 8 files changed, 44 insertions(+), 11 deletions(-) diff --git a/GaudiKernel/CMakeLists.txt b/GaudiKernel/CMakeLists.txt index 1027dbc9ac..ae96d0a832 100644 --- a/GaudiKernel/CMakeLists.txt +++ b/GaudiKernel/CMakeLists.txt @@ -209,9 +209,18 @@ gaudi_add_compile_test(test_StatusCodeFail tests/src/test_StatusCode_fail.cxx ERRORS "FAIL01;FAIL02;FAIL03;FAIL04") add_executable( test_Logging tests/src/test_Logging.cpp ) +if(USE_INTERNAL_fmt) + add_dependencies(test_Logging fmt) + target_compile_definitions(test_Logging PRIVATE FMT_HEADER_ONLY=1) +else() + target_link_libraries(test_Logging fmt::fmt) +endif() #---Dictionaries------------------------------------------------------------ gaudi_add_dictionary(GaudiKernel dict/dictionary.h dict/dictionary.xml LINK_LIBRARIES GaudiKernel) +if(USE_INTERNAL_fmt) + add_dependencies(GaudiKernelGenDeps fmt) +endif() #---Installation------------------------------------------------------------ # Disable generation of ConfUserDB (must be done before gaudi_install_python_modules) diff --git a/GaudiKernel/Gaudi/Logging.h b/GaudiKernel/Gaudi/Logging.h index cacc1d0072..1e8af767a7 100644 --- a/GaudiKernel/Gaudi/Logging.h +++ b/GaudiKernel/Gaudi/Logging.h @@ -4,8 +4,6 @@ #include #include #include -#include -#include #include #include #include @@ -13,6 +11,8 @@ #include +#include + #include "Gaudi/details/LoggingTraits.h" #include "GaudiKernel/Kernel.h" @@ -64,7 +64,7 @@ namespace Gaudi }; struct DefaultBackend : Backend { - void process( std::string msg ) const override { std::cout << msg << '\n'; } + void process( std::string msg ) const override { fmt::print( "{}\n", msg ); } }; Logging() = default; @@ -114,11 +114,8 @@ namespace Gaudi void unregister( Link* link ) { - log( Level::VERBOSE, "Gaudi::Logging", [link]() -> std::string { - std::stringstream out; - out << "unregistering " << link; - return out.str(); - } ); + log( Level::VERBOSE, "Gaudi::Logging", + [link]() -> std::string { return fmt::format( "unregistering {}", static_cast( link ) ); } ); auto pos = find( begin( m_loggers ), end( m_loggers ), link ); if ( pos != end( m_loggers ) ) { m_loggers.erase( pos ); @@ -141,9 +138,9 @@ namespace Gaudi std::vector lines; boost::algorithm::split( lines, msg, []( char c ) { return c == '\n'; } ); for ( const auto& line : lines ) { - std::stringstream data; - data << std::setw( 20 ) << std::left << Traits::getName( s ) << ' ' << std::setw( 8 ) << levelName( l ) << line; - m_backend->process( data.str() ); + fmt::MemoryWriter writer; + writer.write( "{:<20} {:7} {}", Traits::getName( s ), levelName( l ), line ); + m_backend->process( writer.str() ); } } diff --git a/GaudiKernel/Gaudi/LoggingFormatters.h b/GaudiKernel/Gaudi/LoggingFormatters.h index e5241f4417..9342c660c7 100644 --- a/GaudiKernel/Gaudi/LoggingFormatters.h +++ b/GaudiKernel/Gaudi/LoggingFormatters.h @@ -24,5 +24,21 @@ namespace Gaudi private: mutable std::stringstream out; }; + + struct fmtlib { + template + fmtlib( ARG&& arg ) : first_arg{std::forward( arg )} + { + } + + template + inline std::string operator()( ARGS&&... args ) const + { + return fmt::format( first_arg, std::forward( args )... ); + } + + private: + fmt::CStringRef first_arg; + }; } } diff --git a/GaudiKernel/tests/qmtest/refs/Logging.err.ref b/GaudiKernel/tests/qmtest/refs/Logging.err.ref index 018d0f56f9..a648074051 100644 --- a/GaudiKernel/tests/qmtest/refs/Logging.err.ref +++ b/GaudiKernel/tests/qmtest/refs/Logging.err.ref @@ -7,6 +7,7 @@ sent over network: 'instance-3 INFO function with 1 arguments' sent over network: 'instance-3 INFO we can use streamers with modifiers: 0x002a' sent over network: 'instance-3 WARNING and this is a warning' sent over network: 'instance-3 INFO a printf example: 123.450' +sent over network: 'instance-3 INFO a fmt::format example: 123.450' sent over network: 'instance-3 INFO what' sent over network: 'instance-3 INFO about' sent over network: 'instance-3 INFO multi' diff --git a/GaudiKernel/tests/qmtest/refs/Logging.ref b/GaudiKernel/tests/qmtest/refs/Logging.ref index beffdde4a1..02380ac14b 100644 --- a/GaudiKernel/tests/qmtest/refs/Logging.ref +++ b/GaudiKernel/tests/qmtest/refs/Logging.ref @@ -10,6 +10,7 @@ instance-1 INFO function with 1 arguments instance-1 INFO we can use streamers with modifiers: 0x002a instance-1 WARNING and this is a warning instance-1 INFO a printf example: 123.450 +instance-1 INFO a fmt::format example: 123.450 instance-1 INFO what instance-1 INFO about instance-1 INFO multi @@ -22,6 +23,7 @@ instance-2 INFO function with 1 arguments instance-2 INFO we can use streamers with modifiers: 0x002a instance-2 WARNING and this is a warning instance-2 INFO a printf example: 123.450 +instance-2 INFO a fmt::format example: 123.450 instance-2 INFO what instance-2 INFO about instance-2 INFO multi diff --git a/GaudiKernel/tests/src/test_Logging.cpp b/GaudiKernel/tests/src/test_Logging.cpp index 21acd0ac04..cb02a637a0 100644 --- a/GaudiKernel/tests/src/test_Logging.cpp +++ b/GaudiKernel/tests/src/test_Logging.cpp @@ -4,6 +4,7 @@ #include #include +#include struct C_Rulez { C_Rulez( const char* format ) : fmt{format} {} @@ -34,6 +35,7 @@ public: info( "we can use streamers with modifiers: 0x", std::hex, std::setw( 4 ), std::setfill( '0' ), 42 ); warning( "and this is a warning" ); info( "a %-12s example: %10.3f", "printf", 123.45 ); + info( "a {1:12} example: {0:10.3f}", 123.45, "fmt::format" ); info( "what\nabout\nmulti\nline?" ); } diff --git a/GaudiMP/CMakeLists.txt b/GaudiMP/CMakeLists.txt index b1dd505eb2..89fb243e14 100644 --- a/GaudiMP/CMakeLists.txt +++ b/GaudiMP/CMakeLists.txt @@ -27,6 +27,9 @@ gaudi_add_module(GaudiMP ${module_sources} #---Dictionaries------------------------------------------------------------ gaudi_add_dictionary(GaudiMP dict/gaudimp_dict.h dict/selection.xml LINK_LIBRARIES GaudiMPLib) +if(USE_INTERNAL_fmt) + add_dependencies(GaudiMPGenDeps fmt) +endif() #---Installation------------------------------------------------------------ gaudi_install_python_modules() diff --git a/GaudiPython/CMakeLists.txt b/GaudiPython/CMakeLists.txt index 91057ab9f7..acbd83ff39 100644 --- a/GaudiPython/CMakeLists.txt +++ b/GaudiPython/CMakeLists.txt @@ -50,6 +50,9 @@ gaudi_add_module(GaudiPython src/Services/*.cpp #---Dictionaries------------------------------------------------------------ gaudi_add_dictionary(GaudiPython dict/kernel.h dict/selection_kernel.xml LINK_LIBRARIES GaudiPythonLib GaudiUtilsLib) +if(USE_INTERNAL_fmt) + add_dependencies(GaudiPythonGenDeps fmt) +endif() #---Installation------------------------------------------------------------ gaudi_install_python_modules() -- GitLab From 3e915a23717adc95e978cd51f33c2008ba75fc55 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Wed, 1 Nov 2017 08:35:49 +0100 Subject: [PATCH 38/53] Minor implementation clean up --- GaudiKernel/Gaudi/Logging.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/GaudiKernel/Gaudi/Logging.h b/GaudiKernel/Gaudi/Logging.h index 1e8af767a7..e9ae835b8d 100644 --- a/GaudiKernel/Gaudi/Logging.h +++ b/GaudiKernel/Gaudi/Logging.h @@ -79,8 +79,9 @@ namespace Gaudi template ::value>> void log( const Level l, const SOURCE s, std::string msg ) const { + using Traits = details::LoggingTraits; if ( !( true /* || traits.enabled( s, l ) */ ) ) return; - i_log( l, s, std::move( msg ) ); + i_log( l, Traits::getName( s ), std::move( msg ) ); } void log( const Level l, std::string s, std::string msg ) const @@ -90,7 +91,7 @@ namespace Gaudi } template ::value>> - void log( const Level l, const std::string s, const FORMATTER& formatter, ARGS&&... args ) const + void log( const Level l, std::string s, const FORMATTER& formatter, ARGS&&... args ) const { if ( !( true /* || traits.enabled( s, l ) */ ) ) return; i_log( l, std::move( s ), formatter( std::forward( args )... ) ); @@ -101,8 +102,9 @@ namespace Gaudi typename = std::enable_if_t::value>> void log( const Level l, const SOURCE s, const FORMATTER& formatter, ARGS&&... args ) const { + using Traits = details::LoggingTraits; if ( !( true /* || traits.enabled( s, l ) */ ) ) return; - i_log( l, s, formatter( std::forward( args )... ) ); + i_log( l, Traits::getName( s ), formatter( std::forward( args )... ) ); } template @@ -130,16 +132,14 @@ namespace Gaudi } private: - template - void i_log( const Level l, const SOURCE s, std::string msg ) const + void i_log( const Level l, std::string source, const std::string& msg ) const { - using Traits = details::LoggingTraits; // FIXME use https://stackoverflow.com/a/28001459 std::vector lines; boost::algorithm::split( lines, msg, []( char c ) { return c == '\n'; } ); for ( const auto& line : lines ) { fmt::MemoryWriter writer; - writer.write( "{:<20} {:7} {}", Traits::getName( s ), levelName( l ), line ); + writer.write( "{:<20} {:7} {}", std::move( source ), levelName( l ), line ); m_backend->process( writer.str() ); } } -- GitLab From 25dc156840d740b5989a7ac0b2b322b934e6da1b Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Thu, 2 Nov 2017 14:22:58 +0100 Subject: [PATCH 39/53] Removed LoggingTraits and avoid level filtering in Logging::log the most efficient place where to check the logging level is `Logger`, so we do not need to check it twice, and let the backend decide if it need to filter more. --- GaudiKernel/Gaudi/Logging.h | 17 +++-------------- GaudiKernel/Gaudi/details/LoggingTraits.h | 22 ---------------------- 2 files changed, 3 insertions(+), 36 deletions(-) delete mode 100644 GaudiKernel/Gaudi/details/LoggingTraits.h diff --git a/GaudiKernel/Gaudi/Logging.h b/GaudiKernel/Gaudi/Logging.h index e9ae835b8d..1edb1879d3 100644 --- a/GaudiKernel/Gaudi/Logging.h +++ b/GaudiKernel/Gaudi/Logging.h @@ -13,8 +13,6 @@ #include -#include "Gaudi/details/LoggingTraits.h" - #include "GaudiKernel/Kernel.h" namespace Gaudi @@ -79,21 +77,14 @@ namespace Gaudi template ::value>> void log( const Level l, const SOURCE s, std::string msg ) const { - using Traits = details::LoggingTraits; - if ( !( true /* || traits.enabled( s, l ) */ ) ) return; - i_log( l, Traits::getName( s ), std::move( msg ) ); + i_log( l, s->name(), std::move( msg ) ); } - void log( const Level l, std::string s, std::string msg ) const - { - if ( !( true /* || traits.enabled( s, l ) */ ) ) return; - i_log( l, std::move( s ), std::move( msg ) ); - } + void log( const Level l, std::string s, std::string msg ) const { i_log( l, std::move( s ), std::move( msg ) ); } template ::value>> void log( const Level l, std::string s, const FORMATTER& formatter, ARGS&&... args ) const { - if ( !( true /* || traits.enabled( s, l ) */ ) ) return; i_log( l, std::move( s ), formatter( std::forward( args )... ) ); } @@ -102,9 +93,7 @@ namespace Gaudi typename = std::enable_if_t::value>> void log( const Level l, const SOURCE s, const FORMATTER& formatter, ARGS&&... args ) const { - using Traits = details::LoggingTraits; - if ( !( true /* || traits.enabled( s, l ) */ ) ) return; - i_log( l, Traits::getName( s ), formatter( std::forward( args )... ) ); + i_log( l, s->name(), formatter( std::forward( args )... ) ); } template diff --git a/GaudiKernel/Gaudi/details/LoggingTraits.h b/GaudiKernel/Gaudi/details/LoggingTraits.h deleted file mode 100644 index ecaea2cf12..0000000000 --- a/GaudiKernel/Gaudi/details/LoggingTraits.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -namespace Gaudi -{ - namespace details - { - template - struct LoggingTraits { - static inline std::string getName( const T& t ) { return t->name(); } - }; - - template <> - struct LoggingTraits { - static inline std::string getName( const std::string& s ) { return s; } - }; - - template <> - struct LoggingTraits { - static inline std::string getName( const char* s ) { return s; } - }; - } -} -- GitLab From a0628b27b6e1dd693305a0ab0283f8b8a6ea010e Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Thu, 2 Nov 2017 14:27:51 +0100 Subject: [PATCH 40/53] Modified Logging to accept a formatter instance or a callable --- GaudiKernel/Gaudi/Logging.h | 56 ++++++++++--------- GaudiKernel/tests/qmtest/refs/Logging.err.ref | 1 + GaudiKernel/tests/qmtest/refs/Logging.ref | 2 + GaudiKernel/tests/src/test_Logging.cpp | 17 +++++- 4 files changed, 47 insertions(+), 29 deletions(-) diff --git a/GaudiKernel/Gaudi/Logging.h b/GaudiKernel/Gaudi/Logging.h index 1edb1879d3..e4f62367d2 100644 --- a/GaudiKernel/Gaudi/Logging.h +++ b/GaudiKernel/Gaudi/Logging.h @@ -74,26 +74,30 @@ namespace Gaudi return std::exchange( m_backend, std::move( b ) ); } - template ::value>> - void log( const Level l, const SOURCE s, std::string msg ) const + template + void log( const Level l, std::string s, std::string msg ) const { - i_log( l, s->name(), std::move( msg ) ); + i_log( l, std::move( s ), std::move( msg ) ); } - void log( const Level l, std::string s, std::string msg ) const { i_log( l, std::move( s ), std::move( msg ) ); } - template ::value>> void log( const Level l, std::string s, const FORMATTER& formatter, ARGS&&... args ) const { i_log( l, std::move( s ), formatter( std::forward( args )... ) ); } - template ::value>, - typename = std::enable_if_t::value>> - void log( const Level l, const SOURCE s, const FORMATTER& formatter, ARGS&&... args ) const + template + void log( const Level l, std::string s, ARG1&& arg1, ARGS&&... args ) const + { + i_log( l, std::move( s ), FORMATTER{}( std::forward( arg1 ), std::forward( args )... ) ); + } + + template ::value || + std::is_same::value )>> + void log( const Level l, const SOURCE s, ARGS&&... args ) const { - i_log( l, s->name(), formatter( std::forward( args )... ) ); + log( l, s->name(), std::forward( args )... ); } template @@ -145,48 +149,48 @@ namespace Gaudi using Level = Logging::Level; - template + template inline void log( const Level l, ARGS&&... args ) const { if ( m_logging.enabled( l ) ) - m_logging->log( l, static_cast( this ), std::forward( args )... ); + m_logging->log( l, static_cast( this ), std::forward( args )... ); } public: - template + template inline void verbose( ARGS&&... args ) const { - log( Level::VERBOSE, std::forward( args )... ); + log( Level::VERBOSE, std::forward( args )... ); } - template + template inline void debug( ARGS&&... args ) const { - log( Level::DEBUG, std::forward( args )... ); + log( Level::DEBUG, std::forward( args )... ); } - template + template inline void info( ARGS&&... args ) const { - log( Level::INFO, std::forward( args )... ); + log( Level::INFO, std::forward( args )... ); } - template + template inline void warning( ARGS&&... args ) const { - log( Level::WARNING, std::forward( args )... ); + log( Level::WARNING, std::forward( args )... ); } - template + template inline void error( ARGS&&... args ) const { - log( Level::ERROR, std::forward( args )... ); + log( Level::ERROR, std::forward( args )... ); } - template + template inline void fatal( ARGS&&... args ) const { - log( Level::FATAL, std::forward( args )... ); + log( Level::FATAL, std::forward( args )... ); } - template + template inline void print( ARGS&&... args ) const { - log( Level::ALWAYS, std::forward( args )... ); + log( Level::ALWAYS, std::forward( args )... ); } }; } diff --git a/GaudiKernel/tests/qmtest/refs/Logging.err.ref b/GaudiKernel/tests/qmtest/refs/Logging.err.ref index a648074051..50079fdbd8 100644 --- a/GaudiKernel/tests/qmtest/refs/Logging.err.ref +++ b/GaudiKernel/tests/qmtest/refs/Logging.err.ref @@ -8,6 +8,7 @@ sent over network: 'instance-3 INFO we can use streamers with modif sent over network: 'instance-3 WARNING and this is a warning' sent over network: 'instance-3 INFO a printf example: 123.450' sent over network: 'instance-3 INFO a fmt::format example: 123.450' +sent over network: 'instance-3 INFO a fmt::format example: 123.450' sent over network: 'instance-3 INFO what' sent over network: 'instance-3 INFO about' sent over network: 'instance-3 INFO multi' diff --git a/GaudiKernel/tests/qmtest/refs/Logging.ref b/GaudiKernel/tests/qmtest/refs/Logging.ref index 02380ac14b..6240432f02 100644 --- a/GaudiKernel/tests/qmtest/refs/Logging.ref +++ b/GaudiKernel/tests/qmtest/refs/Logging.ref @@ -11,6 +11,7 @@ instance-1 INFO we can use streamers with modifiers: 0x002a instance-1 WARNING and this is a warning instance-1 INFO a printf example: 123.450 instance-1 INFO a fmt::format example: 123.450 +instance-1 INFO a fmt::format example: 123.450 instance-1 INFO what instance-1 INFO about instance-1 INFO multi @@ -24,6 +25,7 @@ instance-2 INFO we can use streamers with modifiers: 0x002a instance-2 WARNING and this is a warning instance-2 INFO a printf example: 123.450 instance-2 INFO a fmt::format example: 123.450 +instance-2 INFO a fmt::format example: 123.450 instance-2 INFO what instance-2 INFO about instance-2 INFO multi diff --git a/GaudiKernel/tests/src/test_Logging.cpp b/GaudiKernel/tests/src/test_Logging.cpp index cb02a637a0..4b7f0f4036 100644 --- a/GaudiKernel/tests/src/test_Logging.cpp +++ b/GaudiKernel/tests/src/test_Logging.cpp @@ -19,6 +19,16 @@ struct C_Rulez { std::string fmt; }; +struct fmtlib2 { + template + std::string operator()( ARGS&&... args ) + { + fmt::MemoryWriter w; + w.write( std::forward( args )... ); + return w.str(); + } +}; + class MyStuff : public Gaudi::Logger { public: @@ -32,10 +42,11 @@ public: info( "plain string" ); info( []() -> std::string { return "function without arguments"; } ); info( []( int i ) -> std::string { return "function with " + std::to_string( i ) + " arguments"; }, 1 ); - info( "we can use streamers with modifiers: 0x", std::hex, std::setw( 4 ), std::setfill( '0' ), 42 ); + info( Stream{"we can use streamers with modifiers: 0x"}, std::hex, std::setw( 4 ), std::setfill( '0' ), 42 ); warning( "and this is a warning" ); - info( "a %-12s example: %10.3f", "printf", 123.45 ); - info( "a {1:12} example: {0:10.3f}", 123.45, "fmt::format" ); + info( C_Rulez{"a %-12s example: %10.3f"}, "printf", 123.45 ); + info( fmtlib{"a {1:12} example: {0:10.3f}"}, 123.45, "fmt::format" ); + info( "a {1:12} example: {0:10.3f}", 123.45, "fmt::format" ); info( "what\nabout\nmulti\nline?" ); } -- GitLab From 2ae55bed28b7686198a79d2638d71ec27b4c5a85 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Thu, 2 Nov 2017 23:16:25 +0100 Subject: [PATCH 41/53] Improved Logging interface - fmtlib and iostream formatters provided - use fmtlib by default - C++14 and C++17 implementations (with tests) --- GaudiKernel/CMakeLists.txt | 20 ++++++-- GaudiKernel/Gaudi/Logging.h | 50 +++++++++---------- GaudiKernel/Gaudi/LoggingFormatters.h | 50 +++++++++++-------- .../{logging.qmt => logging_cpp14.qmt} | 2 +- .../qmtest/gaudikernel.qms/logging_cpp17.qmt | 16 ++++++ GaudiKernel/tests/qmtest/refs/Logging.err.ref | 1 - GaudiKernel/tests/qmtest/refs/Logging.ref | 3 +- GaudiKernel/tests/src/test_Logging.cpp | 14 +++--- 8 files changed, 95 insertions(+), 61 deletions(-) rename GaudiKernel/tests/qmtest/gaudikernel.qms/{logging.qmt => logging_cpp14.qmt} (86%) create mode 100644 GaudiKernel/tests/qmtest/gaudikernel.qms/logging_cpp17.qmt diff --git a/GaudiKernel/CMakeLists.txt b/GaudiKernel/CMakeLists.txt index ae96d0a832..fa0c219577 100644 --- a/GaudiKernel/CMakeLists.txt +++ b/GaudiKernel/CMakeLists.txt @@ -208,12 +208,24 @@ gaudi_add_unit_test(test_reverse tests/src/test_reverse.cpp gaudi_add_compile_test(test_StatusCodeFail tests/src/test_StatusCode_fail.cxx ERRORS "FAIL01;FAIL02;FAIL03;FAIL04") -add_executable( test_Logging tests/src/test_Logging.cpp ) +add_executable( test_Logging_14 tests/src/test_Logging.cpp ) +set_target_properties(test_Logging_14 PROPERTIES COMPILE_FLAGS "-std=c++14") if(USE_INTERNAL_fmt) - add_dependencies(test_Logging fmt) - target_compile_definitions(test_Logging PRIVATE FMT_HEADER_ONLY=1) + add_dependencies(test_Logging_14 fmt) + target_compile_definitions(test_Logging_14 PRIVATE FMT_HEADER_ONLY=1) else() - target_link_libraries(test_Logging fmt::fmt) + target_link_libraries(test_Logging_14 fmt::fmt) +endif() + +if(BINARY_TAG_COMP_NAME STREQUAL "gcc" AND NOT BINARY_TAG_COMP_VERSION VERSION_LESS "7.0") + add_executable( test_Logging_17 tests/src/test_Logging.cpp ) + set_target_properties(test_Logging_17 PROPERTIES COMPILE_FLAGS "-std=c++17") + if(USE_INTERNAL_fmt) + add_dependencies(test_Logging_17 fmt) + target_compile_definitions(test_Logging_17 PRIVATE FMT_HEADER_ONLY=1) + else() + target_link_libraries(test_Logging_17 fmt::fmt) + endif() endif() #---Dictionaries------------------------------------------------------------ diff --git a/GaudiKernel/Gaudi/Logging.h b/GaudiKernel/Gaudi/Logging.h index e4f62367d2..386a116d21 100644 --- a/GaudiKernel/Gaudi/Logging.h +++ b/GaudiKernel/Gaudi/Logging.h @@ -15,6 +15,8 @@ #include "GaudiKernel/Kernel.h" +#include "Gaudi/LoggingFormatters.h" + namespace Gaudi { template @@ -31,9 +33,10 @@ namespace Gaudi return names.at( static_cast>( l ) ); } - struct Link { - Link() {} - Link( Logging* logging_ ) : logging{logging_} {} + using DefaultFormatter = LoggingFormatters::fmtlib; + + struct Link final { + Link( Logging* logging_ = nullptr ) : logging{logging_} {} Link( const Link& ) = delete; Link& operator=( const Link& ) = delete; @@ -57,7 +60,8 @@ namespace Gaudi }; struct Backend { - virtual ~Backend() = default; + virtual ~Backend() = default; + virtual void process( std::string msg ) const = 0; }; @@ -74,31 +78,26 @@ namespace Gaudi return std::exchange( m_backend, std::move( b ) ); } - template - void log( const Level l, std::string s, std::string msg ) const - { - i_log( l, std::move( s ), std::move( msg ) ); - } - - template ::value>> - void log( const Level l, std::string s, const FORMATTER& formatter, ARGS&&... args ) const - { - i_log( l, std::move( s ), formatter( std::forward( args )... ) ); - } + template = 201703L + , + typename = std::enable_if_t> +#endif + > - template void log( const Level l, std::string s, ARG1&& arg1, ARGS&&... args ) const { i_log( l, std::move( s ), FORMATTER{}( std::forward( arg1 ), std::forward( args )... ) ); } - template ::value || - std::is_same::value )>> - void log( const Level l, const SOURCE s, ARGS&&... args ) const +#if __cplusplus >= 201703L + template >> + void log( const Level l, std::string s, const FORMATTER& formatter, ARGS&&... args ) const { - log( l, s->name(), std::forward( args )... ); + i_log( l, std::move( s ), std::invoke( formatter, std::forward( args )... ) ); } +#endif template void registerLogger( Logger& logger ) @@ -109,8 +108,7 @@ namespace Gaudi void unregister( Link* link ) { - log( Level::VERBOSE, "Gaudi::Logging", - [link]() -> std::string { return fmt::format( "unregistering {}", static_cast( link ) ); } ); + log( Level::VERBOSE, "Gaudi::Logging", "unregistering {}", static_cast( link ) ); auto pos = find( begin( m_loggers ), end( m_loggers ), link ); if ( pos != end( m_loggers ) ) { m_loggers.erase( pos ); @@ -131,9 +129,7 @@ namespace Gaudi std::vector lines; boost::algorithm::split( lines, msg, []( char c ) { return c == '\n'; } ); for ( const auto& line : lines ) { - fmt::MemoryWriter writer; - writer.write( "{:<20} {:7} {}", std::move( source ), levelName( l ), line ); - m_backend->process( writer.str() ); + m_backend->process( fmt::format( "{:<20} {:7} {}", std::move( source ), levelName( l ), line ) ); } } @@ -153,7 +149,7 @@ namespace Gaudi inline void log( const Level l, ARGS&&... args ) const { if ( m_logging.enabled( l ) ) - m_logging->log( l, static_cast( this ), std::forward( args )... ); + m_logging->log( l, static_cast( this )->name(), std::forward( args )... ); } public: diff --git a/GaudiKernel/Gaudi/LoggingFormatters.h b/GaudiKernel/Gaudi/LoggingFormatters.h index 9342c660c7..525065f431 100644 --- a/GaudiKernel/Gaudi/LoggingFormatters.h +++ b/GaudiKernel/Gaudi/LoggingFormatters.h @@ -6,39 +6,49 @@ namespace Gaudi { namespace LoggingFormatters { - struct Stream { - template - Stream( ARG&& arg ) +#if __cplusplus >= 201703L + struct iostream final { + template + inline std::string operator()( ARGS&&... args ) const { - out << std::forward( arg ); + std::stringstream out; + ( out << ... << std::forward( args ) ); + return out.str(); + } + }; +#else + struct iostream final { + template + inline std::string operator()( ARGS&&... args ) const + { + std::stringstream out; + return this->impl( out, std::forward( args )... ); } - inline std::string operator()() const { return out.str(); } + private: template - inline std::string operator()( ARG&& arg, ARGS&&... args ) const + inline std::string impl( std::stringstream& out, ARG&& arg, ARGS&&... args ) const { out << std::forward( arg ); - return ( *this )( std::forward( args )... ); + return impl( out, std::forward( args )... ); } - - private: - mutable std::stringstream out; + inline std::string impl( std::stringstream& out ) const { return out.str(); } }; +#endif - struct fmtlib { - template - fmtlib( ARG&& arg ) : first_arg{std::forward( arg )} + struct fmtlib final { + template + std::string operator()( ARGS&&... args ) { + return fmt::format( std::forward( args )... ); } - - template - inline std::string operator()( ARGS&&... args ) const +#if __cplusplus < 201703L + template ::type> + std::string operator()( FUNCTION&& func, ARGS&&... args ) { - return fmt::format( first_arg, std::forward( args )... ); + return func( std::forward( args )... ); } - - private: - fmt::CStringRef first_arg; +#endif }; } } diff --git a/GaudiKernel/tests/qmtest/gaudikernel.qms/logging.qmt b/GaudiKernel/tests/qmtest/gaudikernel.qms/logging_cpp14.qmt similarity index 86% rename from GaudiKernel/tests/qmtest/gaudikernel.qms/logging.qmt rename to GaudiKernel/tests/qmtest/gaudikernel.qms/logging_cpp14.qmt index e3a06bcc16..9a167653e2 100644 --- a/GaudiKernel/tests/qmtest/gaudikernel.qms/logging.qmt +++ b/GaudiKernel/tests/qmtest/gaudikernel.qms/logging_cpp14.qmt @@ -1,6 +1,6 @@ -test_Logging.exe +test_Logging_14.exe true refs/Logging.ref refs/Logging.err.ref diff --git a/GaudiKernel/tests/qmtest/gaudikernel.qms/logging_cpp17.qmt b/GaudiKernel/tests/qmtest/gaudikernel.qms/logging_cpp17.qmt new file mode 100644 index 0000000000..34de1e959b --- /dev/null +++ b/GaudiKernel/tests/qmtest/gaudikernel.qms/logging_cpp17.qmt @@ -0,0 +1,16 @@ + + +test_Logging_17.exe +true +refs/Logging.ref +refs/Logging.err.ref + +preprocessor = normalizeExamples + \ + RegexpReplacer(when = "implementation", + orig = r"C\+\+14", + repl = r"C++17") + +validateWithReference(preproc = preprocessor) + +gcc[^7] + diff --git a/GaudiKernel/tests/qmtest/refs/Logging.err.ref b/GaudiKernel/tests/qmtest/refs/Logging.err.ref index 50079fdbd8..a648074051 100644 --- a/GaudiKernel/tests/qmtest/refs/Logging.err.ref +++ b/GaudiKernel/tests/qmtest/refs/Logging.err.ref @@ -8,7 +8,6 @@ sent over network: 'instance-3 INFO we can use streamers with modif sent over network: 'instance-3 WARNING and this is a warning' sent over network: 'instance-3 INFO a printf example: 123.450' sent over network: 'instance-3 INFO a fmt::format example: 123.450' -sent over network: 'instance-3 INFO a fmt::format example: 123.450' sent over network: 'instance-3 INFO what' sent over network: 'instance-3 INFO about' sent over network: 'instance-3 INFO multi' diff --git a/GaudiKernel/tests/qmtest/refs/Logging.ref b/GaudiKernel/tests/qmtest/refs/Logging.ref index 6240432f02..77162fa887 100644 --- a/GaudiKernel/tests/qmtest/refs/Logging.ref +++ b/GaudiKernel/tests/qmtest/refs/Logging.ref @@ -1,3 +1,4 @@ +=== C++14 implementation === construct Logging === construct loggers === register loggers @@ -11,7 +12,6 @@ instance-1 INFO we can use streamers with modifiers: 0x002a instance-1 WARNING and this is a warning instance-1 INFO a printf example: 123.450 instance-1 INFO a fmt::format example: 123.450 -instance-1 INFO a fmt::format example: 123.450 instance-1 INFO what instance-1 INFO about instance-1 INFO multi @@ -25,7 +25,6 @@ instance-2 INFO we can use streamers with modifiers: 0x002a instance-2 WARNING and this is a warning instance-2 INFO a printf example: 123.450 instance-2 INFO a fmt::format example: 123.450 -instance-2 INFO a fmt::format example: 123.450 instance-2 INFO what instance-2 INFO about instance-2 INFO multi diff --git a/GaudiKernel/tests/src/test_Logging.cpp b/GaudiKernel/tests/src/test_Logging.cpp index 4b7f0f4036..682ca69811 100644 --- a/GaudiKernel/tests/src/test_Logging.cpp +++ b/GaudiKernel/tests/src/test_Logging.cpp @@ -23,9 +23,7 @@ struct fmtlib2 { template std::string operator()( ARGS&&... args ) { - fmt::MemoryWriter w; - w.write( std::forward( args )... ); - return w.str(); + return fmt::format( std::forward( args )... ); } }; @@ -42,11 +40,10 @@ public: info( "plain string" ); info( []() -> std::string { return "function without arguments"; } ); info( []( int i ) -> std::string { return "function with " + std::to_string( i ) + " arguments"; }, 1 ); - info( Stream{"we can use streamers with modifiers: 0x"}, std::hex, std::setw( 4 ), std::setfill( '0' ), 42 ); + info( "we can use streamers with modifiers: 0x", std::hex, std::setw( 4 ), std::setfill( '0' ), 42 ); warning( "and this is a warning" ); info( C_Rulez{"a %-12s example: %10.3f"}, "printf", 123.45 ); - info( fmtlib{"a {1:12} example: {0:10.3f}"}, 123.45, "fmt::format" ); - info( "a {1:12} example: {0:10.3f}", 123.45, "fmt::format" ); + info( "a {1:12} example: {0:10.3f}", 123.45, "fmt::format" ); info( "what\nabout\nmulti\nline?" ); } @@ -60,6 +57,11 @@ struct MyBackend : Gaudi::Logging::Backend { int main() { +#if __cplusplus < 201703L + std::cout << "=== C++14 implementation" << '\n'; +#else + std::cout << "=== C++17 implementation" << '\n'; +#endif { std::cout << "=== construct Logging" << '\n'; -- GitLab From dcd15934ac3720552b017d85c0caec7537320500 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Tue, 7 Nov 2017 17:23:06 +0100 Subject: [PATCH 42/53] Improve performance for non-printed messages and prevent segfaults --- GaudiKernel/Gaudi/Logging.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/GaudiKernel/Gaudi/Logging.h b/GaudiKernel/Gaudi/Logging.h index 386a116d21..cfc006493e 100644 --- a/GaudiKernel/Gaudi/Logging.h +++ b/GaudiKernel/Gaudi/Logging.h @@ -50,7 +50,9 @@ namespace Gaudi Logging* logging = nullptr; Level level = Level::INFO; - inline bool enabled( const Level l ) const { return UNLIKELY( logging && ( l >= level ) ); } + inline bool enabled( const Level l ) const { return l >= level; } + + inline operator bool() const { return logging; } inline Logging* operator->() const { @@ -108,7 +110,7 @@ namespace Gaudi void unregister( Link* link ) { - log( Level::VERBOSE, "Gaudi::Logging", "unregistering {}", static_cast( link ) ); + if ( m_backend ) log( Level::VERBOSE, "Gaudi::Logging", "unregistering {}", static_cast( link ) ); auto pos = find( begin( m_loggers ), end( m_loggers ), link ); if ( pos != end( m_loggers ) ) { m_loggers.erase( pos ); @@ -148,7 +150,7 @@ namespace Gaudi template inline void log( const Level l, ARGS&&... args ) const { - if ( m_logging.enabled( l ) ) + if ( UNLIKELY( m_logging.enabled( l ) && m_logging ) ) m_logging->log( l, static_cast( this )->name(), std::forward( args )... ); } -- GitLab From e19d84c9ef8c9e392c81bc0c543fa29f4a388cd0 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Tue, 7 Nov 2017 17:40:57 +0100 Subject: [PATCH 43/53] Reorganized Logging namespace --- GaudiKernel/Gaudi/Logging.h | 242 +++++++++++++------------ GaudiKernel/tests/src/test_Logging.cpp | 8 +- 2 files changed, 129 insertions(+), 121 deletions(-) diff --git a/GaudiKernel/Gaudi/Logging.h b/GaudiKernel/Gaudi/Logging.h index cfc006493e..86f995cee5 100644 --- a/GaudiKernel/Gaudi/Logging.h +++ b/GaudiKernel/Gaudi/Logging.h @@ -19,12 +19,13 @@ namespace Gaudi { - template - class Logger; - - class Logging + namespace Logging { - public: + template + class Logger; + + class Manager; + enum class Level { VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS }; static const std::string& levelName( Level l ) { @@ -33,31 +34,25 @@ namespace Gaudi return names.at( static_cast>( l ) ); } - using DefaultFormatter = LoggingFormatters::fmtlib; - struct Link final { - Link( Logging* logging_ = nullptr ) : logging{logging_} {} + Link( Manager* manager = nullptr ) : manager{manager} {} Link( const Link& ) = delete; Link& operator=( const Link& ) = delete; - ~Link() - { - if ( logging ) logging->unregister( this ); - logging = nullptr; - } + inline ~Link(); - Logging* logging = nullptr; + Manager* manager = nullptr; Level level = Level::INFO; inline bool enabled( const Level l ) const { return l >= level; } - inline operator bool() const { return logging; } + inline operator bool() const { return manager; } - inline Logging* operator->() const + inline Manager* operator->() const { - assert( logging ); - return logging; + assert( manager ); + return manager; } }; @@ -71,124 +66,137 @@ namespace Gaudi void process( std::string msg ) const override { fmt::print( "{}\n", msg ); } }; - Logging() = default; - Logging( std::unique_ptr b ) { setBackend( std::move( b ) ); } - - std::unique_ptr setBackend( std::unique_ptr b ) + class Manager { - if ( !b ) b = std::make_unique(); - return std::exchange( m_backend, std::move( b ) ); - } + public: + using DefaultFormatter = LoggingFormatters::fmtlib; - template = 201703L - , - typename = std::enable_if_t> -#endif - > + Manager() = default; + Manager( std::unique_ptr b ) { setBackend( std::move( b ) ); } - void log( const Level l, std::string s, ARG1&& arg1, ARGS&&... args ) const - { - i_log( l, std::move( s ), FORMATTER{}( std::forward( arg1 ), std::forward( args )... ) ); - } + std::unique_ptr setBackend( std::unique_ptr b ) + { + if ( !b ) b = std::make_unique(); + return std::exchange( m_backend, std::move( b ) ); + } + template = 201703L - template >> - void log( const Level l, std::string s, const FORMATTER& formatter, ARGS&&... args ) const - { - i_log( l, std::move( s ), std::invoke( formatter, std::forward( args )... ) ); - } + , + typename = std::enable_if_t> #endif + > - template - void registerLogger( Logger& logger ) - { - logger.m_logging.logging = this; - m_loggers.emplace_back( &logger.m_logging ); - } + void log( const Level l, std::string s, ARG1&& arg1, ARGS&&... args ) const + { + i_log( l, std::move( s ), FORMATTER{}( std::forward( arg1 ), std::forward( args )... ) ); + } - void unregister( Link* link ) - { - if ( m_backend ) log( Level::VERBOSE, "Gaudi::Logging", "unregistering {}", static_cast( link ) ); - auto pos = find( begin( m_loggers ), end( m_loggers ), link ); - if ( pos != end( m_loggers ) ) { - m_loggers.erase( pos ); +#if __cplusplus >= 201703L + template >> + void log( const Level l, std::string s, const FORMATTER& formatter, ARGS&&... args ) const + { + i_log( l, std::move( s ), std::invoke( formatter, std::forward( args )... ) ); } - } +#endif - ~Logging() - { - for ( auto& link : m_loggers ) { - link->logging = nullptr; + template + void registerLogger( Logger& logger ) + { + logger.m_logging.manager = this; + m_loggers.emplace_back( &logger.m_logging ); } - } - private: - void i_log( const Level l, std::string source, const std::string& msg ) const - { - // FIXME use https://stackoverflow.com/a/28001459 - std::vector lines; - boost::algorithm::split( lines, msg, []( char c ) { return c == '\n'; } ); - for ( const auto& line : lines ) { - m_backend->process( fmt::format( "{:<20} {:7} {}", std::move( source ), levelName( l ), line ) ); + void unregister( Link* link ) + { + if ( m_backend ) + log( Level::VERBOSE, "Gaudi::Logging::Manager", "unregistering {}", static_cast( link ) ); + auto pos = find( begin( m_loggers ), end( m_loggers ), link ); + if ( pos != end( m_loggers ) ) { + m_loggers.erase( pos ); + } } - } - std::unique_ptr m_backend = std::make_unique(); - std::list m_loggers; - }; + ~Manager() + { + for ( auto& link : m_loggers ) { + link->manager = nullptr; + } + } - template - class Logger - { - friend Logging; - Logging::Link m_logging; + private: + void i_log( const Level l, std::string source, const std::string& msg ) const + { + // FIXME use https://stackoverflow.com/a/28001459 + std::vector lines; + boost::algorithm::split( lines, msg, []( char c ) { return c == '\n'; } ); + for ( const auto& line : lines ) { + fmt::MemoryWriter writer; + writer.write( "{:<20} {:7} {}", std::move( source ), levelName( l ), line ); + m_backend->process( writer.str() ); + } + } - using Level = Logging::Level; + std::unique_ptr m_backend = std::make_unique(); + std::list m_loggers; + }; - template - inline void log( const Level l, ARGS&&... args ) const + Link::~Link() { - if ( UNLIKELY( m_logging.enabled( l ) && m_logging ) ) - m_logging->log( l, static_cast( this )->name(), std::forward( args )... ); + if ( manager ) manager->unregister( this ); + manager = nullptr; } - public: - template - inline void verbose( ARGS&&... args ) const + template + class Logger { - log( Level::VERBOSE, std::forward( args )... ); - } - template - inline void debug( ARGS&&... args ) const - { - log( Level::DEBUG, std::forward( args )... ); - } - template - inline void info( ARGS&&... args ) const - { - log( Level::INFO, std::forward( args )... ); - } - template - inline void warning( ARGS&&... args ) const - { - log( Level::WARNING, std::forward( args )... ); - } - template - inline void error( ARGS&&... args ) const - { - log( Level::ERROR, std::forward( args )... ); - } - template - inline void fatal( ARGS&&... args ) const - { - log( Level::FATAL, std::forward( args )... ); - } - template - inline void print( ARGS&&... args ) const - { - log( Level::ALWAYS, std::forward( args )... ); - } - }; + friend Manager; + Link m_logging; + + template + inline void log( const Level l, ARGS&&... args ) const + { + if ( UNLIKELY( m_logging.enabled( l ) && m_logging ) ) + m_logging->log( l, static_cast( this )->name(), std::forward( args )... ); + } + + public: + template + inline void verbose( ARGS&&... args ) const + { + log( Level::VERBOSE, std::forward( args )... ); + } + template + inline void debug( ARGS&&... args ) const + { + log( Level::DEBUG, std::forward( args )... ); + } + template + inline void info( ARGS&&... args ) const + { + log( Level::INFO, std::forward( args )... ); + } + template + inline void warning( ARGS&&... args ) const + { + log( Level::WARNING, std::forward( args )... ); + } + template + inline void error( ARGS&&... args ) const + { + log( Level::ERROR, std::forward( args )... ); + } + template + inline void fatal( ARGS&&... args ) const + { + log( Level::FATAL, std::forward( args )... ); + } + template + inline void print( ARGS&&... args ) const + { + log( Level::ALWAYS, std::forward( args )... ); + } + }; + } } diff --git a/GaudiKernel/tests/src/test_Logging.cpp b/GaudiKernel/tests/src/test_Logging.cpp index 682ca69811..8e378b5d59 100644 --- a/GaudiKernel/tests/src/test_Logging.cpp +++ b/GaudiKernel/tests/src/test_Logging.cpp @@ -27,7 +27,7 @@ struct fmtlib2 { } }; -class MyStuff : public Gaudi::Logger +class MyStuff : public Gaudi::Logging::Logger { public: MyStuff( std::string name ) : m_name{std::move( name )} {} @@ -65,7 +65,7 @@ int main() { std::cout << "=== construct Logging" << '\n'; - Gaudi::Logging logging; + Gaudi::Logging::Manager logging; std::cout << "=== construct loggers" << '\n'; @@ -90,8 +90,8 @@ int main() { std::cerr << "=== custom backend" << '\n'; - Gaudi::Logging netLog{std::make_unique()}; - MyStuff netStuff{"instance-3"}; + Gaudi::Logging::Manager netLog{std::make_unique()}; + MyStuff netStuff{"instance-3"}; netLog.registerLogger( netStuff ); netStuff.print( "over nework" ); -- GitLab From c2f0e7cba2f123397ff69c304f8fe229e7eae850 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Wed, 8 Nov 2017 00:19:51 +0100 Subject: [PATCH 44/53] Reorganization of Logging headers and code --- GaudiKernel/CMakeLists.txt | 19 +- GaudiKernel/Gaudi/Logging.h | 206 +----------------- GaudiKernel/Gaudi/Logging/Backend.h | 21 ++ GaudiKernel/Gaudi/Logging/Formatters.h | 61 ++++++ GaudiKernel/Gaudi/Logging/Level.h | 18 ++ GaudiKernel/Gaudi/Logging/Link.h | 35 +++ GaudiKernel/Gaudi/Logging/Logger.h | 68 ++++++ GaudiKernel/Gaudi/Logging/Manager.h | 72 ++++++ GaudiKernel/Gaudi/LoggingFormatters.h | 54 ----- GaudiKernel/src/Lib/Logging.cpp | 56 +++++ GaudiKernel/tests/qmtest/refs/Logging.err.ref | 2 +- GaudiKernel/tests/qmtest/refs/Logging.ref | 4 +- GaudiKernel/tests/src/test_Logging.cpp | 4 +- 13 files changed, 354 insertions(+), 266 deletions(-) create mode 100644 GaudiKernel/Gaudi/Logging/Backend.h create mode 100644 GaudiKernel/Gaudi/Logging/Formatters.h create mode 100644 GaudiKernel/Gaudi/Logging/Level.h create mode 100644 GaudiKernel/Gaudi/Logging/Link.h create mode 100644 GaudiKernel/Gaudi/Logging/Logger.h create mode 100644 GaudiKernel/Gaudi/Logging/Manager.h delete mode 100644 GaudiKernel/Gaudi/LoggingFormatters.h create mode 100644 GaudiKernel/src/Lib/Logging.cpp diff --git a/GaudiKernel/CMakeLists.txt b/GaudiKernel/CMakeLists.txt index fa0c219577..ca118e4078 100644 --- a/GaudiKernel/CMakeLists.txt +++ b/GaudiKernel/CMakeLists.txt @@ -50,11 +50,15 @@ if(NOT USE_INTERNAL_fmt) message(STATUS "fmtlib not found") set(USE_INTERNAL_fmt YES CACHE BOOL "using internal build of fmt") endif() + set(fmt_LIB fmt::fmt) endif() if(USE_INTERNAL_fmt) set(fmt_VERSION ${fmt_DEFAULT_VERSION}) message(STATUS "Building fmtlib ${fmt_VERSION}") + + set(fmt_LIB ${CMAKE_BINARY_DIR}/lib64/libfmt.a) + include(ExternalProject) ExternalProject_Add(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git @@ -62,12 +66,15 @@ if(USE_INTERNAL_fmt) CMAKE_ARGS -DFMT_DOC=OFF -DFMT_TEST=OFF -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DCMAKE_BUILD_TYPE=Release + -DCMAKE_CXX_FLAGS=-fPIC + #-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + BUILD_BYPRODUCTS ${fmt_LIB} ${CMAKE_BINARY_DIR}/include/fmt/format.h ) # Ideally we could install directly to ${CMAKE_INSTALL_PREFIX}, but it # would not be available in this project. install(DIRECTORY ${CMAKE_BINARY_DIR}/include/fmt DESTINATION include) - install(DIRECTORY ${CMAKE_BINARY_DIR}/lib/cmake/fmt DESTINATION lib/cmake) - install(FILES ${CMAKE_BINARY_DIR}/lib/libfmt.a DESTINATION lib) + install(DIRECTORY ${CMAKE_BINARY_DIR}/lib64/cmake/fmt DESTINATION lib/cmake) + install(FILES ${fmt_LIB} DESTINATION lib) endif() # Extra settings when building on MacOS: @@ -91,11 +98,11 @@ endif() #---Libraries--------------------------------------------------------------- gaudi_add_library(GaudiKernel src/Lib/*.cpp ${extra_sources} LINK_LIBRARIES ${CMAKE_DL_LIBS} Boost ROOT TBB GaudiPluginService ${extra_libraries} - INCLUDE_DIRS Boost ROOT TBB cppgsl + INCLUDE_DIRS Boost ROOT TBB cppgsl ${fmt_INCLUDE_DIRS} PUBLIC_HEADERS Gaudi GaudiKernel) +target_link_libraries(GaudiKernel ${fmt_LIB}) if(USE_INTERNAL_fmt) - # make sure fmt is built before GaudiKernel add_dependencies(GaudiKernel fmt) endif() @@ -208,7 +215,7 @@ gaudi_add_unit_test(test_reverse tests/src/test_reverse.cpp gaudi_add_compile_test(test_StatusCodeFail tests/src/test_StatusCode_fail.cxx ERRORS "FAIL01;FAIL02;FAIL03;FAIL04") -add_executable( test_Logging_14 tests/src/test_Logging.cpp ) +add_executable( test_Logging_14 tests/src/test_Logging.cpp src/Lib/Logging.cpp ) set_target_properties(test_Logging_14 PROPERTIES COMPILE_FLAGS "-std=c++14") if(USE_INTERNAL_fmt) add_dependencies(test_Logging_14 fmt) @@ -218,7 +225,7 @@ else() endif() if(BINARY_TAG_COMP_NAME STREQUAL "gcc" AND NOT BINARY_TAG_COMP_VERSION VERSION_LESS "7.0") - add_executable( test_Logging_17 tests/src/test_Logging.cpp ) + add_executable( test_Logging_17 tests/src/test_Logging.cpp src/Lib/Logging.cpp ) set_target_properties(test_Logging_17 PROPERTIES COMPILE_FLAGS "-std=c++17") if(USE_INTERNAL_fmt) add_dependencies(test_Logging_17 fmt) diff --git a/GaudiKernel/Gaudi/Logging.h b/GaudiKernel/Gaudi/Logging.h index 86f995cee5..81989a9d62 100644 --- a/GaudiKernel/Gaudi/Logging.h +++ b/GaudiKernel/Gaudi/Logging.h @@ -1,202 +1,8 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include "GaudiKernel/Kernel.h" - -#include "Gaudi/LoggingFormatters.h" - -namespace Gaudi -{ - namespace Logging - { - template - class Logger; - - class Manager; - - enum class Level { VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS }; - static const std::string& levelName( Level l ) - { - const static std::array names = {"VERBOSE", "DEBUG", "INFO", "WARNING", - "ERROR", "FATAL", "ALWAYS"}; - return names.at( static_cast>( l ) ); - } - - struct Link final { - Link( Manager* manager = nullptr ) : manager{manager} {} - - Link( const Link& ) = delete; - Link& operator=( const Link& ) = delete; - - inline ~Link(); - - Manager* manager = nullptr; - Level level = Level::INFO; - - inline bool enabled( const Level l ) const { return l >= level; } - - inline operator bool() const { return manager; } - - inline Manager* operator->() const - { - assert( manager ); - return manager; - } - }; - - struct Backend { - virtual ~Backend() = default; - - virtual void process( std::string msg ) const = 0; - }; - - struct DefaultBackend : Backend { - void process( std::string msg ) const override { fmt::print( "{}\n", msg ); } - }; - - class Manager - { - public: - using DefaultFormatter = LoggingFormatters::fmtlib; - - Manager() = default; - Manager( std::unique_ptr b ) { setBackend( std::move( b ) ); } - - std::unique_ptr setBackend( std::unique_ptr b ) - { - if ( !b ) b = std::make_unique(); - return std::exchange( m_backend, std::move( b ) ); - } - - template = 201703L - , - typename = std::enable_if_t> -#endif - > - - void log( const Level l, std::string s, ARG1&& arg1, ARGS&&... args ) const - { - i_log( l, std::move( s ), FORMATTER{}( std::forward( arg1 ), std::forward( args )... ) ); - } - -#if __cplusplus >= 201703L - template >> - void log( const Level l, std::string s, const FORMATTER& formatter, ARGS&&... args ) const - { - i_log( l, std::move( s ), std::invoke( formatter, std::forward( args )... ) ); - } -#endif - - template - void registerLogger( Logger& logger ) - { - logger.m_logging.manager = this; - m_loggers.emplace_back( &logger.m_logging ); - } - - void unregister( Link* link ) - { - if ( m_backend ) - log( Level::VERBOSE, "Gaudi::Logging::Manager", "unregistering {}", static_cast( link ) ); - auto pos = find( begin( m_loggers ), end( m_loggers ), link ); - if ( pos != end( m_loggers ) ) { - m_loggers.erase( pos ); - } - } - - ~Manager() - { - for ( auto& link : m_loggers ) { - link->manager = nullptr; - } - } - - private: - void i_log( const Level l, std::string source, const std::string& msg ) const - { - // FIXME use https://stackoverflow.com/a/28001459 - std::vector lines; - boost::algorithm::split( lines, msg, []( char c ) { return c == '\n'; } ); - for ( const auto& line : lines ) { - fmt::MemoryWriter writer; - writer.write( "{:<20} {:7} {}", std::move( source ), levelName( l ), line ); - m_backend->process( writer.str() ); - } - } - - std::unique_ptr m_backend = std::make_unique(); - std::list m_loggers; - }; - - Link::~Link() - { - if ( manager ) manager->unregister( this ); - manager = nullptr; - } - - template - class Logger - { - friend Manager; - Link m_logging; - - template - inline void log( const Level l, ARGS&&... args ) const - { - if ( UNLIKELY( m_logging.enabled( l ) && m_logging ) ) - m_logging->log( l, static_cast( this )->name(), std::forward( args )... ); - } - - public: - template - inline void verbose( ARGS&&... args ) const - { - log( Level::VERBOSE, std::forward( args )... ); - } - template - inline void debug( ARGS&&... args ) const - { - log( Level::DEBUG, std::forward( args )... ); - } - template - inline void info( ARGS&&... args ) const - { - log( Level::INFO, std::forward( args )... ); - } - template - inline void warning( ARGS&&... args ) const - { - log( Level::WARNING, std::forward( args )... ); - } - template - inline void error( ARGS&&... args ) const - { - log( Level::ERROR, std::forward( args )... ); - } - template - inline void fatal( ARGS&&... args ) const - { - log( Level::FATAL, std::forward( args )... ); - } - template - inline void print( ARGS&&... args ) const - { - log( Level::ALWAYS, std::forward( args )... ); - } - }; - } -} +#include "Gaudi/Logging/Backend.h" +#include "Gaudi/Logging/Formatters.h" +#include "Gaudi/Logging/Level.h" +#include "Gaudi/Logging/Link.h" +#include "Gaudi/Logging/Logger.h" +#include "Gaudi/Logging/Manager.h" diff --git a/GaudiKernel/Gaudi/Logging/Backend.h b/GaudiKernel/Gaudi/Logging/Backend.h new file mode 100644 index 0000000000..15b6e0c58a --- /dev/null +++ b/GaudiKernel/Gaudi/Logging/Backend.h @@ -0,0 +1,21 @@ +#pragma once + +#include + +namespace Gaudi +{ + namespace Logging + { + struct Backend { + virtual ~Backend() = default; + + virtual void process( std::string msg ) const = 0; + }; + + struct StdOutBackend : Backend { + void process( std::string msg ) const override; + }; + + using DefaultBackend = StdOutBackend; + } +} diff --git a/GaudiKernel/Gaudi/Logging/Formatters.h b/GaudiKernel/Gaudi/Logging/Formatters.h new file mode 100644 index 0000000000..b0dad10c5c --- /dev/null +++ b/GaudiKernel/Gaudi/Logging/Formatters.h @@ -0,0 +1,61 @@ +#pragma once + +#include +#include +#include + +#include + +namespace Gaudi +{ + namespace Logging + { + namespace Formatters + { +#if __cplusplus >= 201703L + struct iostream final { + template + inline std::string operator()( ARGS&&... args ) const + { + std::stringstream out; + ( out << ... << std::forward( args ) ); + return out.str(); + } + }; +#else + struct iostream final { + template + inline std::string operator()( ARGS&&... args ) const + { + std::stringstream out; + return this->impl( out, std::forward( args )... ); + } + + private: + template + inline std::string impl( std::stringstream& out, ARG&& arg, ARGS&&... args ) const + { + out << std::forward( arg ); + return impl( out, std::forward( args )... ); + } + inline std::string impl( std::stringstream& out ) const { return out.str(); } + }; +#endif + + struct fmtlib final { + template + std::string operator()( ARGS&&... args ) + { + return fmt::format( std::forward( args )... ); + } +#if __cplusplus < 201703L + template ::type> + std::string operator()( FUNCTION&& func, ARGS&&... args ) + { + return func( std::forward( args )... ); + } +#endif + }; + } + } +} diff --git a/GaudiKernel/Gaudi/Logging/Level.h b/GaudiKernel/Gaudi/Logging/Level.h new file mode 100644 index 0000000000..7ec01d92aa --- /dev/null +++ b/GaudiKernel/Gaudi/Logging/Level.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +namespace Gaudi +{ + namespace Logging + { + enum class Level { VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS }; + + inline const std::string& levelName( Level l ) + { + const static std::array names = {"VERBOSE", "DEBUG", "INFO", "WARNING", + "ERROR", "FATAL", "ALWAYS"}; + return names.at( static_cast>( l ) ); + } + } +} diff --git a/GaudiKernel/Gaudi/Logging/Link.h b/GaudiKernel/Gaudi/Logging/Link.h new file mode 100644 index 0000000000..fa3711faa0 --- /dev/null +++ b/GaudiKernel/Gaudi/Logging/Link.h @@ -0,0 +1,35 @@ +#pragma once + +#include "Gaudi/Logging/Level.h" + +#include + +namespace Gaudi +{ + namespace Logging + { + class Manager; + + struct Link final { + Link( Manager* manager = nullptr ) : manager{manager} {} + + Link( const Link& ) = delete; + Link& operator=( const Link& ) = delete; + + ~Link(); + + Manager* manager = nullptr; + Level level = Level::INFO; + + inline bool enabled( const Level l ) const { return l >= level; } + + inline operator bool() const { return manager; } + + inline Manager* operator->() const + { + assert( manager ); + return manager; + } + }; + } +} diff --git a/GaudiKernel/Gaudi/Logging/Logger.h b/GaudiKernel/Gaudi/Logging/Logger.h new file mode 100644 index 0000000000..9dc3cf9a33 --- /dev/null +++ b/GaudiKernel/Gaudi/Logging/Logger.h @@ -0,0 +1,68 @@ +#pragma once + +#include "Gaudi/Logging/Level.h" +#include "Gaudi/Logging/Link.h" +#include "Gaudi/Logging/Manager.h" + +// For UNLIKELY +#include "GaudiKernel/Kernel.h" + +// for std::forward +#include + +namespace Gaudi +{ + namespace Logging + { + template + class Logger + { + friend Manager; + Link m_logging; + + template + inline void log( const Level l, ARGS&&... args ) const + { + if ( UNLIKELY( m_logging.enabled( l ) && m_logging ) ) + m_logging->log( l, static_cast( this )->name(), std::forward( args )... ); + } + + public: + template + inline void verbose( ARGS&&... args ) const + { + log( Level::VERBOSE, std::forward( args )... ); + } + template + inline void debug( ARGS&&... args ) const + { + log( Level::DEBUG, std::forward( args )... ); + } + template + inline void info( ARGS&&... args ) const + { + log( Level::INFO, std::forward( args )... ); + } + template + inline void warning( ARGS&&... args ) const + { + log( Level::WARNING, std::forward( args )... ); + } + template + inline void error( ARGS&&... args ) const + { + log( Level::ERROR, std::forward( args )... ); + } + template + inline void fatal( ARGS&&... args ) const + { + log( Level::FATAL, std::forward( args )... ); + } + template + inline void print( ARGS&&... args ) const + { + log( Level::ALWAYS, std::forward( args )... ); + } + }; + } +} diff --git a/GaudiKernel/Gaudi/Logging/Manager.h b/GaudiKernel/Gaudi/Logging/Manager.h new file mode 100644 index 0000000000..c103b07968 --- /dev/null +++ b/GaudiKernel/Gaudi/Logging/Manager.h @@ -0,0 +1,72 @@ +#pragma once + +#include "Gaudi/Logging/Backend.h" +#include "Gaudi/Logging/Formatters.h" +#include "Gaudi/Logging/Level.h" + +#include +#include +#include +#include +#include +#include + +namespace Gaudi +{ + namespace Logging + { + template + class Logger; + + struct Link; + + class Manager + { + public: + using DefaultFormatter = Formatters::fmtlib; + + Manager() = default; + Manager( std::unique_ptr b ); + + std::unique_ptr setBackend( std::unique_ptr b ); + + template = 201703L + , + typename = std::enable_if_t> +#endif + > + + void log( const Level l, std::string s, ARG1&& arg1, ARGS&&... args ) const + { + i_log( l, std::move( s ), FORMATTER{}( std::forward( arg1 ), std::forward( args )... ) ); + } + +#if __cplusplus >= 201703L + template >> + void log( const Level l, std::string s, const FORMATTER& formatter, ARGS&&... args ) const + { + i_log( l, std::move( s ), std::invoke( formatter, std::forward( args )... ) ); + } +#endif + + template + void registerLogger( Logger& logger ) + { + logger.m_logging.manager = this; + m_loggers.emplace_back( &logger.m_logging ); + } + + void unregister( Link* link ); + + ~Manager(); + + private: + void i_log( const Level l, std::string source, const std::string& msg ) const; + + std::unique_ptr m_backend = std::make_unique(); + std::list m_loggers; + }; + } +} diff --git a/GaudiKernel/Gaudi/LoggingFormatters.h b/GaudiKernel/Gaudi/LoggingFormatters.h deleted file mode 100644 index 525065f431..0000000000 --- a/GaudiKernel/Gaudi/LoggingFormatters.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include - -namespace Gaudi -{ - namespace LoggingFormatters - { -#if __cplusplus >= 201703L - struct iostream final { - template - inline std::string operator()( ARGS&&... args ) const - { - std::stringstream out; - ( out << ... << std::forward( args ) ); - return out.str(); - } - }; -#else - struct iostream final { - template - inline std::string operator()( ARGS&&... args ) const - { - std::stringstream out; - return this->impl( out, std::forward( args )... ); - } - - private: - template - inline std::string impl( std::stringstream& out, ARG&& arg, ARGS&&... args ) const - { - out << std::forward( arg ); - return impl( out, std::forward( args )... ); - } - inline std::string impl( std::stringstream& out ) const { return out.str(); } - }; -#endif - - struct fmtlib final { - template - std::string operator()( ARGS&&... args ) - { - return fmt::format( std::forward( args )... ); - } -#if __cplusplus < 201703L - template ::type> - std::string operator()( FUNCTION&& func, ARGS&&... args ) - { - return func( std::forward( args )... ); - } -#endif - }; - } -} diff --git a/GaudiKernel/src/Lib/Logging.cpp b/GaudiKernel/src/Lib/Logging.cpp new file mode 100644 index 0000000000..c7088af567 --- /dev/null +++ b/GaudiKernel/src/Lib/Logging.cpp @@ -0,0 +1,56 @@ +// Sources for non-inlined methods of Logging subsystem + +#include "Gaudi/Logging/Backend.h" +#include "Gaudi/Logging/Link.h" +#include "Gaudi/Logging/Manager.h" + +#include + +#include + +#include +#include + +using namespace Gaudi::Logging; + +Link::~Link() +{ + if ( manager ) manager->unregister( this ); + manager = nullptr; +} + +void StdOutBackend::process( std::string msg ) const { fmt::print( "{}\n", msg ); } + +Manager::Manager( std::unique_ptr b ) { setBackend( std::move( b ) ); } + +std::unique_ptr Manager::setBackend( std::unique_ptr b ) +{ + if ( !b ) b = std::make_unique(); + return std::exchange( m_backend, std::move( b ) ); +} + +void Manager::unregister( Link* link ) +{ + if ( m_backend ) log( Level::VERBOSE, "Gaudi::Logging::Manager", "unregistering {}", static_cast( link ) ); + auto pos = find( begin( m_loggers ), end( m_loggers ), link ); + if ( pos != end( m_loggers ) ) { + m_loggers.erase( pos ); + } +} + +Manager::~Manager() +{ + for ( auto& link : m_loggers ) { + link->manager = nullptr; + } +} + +void Manager::i_log( const Level l, std::string source, const std::string& msg ) const +{ + // FIXME use https://stackoverflow.com/a/28001459 + std::vector lines; + boost::algorithm::split( lines, msg, []( char c ) { return c == '\n'; } ); + for ( const auto& line : lines ) { + m_backend->process( fmt::format( "{:<20} {:7} {}", std::move( source ), levelName( l ), line ) ); + } +} diff --git a/GaudiKernel/tests/qmtest/refs/Logging.err.ref b/GaudiKernel/tests/qmtest/refs/Logging.err.ref index a648074051..4a1095f348 100644 --- a/GaudiKernel/tests/qmtest/refs/Logging.err.ref +++ b/GaudiKernel/tests/qmtest/refs/Logging.err.ref @@ -13,4 +13,4 @@ sent over network: 'instance-3 INFO about' sent over network: 'instance-3 INFO multi' sent over network: 'instance-3 INFO line?' === end of scope -sent over network: 'Gaudi::Logging VERBOSE unregistering 0x7ffd7e6cf910' +sent over network: 'Gaudi::Logging::Manager VERBOSE unregistering 0x7ffd7e6cf910' diff --git a/GaudiKernel/tests/qmtest/refs/Logging.ref b/GaudiKernel/tests/qmtest/refs/Logging.ref index 77162fa887..7adc55e7e6 100644 --- a/GaudiKernel/tests/qmtest/refs/Logging.ref +++ b/GaudiKernel/tests/qmtest/refs/Logging.ref @@ -30,5 +30,5 @@ instance-2 INFO about instance-2 INFO multi instance-2 INFO line? === end of scope -Gaudi::Logging VERBOSE unregistering 0x7ffed6ca4ef0 -Gaudi::Logging VERBOSE unregistering 0x7ffed6ca4ec0 +Gaudi::Logging::Manager VERBOSE unregistering 0x7ffed6ca4ef0 +Gaudi::Logging::Manager VERBOSE unregistering 0x7ffed6ca4ec0 diff --git a/GaudiKernel/tests/src/test_Logging.cpp b/GaudiKernel/tests/src/test_Logging.cpp index 8e378b5d59..37543cfa24 100644 --- a/GaudiKernel/tests/src/test_Logging.cpp +++ b/GaudiKernel/tests/src/test_Logging.cpp @@ -1,7 +1,5 @@ #include -#include - #include #include #include @@ -35,7 +33,7 @@ public: void exec() const { - using namespace Gaudi::LoggingFormatters; + using namespace Gaudi::Logging::Formatters; print( "entering exec()" ); info( "plain string" ); info( []() -> std::string { return "function without arguments"; } ); -- GitLab From 0e02918a85c3c9b1f72951269965497e44340056 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Mon, 13 Nov 2017 09:31:23 +0100 Subject: [PATCH 45/53] Add property OutputLevel to Gaudi::Logging::Logger --- GaudiKernel/CMakeLists.txt | 14 ++------------ GaudiKernel/Gaudi/Logging/Link.h | 6 ++++++ GaudiKernel/Gaudi/Logging/Logger.h | 5 +++++ GaudiKernel/src/Lib/Link.cpp | 12 ++++++++++++ GaudiKernel/tests/src/test_Logging.cpp | 6 ++++-- 5 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 GaudiKernel/src/Lib/Link.cpp diff --git a/GaudiKernel/CMakeLists.txt b/GaudiKernel/CMakeLists.txt index ca118e4078..117790f23d 100644 --- a/GaudiKernel/CMakeLists.txt +++ b/GaudiKernel/CMakeLists.txt @@ -217,22 +217,12 @@ gaudi_add_compile_test(test_StatusCodeFail tests/src/test_StatusCode_fail.cxx add_executable( test_Logging_14 tests/src/test_Logging.cpp src/Lib/Logging.cpp ) set_target_properties(test_Logging_14 PROPERTIES COMPILE_FLAGS "-std=c++14") -if(USE_INTERNAL_fmt) - add_dependencies(test_Logging_14 fmt) - target_compile_definitions(test_Logging_14 PRIVATE FMT_HEADER_ONLY=1) -else() - target_link_libraries(test_Logging_14 fmt::fmt) -endif() +target_link_libraries(test_Logging_14 GaudiKernel) if(BINARY_TAG_COMP_NAME STREQUAL "gcc" AND NOT BINARY_TAG_COMP_VERSION VERSION_LESS "7.0") add_executable( test_Logging_17 tests/src/test_Logging.cpp src/Lib/Logging.cpp ) set_target_properties(test_Logging_17 PROPERTIES COMPILE_FLAGS "-std=c++17") - if(USE_INTERNAL_fmt) - add_dependencies(test_Logging_17 fmt) - target_compile_definitions(test_Logging_17 PRIVATE FMT_HEADER_ONLY=1) - else() - target_link_libraries(test_Logging_17 fmt::fmt) - endif() + target_link_libraries(test_Logging_17 GaudiKernel) endif() #---Dictionaries------------------------------------------------------------ diff --git a/GaudiKernel/Gaudi/Logging/Link.h b/GaudiKernel/Gaudi/Logging/Link.h index fa3711faa0..697a6e34b1 100644 --- a/GaudiKernel/Gaudi/Logging/Link.h +++ b/GaudiKernel/Gaudi/Logging/Link.h @@ -4,6 +4,9 @@ #include +// for std::underlying_type_t +#include + namespace Gaudi { namespace Logging @@ -30,6 +33,9 @@ namespace Gaudi assert( manager ); return manager; } + + using IntegerLevel = std::underlying_type_t; + IntegerLevel& integerLevel(); }; } } diff --git a/GaudiKernel/Gaudi/Logging/Logger.h b/GaudiKernel/Gaudi/Logging/Logger.h index 9dc3cf9a33..f01d56a05e 100644 --- a/GaudiKernel/Gaudi/Logging/Logger.h +++ b/GaudiKernel/Gaudi/Logging/Logger.h @@ -4,6 +4,8 @@ #include "Gaudi/Logging/Link.h" #include "Gaudi/Logging/Manager.h" +#include "GaudiKernel/Property.h" + // For UNLIKELY #include "GaudiKernel/Kernel.h" @@ -27,6 +29,9 @@ namespace Gaudi m_logging->log( l, static_cast( this )->name(), std::forward( args )... ); } + Gaudi::Property m_outputLevel{static_cast( this ), "OutputLevel", + m_logging.integerLevel()}; + public: template inline void verbose( ARGS&&... args ) const diff --git a/GaudiKernel/src/Lib/Link.cpp b/GaudiKernel/src/Lib/Link.cpp new file mode 100644 index 0000000000..0a6db7d5e5 --- /dev/null +++ b/GaudiKernel/src/Lib/Link.cpp @@ -0,0 +1,12 @@ +#include "Gaudi/Logging/Link.h" + +namespace Gaudi +{ + namespace Logging + { + Link::IntegerLevel& Link::integerLevel() + { + return *reinterpret_cast( &level ); + } + } +} diff --git a/GaudiKernel/tests/src/test_Logging.cpp b/GaudiKernel/tests/src/test_Logging.cpp index 37543cfa24..f12a949312 100644 --- a/GaudiKernel/tests/src/test_Logging.cpp +++ b/GaudiKernel/tests/src/test_Logging.cpp @@ -1,5 +1,7 @@ #include +#include "GaudiKernel/PropertyHolder.h" + #include #include #include @@ -25,11 +27,11 @@ struct fmtlib2 { } }; -class MyStuff : public Gaudi::Logging::Logger +class MyStuff : public PropertyHolder>, public Gaudi::Logging::Logger { public: MyStuff( std::string name ) : m_name{std::move( name )} {} - const std::string& name() const { return m_name; } + const std::string& name() const override { return m_name; } void exec() const { -- GitLab From 8ab2c93e53e23720aae5dcd2dbdb599d8543139b Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Mon, 13 Nov 2017 10:19:04 +0100 Subject: [PATCH 46/53] Use same numeric level for MSG:Level and Gaudi::Logging::Level --- GaudiKernel/Gaudi/Logging/Level.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GaudiKernel/Gaudi/Logging/Level.h b/GaudiKernel/Gaudi/Logging/Level.h index 7ec01d92aa..43ecec0bb1 100644 --- a/GaudiKernel/Gaudi/Logging/Level.h +++ b/GaudiKernel/Gaudi/Logging/Level.h @@ -6,12 +6,12 @@ namespace Gaudi { namespace Logging { - enum class Level { VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS }; + enum class Level { NIL, VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS }; inline const std::string& levelName( Level l ) { - const static std::array names = {"VERBOSE", "DEBUG", "INFO", "WARNING", - "ERROR", "FATAL", "ALWAYS"}; + const static std::array names = {"undefined", "VERBOSE", "DEBUG", "INFO", + "WARNING", "ERROR", "FATAL", "ALWAYS"}; return names.at( static_cast>( l ) ); } } -- GitLab From c2211a4b61bb00bd711c7ca0598af66de25f7aa6 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Thu, 23 Nov 2017 16:23:00 +0100 Subject: [PATCH 47/53] Dropped `Link` in favour of `std::weak_ptr` as side effects: - cleaned up a bit the interfaces - enabled `Gaudi::Property` --- GaudiKernel/Gaudi/Logging.h | 1 - GaudiKernel/Gaudi/Logging/LevelAsProperty.h | 18 ++++++++ GaudiKernel/Gaudi/Logging/Link.h | 41 ------------------- GaudiKernel/Gaudi/Logging/Logger.h | 25 +++++++---- GaudiKernel/Gaudi/Logging/Manager.h | 18 -------- GaudiKernel/src/Lib/Link.cpp | 12 ------ GaudiKernel/src/Lib/Logger.cpp | 27 ++++++++++++ GaudiKernel/src/Lib/Logging.cpp | 23 ----------- GaudiKernel/tests/qmtest/refs/Logging.err.ref | 1 - GaudiKernel/tests/qmtest/refs/Logging.ref | 2 - GaudiKernel/tests/src/test_Logging.cpp | 12 +++--- 11 files changed, 68 insertions(+), 112 deletions(-) create mode 100644 GaudiKernel/Gaudi/Logging/LevelAsProperty.h delete mode 100644 GaudiKernel/Gaudi/Logging/Link.h delete mode 100644 GaudiKernel/src/Lib/Link.cpp create mode 100644 GaudiKernel/src/Lib/Logger.cpp diff --git a/GaudiKernel/Gaudi/Logging.h b/GaudiKernel/Gaudi/Logging.h index 81989a9d62..458d529a2a 100644 --- a/GaudiKernel/Gaudi/Logging.h +++ b/GaudiKernel/Gaudi/Logging.h @@ -3,6 +3,5 @@ #include "Gaudi/Logging/Backend.h" #include "Gaudi/Logging/Formatters.h" #include "Gaudi/Logging/Level.h" -#include "Gaudi/Logging/Link.h" #include "Gaudi/Logging/Logger.h" #include "Gaudi/Logging/Manager.h" diff --git a/GaudiKernel/Gaudi/Logging/LevelAsProperty.h b/GaudiKernel/Gaudi/Logging/LevelAsProperty.h new file mode 100644 index 0000000000..59e62255b1 --- /dev/null +++ b/GaudiKernel/Gaudi/Logging/LevelAsProperty.h @@ -0,0 +1,18 @@ +#pragma once + +#include "Gaudi/Logging/Level.h" +#include "GaudiKernel/StatusCode.h" +#include +#include + +namespace Gaudi +{ + namespace Utils + { + std::ostream& toStream( const Logging::Level& lvl, std::ostream& s ); + } + namespace Parsers + { + StatusCode parse( Logging::Level& result, const std::string& input ); + } +} diff --git a/GaudiKernel/Gaudi/Logging/Link.h b/GaudiKernel/Gaudi/Logging/Link.h deleted file mode 100644 index 697a6e34b1..0000000000 --- a/GaudiKernel/Gaudi/Logging/Link.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include "Gaudi/Logging/Level.h" - -#include - -// for std::underlying_type_t -#include - -namespace Gaudi -{ - namespace Logging - { - class Manager; - - struct Link final { - Link( Manager* manager = nullptr ) : manager{manager} {} - - Link( const Link& ) = delete; - Link& operator=( const Link& ) = delete; - - ~Link(); - - Manager* manager = nullptr; - Level level = Level::INFO; - - inline bool enabled( const Level l ) const { return l >= level; } - - inline operator bool() const { return manager; } - - inline Manager* operator->() const - { - assert( manager ); - return manager; - } - - using IntegerLevel = std::underlying_type_t; - IntegerLevel& integerLevel(); - }; - } -} diff --git a/GaudiKernel/Gaudi/Logging/Logger.h b/GaudiKernel/Gaudi/Logging/Logger.h index f01d56a05e..d6c45e89f6 100644 --- a/GaudiKernel/Gaudi/Logging/Logger.h +++ b/GaudiKernel/Gaudi/Logging/Logger.h @@ -1,9 +1,10 @@ #pragma once #include "Gaudi/Logging/Level.h" -#include "Gaudi/Logging/Link.h" #include "Gaudi/Logging/Manager.h" +#include "Gaudi/Logging/LevelAsProperty.h" + #include "GaudiKernel/Property.h" // For UNLIKELY @@ -12,6 +13,9 @@ // for std::forward #include +// for std::weak_ptr +#include + namespace Gaudi { namespace Logging @@ -19,20 +23,25 @@ namespace Gaudi template class Logger { - friend Manager; - Link m_logging; + std::weak_ptr m_logging; + + Gaudi::Property m_level{static_cast( this ), "OutputLevel", Level::INFO}; + + inline bool enabled( const Level l ) const { return l >= m_level; } template inline void log( const Level l, ARGS&&... args ) const { - if ( UNLIKELY( m_logging.enabled( l ) && m_logging ) ) - m_logging->log( l, static_cast( this )->name(), std::forward( args )... ); + if ( UNLIKELY( enabled( l ) ) ) { + if ( auto mgr = m_logging.lock() ) + mgr->template log( l, static_cast( this )->name(), + std::forward( args )... ); + } } - Gaudi::Property m_outputLevel{static_cast( this ), "OutputLevel", - m_logging.integerLevel()}; - public: + void setLoggingManager( const std::shared_ptr& mgr ) { m_logging = mgr; } + template inline void verbose( ARGS&&... args ) const { diff --git a/GaudiKernel/Gaudi/Logging/Manager.h b/GaudiKernel/Gaudi/Logging/Manager.h index c103b07968..cb87f22d5d 100644 --- a/GaudiKernel/Gaudi/Logging/Manager.h +++ b/GaudiKernel/Gaudi/Logging/Manager.h @@ -5,7 +5,6 @@ #include "Gaudi/Logging/Level.h" #include -#include #include #include #include @@ -15,11 +14,6 @@ namespace Gaudi { namespace Logging { - template - class Logger; - - struct Link; - class Manager { public: @@ -51,22 +45,10 @@ namespace Gaudi } #endif - template - void registerLogger( Logger& logger ) - { - logger.m_logging.manager = this; - m_loggers.emplace_back( &logger.m_logging ); - } - - void unregister( Link* link ); - - ~Manager(); - private: void i_log( const Level l, std::string source, const std::string& msg ) const; std::unique_ptr m_backend = std::make_unique(); - std::list m_loggers; }; } } diff --git a/GaudiKernel/src/Lib/Link.cpp b/GaudiKernel/src/Lib/Link.cpp deleted file mode 100644 index 0a6db7d5e5..0000000000 --- a/GaudiKernel/src/Lib/Link.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "Gaudi/Logging/Link.h" - -namespace Gaudi -{ - namespace Logging - { - Link::IntegerLevel& Link::integerLevel() - { - return *reinterpret_cast( &level ); - } - } -} diff --git a/GaudiKernel/src/Lib/Logger.cpp b/GaudiKernel/src/Lib/Logger.cpp new file mode 100644 index 0000000000..e15a073f50 --- /dev/null +++ b/GaudiKernel/src/Lib/Logger.cpp @@ -0,0 +1,27 @@ +#include "Gaudi/Logging/Level.h" + +#include + +// for std::underlying_type_t +#include + +using Level = Gaudi::Logging::Level; +using IntLevel = std::underlying_type_t; + +namespace Gaudi +{ + namespace Utils + { + std::ostream& toStream( const Logging::Level& lvl, std::ostream& s ) + { + return s << *reinterpret_cast( const_cast( &lvl ) ); + } + } + namespace Parsers + { + StatusCode parse( Level& result, const std::string& input ) + { + return parse( *reinterpret_cast( &result ), input ); + } + } +} diff --git a/GaudiKernel/src/Lib/Logging.cpp b/GaudiKernel/src/Lib/Logging.cpp index c7088af567..206811314e 100644 --- a/GaudiKernel/src/Lib/Logging.cpp +++ b/GaudiKernel/src/Lib/Logging.cpp @@ -1,7 +1,6 @@ // Sources for non-inlined methods of Logging subsystem #include "Gaudi/Logging/Backend.h" -#include "Gaudi/Logging/Link.h" #include "Gaudi/Logging/Manager.h" #include @@ -13,12 +12,6 @@ using namespace Gaudi::Logging; -Link::~Link() -{ - if ( manager ) manager->unregister( this ); - manager = nullptr; -} - void StdOutBackend::process( std::string msg ) const { fmt::print( "{}\n", msg ); } Manager::Manager( std::unique_ptr b ) { setBackend( std::move( b ) ); } @@ -29,22 +22,6 @@ std::unique_ptr Manager::setBackend( std::unique_ptr b ) return std::exchange( m_backend, std::move( b ) ); } -void Manager::unregister( Link* link ) -{ - if ( m_backend ) log( Level::VERBOSE, "Gaudi::Logging::Manager", "unregistering {}", static_cast( link ) ); - auto pos = find( begin( m_loggers ), end( m_loggers ), link ); - if ( pos != end( m_loggers ) ) { - m_loggers.erase( pos ); - } -} - -Manager::~Manager() -{ - for ( auto& link : m_loggers ) { - link->manager = nullptr; - } -} - void Manager::i_log( const Level l, std::string source, const std::string& msg ) const { // FIXME use https://stackoverflow.com/a/28001459 diff --git a/GaudiKernel/tests/qmtest/refs/Logging.err.ref b/GaudiKernel/tests/qmtest/refs/Logging.err.ref index 4a1095f348..eb07cf9a54 100644 --- a/GaudiKernel/tests/qmtest/refs/Logging.err.ref +++ b/GaudiKernel/tests/qmtest/refs/Logging.err.ref @@ -13,4 +13,3 @@ sent over network: 'instance-3 INFO about' sent over network: 'instance-3 INFO multi' sent over network: 'instance-3 INFO line?' === end of scope -sent over network: 'Gaudi::Logging::Manager VERBOSE unregistering 0x7ffd7e6cf910' diff --git a/GaudiKernel/tests/qmtest/refs/Logging.ref b/GaudiKernel/tests/qmtest/refs/Logging.ref index 7adc55e7e6..586d000e90 100644 --- a/GaudiKernel/tests/qmtest/refs/Logging.ref +++ b/GaudiKernel/tests/qmtest/refs/Logging.ref @@ -30,5 +30,3 @@ instance-2 INFO about instance-2 INFO multi instance-2 INFO line? === end of scope -Gaudi::Logging::Manager VERBOSE unregistering 0x7ffed6ca4ef0 -Gaudi::Logging::Manager VERBOSE unregistering 0x7ffed6ca4ec0 diff --git a/GaudiKernel/tests/src/test_Logging.cpp b/GaudiKernel/tests/src/test_Logging.cpp index f12a949312..9c63d3afa8 100644 --- a/GaudiKernel/tests/src/test_Logging.cpp +++ b/GaudiKernel/tests/src/test_Logging.cpp @@ -65,7 +65,7 @@ int main() { std::cout << "=== construct Logging" << '\n'; - Gaudi::Logging::Manager logging; + auto logging = std::make_shared(); std::cout << "=== construct loggers" << '\n'; @@ -74,8 +74,8 @@ int main() std::cout << "=== register loggers" << '\n'; - logging.registerLogger( m ); - logging.registerLogger( n ); + m.setLoggingManager( logging ); + n.setLoggingManager( logging ); std::cout << "=== use loggers" << '\n'; @@ -90,9 +90,9 @@ int main() { std::cerr << "=== custom backend" << '\n'; - Gaudi::Logging::Manager netLog{std::make_unique()}; - MyStuff netStuff{"instance-3"}; - netLog.registerLogger( netStuff ); + auto netLog = std::make_shared( std::make_unique() ); + MyStuff netStuff{"instance-3"}; + netStuff.setLoggingManager( netLog ); netStuff.print( "over nework" ); netStuff.exec(); -- GitLab From 3e4d6a73f1c9d980e3cd63083e311b8854d6c5ad Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Fri, 24 Nov 2017 10:28:47 +0100 Subject: [PATCH 48/53] Added Gaudi::Logging::Context - delegate all formatting to the backend --- GaudiKernel/Gaudi/Logging/Backend.h | 6 ++++-- GaudiKernel/Gaudi/Logging/Context.h | 25 +++++++++++++++++++++++++ GaudiKernel/Gaudi/Logging/Logger.h | 6 +++--- GaudiKernel/src/Lib/Context.cpp | 18 ++++++++++++++++++ GaudiKernel/src/Lib/Logging.cpp | 17 ++++++++++------- GaudiKernel/tests/src/test_Logging.cpp | 14 +++++++++++++- 6 files changed, 73 insertions(+), 13 deletions(-) create mode 100644 GaudiKernel/Gaudi/Logging/Context.h create mode 100644 GaudiKernel/src/Lib/Context.cpp diff --git a/GaudiKernel/Gaudi/Logging/Backend.h b/GaudiKernel/Gaudi/Logging/Backend.h index 15b6e0c58a..bd2c9830cd 100644 --- a/GaudiKernel/Gaudi/Logging/Backend.h +++ b/GaudiKernel/Gaudi/Logging/Backend.h @@ -1,5 +1,7 @@ #pragma once +#include "Gaudi/Logging/Context.h" + #include namespace Gaudi @@ -9,11 +11,11 @@ namespace Gaudi struct Backend { virtual ~Backend() = default; - virtual void process( std::string msg ) const = 0; + virtual void process( const Context& ctx, const std::string& msg ) const = 0; }; struct StdOutBackend : Backend { - void process( std::string msg ) const override; + void process( const Context& ctx, const std::string& msg ) const override; }; using DefaultBackend = StdOutBackend; diff --git a/GaudiKernel/Gaudi/Logging/Context.h b/GaudiKernel/Gaudi/Logging/Context.h new file mode 100644 index 0000000000..16eb12f948 --- /dev/null +++ b/GaudiKernel/Gaudi/Logging/Context.h @@ -0,0 +1,25 @@ +#pragma once + +#include "Gaudi/Logging/Level.h" +#include "GaudiKernel/EventContext.h" + +#include + +namespace Gaudi +{ + namespace Logging + { + struct Context { + Context( std::string source, Level level ); + + std::string source; + Level level; + + EventContext evtCtx; + + pthread_t thread; + + std::chrono::system_clock::time_point time; + }; + } +} diff --git a/GaudiKernel/Gaudi/Logging/Logger.h b/GaudiKernel/Gaudi/Logging/Logger.h index d6c45e89f6..a2800b4847 100644 --- a/GaudiKernel/Gaudi/Logging/Logger.h +++ b/GaudiKernel/Gaudi/Logging/Logger.h @@ -23,7 +23,7 @@ namespace Gaudi template class Logger { - std::weak_ptr m_logging; + std::weak_ptr m_logMgr; Gaudi::Property m_level{static_cast( this ), "OutputLevel", Level::INFO}; @@ -33,14 +33,14 @@ namespace Gaudi inline void log( const Level l, ARGS&&... args ) const { if ( UNLIKELY( enabled( l ) ) ) { - if ( auto mgr = m_logging.lock() ) + if ( auto mgr = m_logMgr.lock() ) mgr->template log( l, static_cast( this )->name(), std::forward( args )... ); } } public: - void setLoggingManager( const std::shared_ptr& mgr ) { m_logging = mgr; } + void setLoggingManager( const std::shared_ptr& mgr ) { m_logMgr = mgr; } template inline void verbose( ARGS&&... args ) const diff --git a/GaudiKernel/src/Lib/Context.cpp b/GaudiKernel/src/Lib/Context.cpp new file mode 100644 index 0000000000..06d5788c37 --- /dev/null +++ b/GaudiKernel/src/Lib/Context.cpp @@ -0,0 +1,18 @@ +#include "Gaudi/Logging/Context.h" + +#include "GaudiKernel/ThreadLocalContext.h" + +namespace Gaudi +{ + namespace Logging + { + Context::Context( std::string source, Level level ) + : source{std::move( source )} + , level{level} + , evtCtx{Gaudi::Hive::currentContext()} + , thread{pthread_self()} + , time{std::chrono::system_clock::now()} + { + } + } +} diff --git a/GaudiKernel/src/Lib/Logging.cpp b/GaudiKernel/src/Lib/Logging.cpp index 206811314e..0a8ee77614 100644 --- a/GaudiKernel/src/Lib/Logging.cpp +++ b/GaudiKernel/src/Lib/Logging.cpp @@ -12,7 +12,15 @@ using namespace Gaudi::Logging; -void StdOutBackend::process( std::string msg ) const { fmt::print( "{}\n", msg ); } +void StdOutBackend::process( const Context& ctx, const std::string& msg ) const +{ + // FIXME use https://stackoverflow.com/a/28001459 + std::vector lines; + boost::algorithm::split( lines, msg, []( char c ) { return c == '\n'; } ); + for ( const auto& line : lines ) { + fmt::print( "{:<20} {:7} {}\n", ctx.source, levelName( ctx.level ), line ); + } +} Manager::Manager( std::unique_ptr b ) { setBackend( std::move( b ) ); } @@ -24,10 +32,5 @@ std::unique_ptr Manager::setBackend( std::unique_ptr b ) void Manager::i_log( const Level l, std::string source, const std::string& msg ) const { - // FIXME use https://stackoverflow.com/a/28001459 - std::vector lines; - boost::algorithm::split( lines, msg, []( char c ) { return c == '\n'; } ); - for ( const auto& line : lines ) { - m_backend->process( fmt::format( "{:<20} {:7} {}", std::move( source ), levelName( l ), line ) ); - } + m_backend->process( Context( std::move( source ), l ), msg ); } diff --git a/GaudiKernel/tests/src/test_Logging.cpp b/GaudiKernel/tests/src/test_Logging.cpp index 9c63d3afa8..174e39ce46 100644 --- a/GaudiKernel/tests/src/test_Logging.cpp +++ b/GaudiKernel/tests/src/test_Logging.cpp @@ -1,7 +1,10 @@ #include +#include #include "GaudiKernel/PropertyHolder.h" +#include + #include #include #include @@ -52,7 +55,16 @@ private: }; struct MyBackend : Gaudi::Logging::Backend { - void process( std::string msg ) const override { std::cerr << "sent over network: '" << msg << '\'' << '\n'; } + void process( const Gaudi::Logging::Context& ctx, const std::string& msg ) const override + { + // Copied from Logging.cpp and adapted for testing + // FIXME use https://stackoverflow.com/a/28001459 + std::vector lines; + boost::algorithm::split( lines, msg, []( char c ) { return c == '\n'; } ); + for ( const auto& line : lines ) { + fmt::print( stderr, "sent over network: '{:<20} {:7} {}'\n", ctx.source, levelName( ctx.level ), line ); + } + } }; int main() -- GitLab From 1b652d338d98e8f0a67c1a0297f8d082cdc363b9 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Tue, 28 Nov 2017 15:56:02 +0100 Subject: [PATCH 49/53] Do not rely on SmartIF(serviceLocator()) being ApplicationMgr --- .../HistogramPersistencySvc.cpp | 2 +- .../src/ApplicationMgr/AppMgrRunable.cpp | 25 ++++--------------- .../src/ApplicationMgr/AppMgrRunable.h | 6 +---- .../src/ApplicationMgr/EventLoopMgr.cpp | 2 +- GaudiCoreSvc/src/IncidentSvc/IncidentSvc.cpp | 2 +- GaudiExamples/src/Properties/PropertyAlg.cpp | 2 +- GaudiHive/src/AlgoExecutionTask.cpp | 2 +- GaudiHive/src/HiveSlimEventLoopMgr.cpp | 5 ++-- GaudiKernel/src/Lib/MinimalEventLoopMgr.cpp | 6 ++--- GaudiKernel/src/Util/genconf.cpp | 2 +- .../src/Services/PythonScriptingSvc.cpp | 2 +- GaudiSvc/src/NTupleSvc/NTupleSvc.cpp | 2 +- GaudiUtils/src/component/IODataManager.cpp | 2 +- GaudiUtils/src/component/SignalMonitorSvc.cpp | 2 +- 14 files changed, 21 insertions(+), 41 deletions(-) diff --git a/GaudiCommonSvc/src/HistogramPersistencySvc/HistogramPersistencySvc.cpp b/GaudiCommonSvc/src/HistogramPersistencySvc/HistogramPersistencySvc.cpp index 3b3d199742..cc7d3396c1 100644 --- a/GaudiCommonSvc/src/HistogramPersistencySvc/HistogramPersistencySvc.cpp +++ b/GaudiCommonSvc/src/HistogramPersistencySvc/HistogramPersistencySvc.cpp @@ -96,7 +96,7 @@ StatusCode HistogramPersistencySvc::initialize() StatusCode HistogramPersistencySvc::reinitialize() { // Obtain the IProperty of the ApplicationMgr - auto prpMgr = serviceLocator()->as(); + auto prpMgr = serviceLocator()->service( "ApplicationMgr" ).as(); if ( !prpMgr ) { fatal() << "IProperty interface not found in ApplicationMgr." << endmsg; return StatusCode::FAILURE; diff --git a/GaudiCoreSvc/src/ApplicationMgr/AppMgrRunable.cpp b/GaudiCoreSvc/src/ApplicationMgr/AppMgrRunable.cpp index 7c00aed249..ac5e634126 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/AppMgrRunable.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/AppMgrRunable.cpp @@ -15,37 +15,22 @@ StatusCode AppMgrRunable::initialize() { StatusCode sc = Service::initialize(); if ( sc.isSuccess() ) { - sc = serviceLocator()->queryInterface( IAppMgrUI::interfaceID(), pp_cast( &m_appMgrUI ) ); + m_appMgrUI = serviceLocator()->service( "ApplicationMgr" ); + if ( !m_appMgrUI ) error() << "Cannot get IAppMgrUI interface of ApplicationMgr" << endmsg; // get property from application manager if ( m_evtMax == (int)0xFEEDBABE ) { - auto props = serviceLocator()->as(); + auto props = serviceLocator()->service( "ApplicationMgr" ).as(); setProperty( props->getProperty( "EvtMax" ) ).ignore(); } } return sc; } -// IService implementation: initialize the service -StatusCode AppMgrRunable::start() -{ - StatusCode sc = Service::start(); - return sc; -} - -// IService implementation: initialize the service -StatusCode AppMgrRunable::stop() -{ - StatusCode sc = Service::stop(); - return sc; -} - // IService implementation: finalize the service StatusCode AppMgrRunable::finalize() { - StatusCode sc = Service::finalize(); - if ( m_appMgrUI ) m_appMgrUI->release(); - m_appMgrUI = nullptr; - return sc; + m_appMgrUI.reset(); + return Service::finalize(); } // IRunable implementation : Run the class implementation diff --git a/GaudiCoreSvc/src/ApplicationMgr/AppMgrRunable.h b/GaudiCoreSvc/src/ApplicationMgr/AppMgrRunable.h index 4da1ff5d72..09dbd892ab 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/AppMgrRunable.h +++ b/GaudiCoreSvc/src/ApplicationMgr/AppMgrRunable.h @@ -29,7 +29,7 @@ class AppMgrRunable : public extends { protected: /// Reference to application manager UI - IAppMgrUI* m_appMgrUI = nullptr; + SmartIF m_appMgrUI; Gaudi::Property m_evtMax{this, "EvtMax", 0xFEEDBABE, "number of events to be processed"}; public: @@ -38,10 +38,6 @@ public: /// IService implementation: initialize the service StatusCode initialize() override; - /// IService implementation: start the service - StatusCode start() override; - /// IService implementation: stop the service - StatusCode stop() override; /// IService implementation: finalize the service StatusCode finalize() override; /// IRunable implementation : Run the class implementation diff --git a/GaudiCoreSvc/src/ApplicationMgr/EventLoopMgr.cpp b/GaudiCoreSvc/src/ApplicationMgr/EventLoopMgr.cpp index c555fc0604..9f278c6a61 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/EventLoopMgr.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/EventLoopMgr.cpp @@ -54,7 +54,7 @@ StatusCode EventLoopMgr::initialize() } // Obtain the IProperty of the ApplicationMgr - m_appMgrProperty = serviceLocator(); + m_appMgrProperty = serviceLocator()->service( "ApplicationMgr" ); if ( !m_appMgrProperty ) { fatal() << "IProperty interface not found in ApplicationMgr." << endmsg; return StatusCode::FAILURE; diff --git a/GaudiCoreSvc/src/IncidentSvc/IncidentSvc.cpp b/GaudiCoreSvc/src/IncidentSvc/IncidentSvc.cpp index d6b644e341..a2de9fd1bf 100644 --- a/GaudiCoreSvc/src/IncidentSvc/IncidentSvc.cpp +++ b/GaudiCoreSvc/src/IncidentSvc/IncidentSvc.cpp @@ -156,7 +156,7 @@ void IncidentSvc::i_fireIncident( const Incident& incident, const std::string& l // Special case: FailInputFile incident must set the application return code if ( incident.type() == IncidentType::FailInputFile || incident.type() == IncidentType::CorruptedInputFile ) { - auto appmgr = serviceLocator()->as(); + auto appmgr = serviceLocator()->service( "ApplicationMgr" ).as(); Gaudi::setAppReturnCode( appmgr, incident.type() == IncidentType::FailInputFile ? Gaudi::ReturnCode::FailInput : Gaudi::ReturnCode::CorruptedInput ) diff --git a/GaudiExamples/src/Properties/PropertyAlg.cpp b/GaudiExamples/src/Properties/PropertyAlg.cpp index 412e8aaefd..75fb2a3026 100644 --- a/GaudiExamples/src/Properties/PropertyAlg.cpp +++ b/GaudiExamples/src/Properties/PropertyAlg.cpp @@ -177,7 +177,7 @@ StatusCode PropertyAlg::initialize() info() << "==========Checking Accesing Properties by string=========" << endmsg; - auto appmgr = serviceLocator()->as(); + auto appmgr = serviceLocator()->service( "ApplicationMgr" ).as(); // StatusCode sc = serviceLocator()->service("ApplicationMgr", appmgr); if ( !appmgr ) { error() << "Unable to locate the ApplicationMgr" << endmsg; diff --git a/GaudiHive/src/AlgoExecutionTask.cpp b/GaudiHive/src/AlgoExecutionTask.cpp index bd660440b8..8e2d176625 100644 --- a/GaudiHive/src/AlgoExecutionTask.cpp +++ b/GaudiHive/src/AlgoExecutionTask.cpp @@ -24,7 +24,7 @@ tbb::task* AlgoExecutionTask::execute() Gaudi::Hive::setCurrentContext( m_evtCtx ); // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard - const SmartIF appmgr( m_serviceLocator ); + const SmartIF appmgr = m_serviceLocator->service( "ApplicationMgr" ); SmartIF messageSvc( m_serviceLocator ); MsgStream log( messageSvc, "AlgoExecutionTask" ); diff --git a/GaudiHive/src/HiveSlimEventLoopMgr.cpp b/GaudiHive/src/HiveSlimEventLoopMgr.cpp index b1ddc3f958..1f6567a3c0 100644 --- a/GaudiHive/src/HiveSlimEventLoopMgr.cpp +++ b/GaudiHive/src/HiveSlimEventLoopMgr.cpp @@ -80,7 +80,7 @@ StatusCode HiveSlimEventLoopMgr::initialize() return StatusCode::FAILURE; } // Obtain the IProperty of the ApplicationMgr - m_appMgrProperty = serviceLocator(); + m_appMgrProperty = serviceLocator()->service( "ApplicationMgr" ); if ( !m_appMgrProperty ) { fatal() << "IProperty interface not found in ApplicationMgr." << endmsg; return StatusCode::FAILURE; @@ -375,8 +375,7 @@ StatusCode HiveSlimEventLoopMgr::executeRun( int maxevt ) StatusCode HiveSlimEventLoopMgr::stopRun() { // Set the application return code - auto appmgr = serviceLocator()->as(); - if ( Gaudi::setAppReturnCode( appmgr, Gaudi::ReturnCode::ScheduledStop ).isFailure() ) { + if ( Gaudi::setAppReturnCode( m_appMgrProperty, Gaudi::ReturnCode::ScheduledStop ).isFailure() ) { error() << "Could not set return code of the application (" << Gaudi::ReturnCode::ScheduledStop << ")" << endmsg; } m_scheduledStop = true; diff --git a/GaudiKernel/src/Lib/MinimalEventLoopMgr.cpp b/GaudiKernel/src/Lib/MinimalEventLoopMgr.cpp index 5a2810eae9..239f320e20 100644 --- a/GaudiKernel/src/Lib/MinimalEventLoopMgr.cpp +++ b/GaudiKernel/src/Lib/MinimalEventLoopMgr.cpp @@ -72,7 +72,7 @@ StatusCode MinimalEventLoopMgr::initialize() return StatusCode::FAILURE; } - auto prpMgr = serviceLocator()->as(); + auto prpMgr = serviceLocator()->service( "ApplicationMgr" ).as(); if ( !prpMgr ) { error() << "Error retrieving AppMgr interface IProperty." << endmsg; return StatusCode::FAILURE; @@ -383,7 +383,7 @@ StatusCode MinimalEventLoopMgr::executeEvent( void* /* par */ ) if ( m_WB.isValid() ) m_WB->selectStore( context.slot() ).ignore(); // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard - const auto appmgr = serviceLocator()->as(); + const auto appmgr = serviceLocator()->service( "ApplicationMgr" ).as(); // Call the execute() method of all top algorithms for ( auto& ita : m_topAlgList ) { StatusCode sc( StatusCode::FAILURE ); @@ -451,7 +451,7 @@ StatusCode MinimalEventLoopMgr::executeEvent( void* /* par */ ) StatusCode MinimalEventLoopMgr::stopRun() { // Set the application return code - auto appmgr = serviceLocator()->as(); + auto appmgr = serviceLocator()->service( "ApplicationMgr" ).as(); if ( Gaudi::setAppReturnCode( appmgr, Gaudi::ReturnCode::ScheduledStop ).isFailure() ) { error() << "Could not set return code of the application (" << Gaudi::ReturnCode::ScheduledStop << ")" << endmsg; } diff --git a/GaudiKernel/src/Util/genconf.cpp b/GaudiKernel/src/Util/genconf.cpp index ba436050c9..68c2b761d2 100644 --- a/GaudiKernel/src/Util/genconf.cpp +++ b/GaudiKernel/src/Util/genconf.cpp @@ -567,7 +567,7 @@ int configGenerator::genConfig( const Strings_t& libs, const string& userModule prop = SmartIF( Auditor::Factory::create( factoryName, cname, svcLoc ).release() ); break; case component_t::ApplicationMgr: - prop = SmartIF( svcLoc ); + prop = svcLoc->service( "ApplicationMgr" ); break; default: continue; // unknown diff --git a/GaudiPython/src/Services/PythonScriptingSvc.cpp b/GaudiPython/src/Services/PythonScriptingSvc.cpp index 261dcba51c..ffa1804cc1 100644 --- a/GaudiPython/src/Services/PythonScriptingSvc.cpp +++ b/GaudiPython/src/Services/PythonScriptingSvc.cpp @@ -44,7 +44,7 @@ StatusCode PythonScriptingSvc::initialize() // use the ApplicationMgr JobOptionsPath property as long as // the JobOptionsType property is set to "NONE". if ( m_startupScript.empty() ) { - auto prpMgr = serviceLocator()->as(); + auto prpMgr = serviceLocator()->service( "ApplicationMgr" ).as(); if ( prpMgr ) { Gaudi::Property tmp; tmp.assign( prpMgr->getProperty( "JobOptionsType" ) ); diff --git a/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp b/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp index 6994b886e0..ea6b9b7957 100644 --- a/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp +++ b/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp @@ -260,7 +260,7 @@ StatusCode NTupleSvc::createService( const std::string& /* nam */, const std::st { /// CGL: set the storage type // Get the value of the Stat persistancy mechanism from the AppMgr - auto appPropMgr = serviceLocator()->as(); + auto appPropMgr = serviceLocator()->service( "ApplicationMgr" ).as(); if ( !appPropMgr ) { // Report an error and return the FAILURE status code error() << "Could not get PropMgr" << endmsg; diff --git a/GaudiUtils/src/component/IODataManager.cpp b/GaudiUtils/src/component/IODataManager.cpp index 8272a36a4c..023293d889 100644 --- a/GaudiUtils/src/component/IODataManager.cpp +++ b/GaudiUtils/src/component/IODataManager.cpp @@ -278,7 +278,7 @@ StatusCode IODataManager::connectDataIO( int typ, IoType rw, CSTR dataset, CSTR } // keep track of the current return code before we start iterating over // replicas - auto appmgr = serviceLocator()->as(); + auto appmgr = serviceLocator()->service( "ApplicationMgr" ).as(); int origReturnCode = Gaudi::getAppReturnCode( appmgr ); for ( auto i = files.cbegin(); i != files.cend(); ++i ) { std::string pfn = i->first; diff --git a/GaudiUtils/src/component/SignalMonitorSvc.cpp b/GaudiUtils/src/component/SignalMonitorSvc.cpp index 445b3d0c16..0db46584d4 100644 --- a/GaudiUtils/src/component/SignalMonitorSvc.cpp +++ b/GaudiUtils/src/component/SignalMonitorSvc.cpp @@ -370,7 +370,7 @@ namespace Gaudi return StatusCode::FAILURE; } // Get the IMainAppStatus interface of the ApplicationMgr - m_appProperty = serviceLocator(); + m_appProperty = serviceLocator()->service( "ApplicationMgr" ); if ( !m_appProperty ) { warning() << "Cannot retrieve IProperty interface of ApplicationMgr, " "the return code will not be changed" -- GitLab From 51f90e5d7103fd90e331a4dc6af73c18d33a4a30 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Tue, 7 Nov 2017 17:46:07 +0100 Subject: [PATCH 50/53] Concurrent use of CommonMessaging and Gaudi::Logging::Logger It is possible to use any of the two implementations in all the components that used CommonMessaging. --- .../src/PersistencySvc/OutputStream.cpp | 4 +- .../src/ApplicationMgr/AlgorithmManager.cpp | 10 ++++- .../src/ApplicationMgr/AppMgrRunable.cpp | 2 +- .../src/ApplicationMgr/ApplicationMgr.cpp | 28 +++++++++++++- .../src/ApplicationMgr/ApplicationMgr.h | 5 +++ .../src/ApplicationMgr/EventLoopMgr.cpp | 6 +-- .../src/ApplicationMgr/ServiceManager.cpp | 10 ++++- GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp | 5 ++- GaudiCoreSvc/src/MessageSvc/MessageSvc.cpp | 13 +++---- .../ExtendedProperties/ArrayProperties.cpp | 2 + .../ExtendedProperties/ExtendedProperties.cpp | 1 + .../ExtendedProperties2.cpp | 1 + GaudiExamples/src/Histograms/Aida2Root.cpp | 37 +++++++------------ GaudiExamples/src/Maps/MapAlg.cpp | 8 ++-- .../src/MultipleLogStreams/QotdAlg.cpp | 5 ++- .../src/Properties/CustomPropertiesAlg.cpp | 2 + .../src/RandomNumber/RandomNumberAlg.cpp | 5 +-- GaudiExamples/src/Selections/SelFilter.cpp | 8 ++-- GaudiExamples/src/ToolHandles/Algorithms.cpp | 3 +- GaudiHive/src/CPUCruncher.cpp | 2 +- GaudiHive/src/HiveSlimEventLoopMgr.cpp | 4 +- GaudiHive/src/HiveWhiteBoard.cpp | 2 +- GaudiHive/src/PrecedenceRulesGraph.h | 23 +++++++++--- GaudiKernel/Gaudi/Logging/Logger.h | 3 ++ GaudiKernel/GaudiKernel/AlgTool.h | 22 +++++++++-- GaudiKernel/GaudiKernel/Algorithm.h | 21 ++++++++++- GaudiKernel/GaudiKernel/Auditor.h | 20 +++++++++- GaudiKernel/GaudiKernel/ComponentManager.h | 24 +++++++++++- GaudiKernel/GaudiKernel/IProperty.h | 6 +-- GaudiKernel/GaudiKernel/PropertyHolder.h | 10 +++++ GaudiKernel/GaudiKernel/PropertyMgr.h | 5 +++ GaudiKernel/GaudiKernel/Service.h | 24 +++++++++--- GaudiKernel/src/Lib/AlgTool.cpp | 12 +++--- GaudiKernel/src/Lib/Algorithm.cpp | 16 ++++---- GaudiKernel/src/Lib/Auditor.cpp | 13 ++++--- GaudiKernel/src/Lib/MinimalEventLoopMgr.cpp | 4 +- GaudiKernel/src/Lib/PropertyMgr.cpp | 11 ++++++ GaudiKernel/src/Lib/Service.cpp | 17 +++++---- GaudiMP/src/component/IoComponentMgr.cpp | 4 +- GaudiMP/src/component/RecordOutputStream.cpp | 3 -- GaudiMP/src/component/ReplayOutputStream.cpp | 6 +-- GaudiSvc/src/FileMgr/FileMgr.cpp | 4 +- 42 files changed, 290 insertions(+), 121 deletions(-) diff --git a/GaudiCommonSvc/src/PersistencySvc/OutputStream.cpp b/GaudiCommonSvc/src/PersistencySvc/OutputStream.cpp index 596ab1f927..205869331e 100644 --- a/GaudiCommonSvc/src/PersistencySvc/OutputStream.cpp +++ b/GaudiCommonSvc/src/PersistencySvc/OutputStream.cpp @@ -1,3 +1,5 @@ +#include "OutputStream.h" + // Framework include files #include "GaudiKernel/IAlgManager.h" #include "GaudiKernel/IConversionSvc.h" @@ -16,8 +18,6 @@ #include "GaudiKernel/MsgStream.h" #include "GaudiKernel/strcasecmp.h" -#include "OutputStream.h" - #include // Define the algorithm factory for the standard output data writer diff --git a/GaudiCoreSvc/src/ApplicationMgr/AlgorithmManager.cpp b/GaudiCoreSvc/src/ApplicationMgr/AlgorithmManager.cpp index 4e94096178..e044c9df45 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/AlgorithmManager.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/AlgorithmManager.cpp @@ -84,6 +84,12 @@ StatusCode AlgorithmManager::createAlgorithm( const std::string& algtype, const // this is needed to keep the reference count correct, since isValidInterface(algorithm) // implies an increment of the counter by 1 algorithm->release(); + auto actualAlg = dynamic_cast( algorithm ); + if ( actualAlg ) { + actualAlg->setLoggingManager( m_logMgr.lock() ); + } else { + warning() << actualalgtype << " does not seem to inherit from Algorithm" << endmsg; + } StatusCode rc; if ( managed ) { // Bring the created algorithm to the same state of the ApplicationMgr @@ -219,9 +225,9 @@ StatusCode AlgorithmManager::restart() void AlgorithmManager::outputLevelUpdate() { - resetMessaging(); + getProperty( "OutputLevel" ).fromString( std::to_string( resetMessaging() ) ); for ( auto& algItem : m_algs ) { const auto alg = dynamic_cast( algItem.algorithm.get() ); - if ( alg ) alg->resetMessaging(); + if ( alg ) alg->getProperty( "OutputLevel" ).fromString( std::to_string( alg->resetMessaging() ) ); } } diff --git a/GaudiCoreSvc/src/ApplicationMgr/AppMgrRunable.cpp b/GaudiCoreSvc/src/ApplicationMgr/AppMgrRunable.cpp index ac5e634126..1798314bbb 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/AppMgrRunable.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/AppMgrRunable.cpp @@ -16,7 +16,7 @@ StatusCode AppMgrRunable::initialize() StatusCode sc = Service::initialize(); if ( sc.isSuccess() ) { m_appMgrUI = serviceLocator()->service( "ApplicationMgr" ); - if ( !m_appMgrUI ) error() << "Cannot get IAppMgrUI interface of ApplicationMgr" << endmsg; + if ( !m_appMgrUI ) error( "Cannot get IAppMgrUI interface of ApplicationMgr" ); // get property from application manager if ( m_evtMax == (int)0xFEEDBABE ) { auto props = serviceLocator()->service( "ApplicationMgr" ).as(); diff --git a/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp b/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp index 55ab678a62..570031c47f 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp @@ -23,6 +23,9 @@ #include "GaudiCoreSvcVersion.h" +#include "Gaudi/Logging/Backend.h" +#include "GaudiKernel/Message.h" + using System::getEnv; using System::isEnvSet; @@ -36,6 +39,25 @@ using System::isEnvSet; DECLARE_OBJECT_FACTORY( ApplicationMgr ) +namespace +{ + struct MsgSvcBackend : Gaudi::Logging::Backend { + MsgSvcBackend( IMessageSvc* msgSvc ) : m_msgSvc( msgSvc ) {} + void process( const Gaudi::Logging::Context& ctx, const std::string& msg ) const override + { + if ( m_msgSvc ) { + m_msgSvc->reportMessage( Message{ctx.source, static_cast( ctx.level ), msg}, + static_cast( ctx.level ) ); + } else { + std::cerr << "no IMessageSvc!\n"; + } + } + + private: + IMessageSvc* m_msgSvc; + }; +} + // Implementation class for the Application Manager. In this way the // ApplicationMgr class is a fully insulated concrete class. Clients // (main programs) will not need to re-compile if there are changes @@ -50,7 +72,9 @@ ApplicationMgr::ApplicationMgr( IInterface* ) addRef(); // Initial count set to 1 // Instantiate component managers - m_managers[IService::interfaceID().id()] = new ServiceManager( this ); + ServiceManager* svcMgr = new ServiceManager( this ); + svcMgr->m_logMgr = m_logMgr; + m_managers[IService::interfaceID().id()] = svcMgr; m_svcLocator = svcManager(); @@ -59,6 +83,7 @@ ApplicationMgr::ApplicationMgr( IInterface* ) m_classManager = new DLLClassManager( this ); AlgorithmManager* algMgr = new AlgorithmManager( this ); + algMgr->m_logMgr = m_logMgr; m_managers[IAlgorithm::interfaceID().id()] = algMgr; // m_managers[IAlgorithm::interfaceID().id()] = new HiveAlgorithmManager(this); @@ -150,6 +175,7 @@ StatusCode ApplicationMgr::i_startup() log << MSG::FATAL << "Error retrieving MessageSvc." << endmsg; return StatusCode::FAILURE; } + m_logMgr->setBackend( std::make_unique( m_messageSvc ) ); auto jobsvc = svcManager()->createService( Gaudi::Utils::TypeNameString( "JobOptionsSvc", m_jobOptionsSvcType ) ); // Create the Job Options service diff --git a/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.h b/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.h index 1cb0e19afb..fa11c66a77 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.h +++ b/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.h @@ -15,8 +15,11 @@ #include "GaudiKernel/PropertyHolder.h" #include "GaudiKernel/Service.h" +#include "Gaudi/Logging/Manager.h" + // STL include files #include +#include #include // Forward declarations @@ -205,6 +208,8 @@ protected: SmartIF m_processingMgr; ///< Reference to processing manager object SmartIF m_jobOptionsSvc; ///< Reference to JobOption service + std::shared_ptr m_logMgr = std::make_shared(); + // // The public ApplicationMgr properties // diff --git a/GaudiCoreSvc/src/ApplicationMgr/EventLoopMgr.cpp b/GaudiCoreSvc/src/ApplicationMgr/EventLoopMgr.cpp index 9f278c6a61..60f376fdec 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/EventLoopMgr.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/EventLoopMgr.cpp @@ -18,8 +18,8 @@ // Instantiation of a static factory class used by clients to create instances of this service DECLARE_COMPONENT( EventLoopMgr ) -#define ON_DEBUG if ( UNLIKELY( outputLevel() <= MSG::DEBUG ) ) -#define ON_VERBOSE if ( UNLIKELY( outputLevel() <= MSG::VERBOSE ) ) +#define ON_DEBUG if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) +#define ON_VERBOSE if ( UNLIKELY( msgLevel( MSG::VERBOSE ) ) ) #define DEBMSG ON_DEBUG debug() #define VERMSG ON_VERBOSE verbose() @@ -354,7 +354,7 @@ StatusCode EventLoopMgr::nextEvent( int maxevt ) } } - if ( UNLIKELY( outputLevel() <= MSG::DEBUG ) ) + if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) debug() << "---> Loop Finished - " << " WSS " << System::mappedMemory( System::MemoryUnit::kByte ) * oneOver1024 << " | total time (skipping 1st evt) " diff --git a/GaudiCoreSvc/src/ApplicationMgr/ServiceManager.cpp b/GaudiCoreSvc/src/ApplicationMgr/ServiceManager.cpp index 41dc5d8e89..26bd3e8291 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/ServiceManager.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/ServiceManager.cpp @@ -92,6 +92,12 @@ SmartIF& ServiceManager::createService( const Gaudi::Utils::TypeNameSt fatal() << "Incompatible interface IService version for " << type << endmsg; return no_service; } + auto actualSvc = dynamic_cast( service ); + if ( actualSvc ) { + actualSvc->setLoggingManager( m_logMgr.lock() ); + } else { + warning() << type << " does not seem to inherit from Service" << endmsg; + } m_listsvc.push_back( service ); service->setServiceManager( this ); @@ -538,10 +544,10 @@ void ServiceManager::dump() const void ServiceManager::outputLevelUpdate() { - resetMessaging(); + getProperty( "OutputLevel" ).fromString( std::to_string( resetMessaging() ) ); for ( auto& svcItem : m_listsvc ) { const auto svc = dynamic_cast( svcItem.service.get() ); - if ( svc ) svc->resetMessaging(); + if ( svc ) svc->getProperty( "OutputLevel" ).fromString( std::to_string( svc->resetMessaging() ) ); } } diff --git a/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp b/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp index b1cffe9f77..80e23e089e 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/ToolSvc.cpp @@ -502,7 +502,10 @@ StatusCode ToolSvc::create( const std::string& tooltype, const std::string& tool // to downcast IAlgTool to AlgTool in order to set the properties via the JobOptions // service AlgTool* mytool = dynamic_cast( toolguard.get() ); - if ( mytool ) mytool->bindPropertiesTo( serviceLocator()->getOptsSvc() ); + if ( mytool ) { + mytool->setLoggingManager( m_logMgr.lock() ); + mytool->bindPropertiesTo( serviceLocator()->getOptsSvc() ); + } // Initialize the Tool StatusCode sc( StatusCode::FAILURE, true ); diff --git a/GaudiCoreSvc/src/MessageSvc/MessageSvc.cpp b/GaudiCoreSvc/src/MessageSvc/MessageSvc.cpp index 99fbeeedcf..d8a30ab919 100644 --- a/GaudiCoreSvc/src/MessageSvc/MessageSvc.cpp +++ b/GaudiCoreSvc/src/MessageSvc/MessageSvc.cpp @@ -84,7 +84,7 @@ MessageSvc::MessageSvc( const std::string& name, ISvcLocator* svcloc ) : base_cl { m_inactCount.declareUpdateHandler( &MessageSvc::setupInactCount, this ); - m_outputLevel.declareUpdateHandler( [svcloc]( Gaudi::Details::PropertyBase& ) { + getProperty( "OutputLevel" ).declareUpdateHandler( [svcloc]( Gaudi::Details::PropertyBase& ) { SmartIF app = svcloc; if ( app ) app->outputLevelUpdate(); } ); @@ -597,24 +597,23 @@ void MessageSvc::eraseMessage( const StatusCode& key, const Message& msg ) // --------------------------------------------------------------------------- int MessageSvc::outputLevel() const { - // --------------------------------------------------------------------------- - return m_outputLevel; + Gaudi::Property p; + p.assign( getProperty( "OutputLevel" ) ); + return p.value(); } // --------------------------------------------------------------------------- int MessageSvc::outputLevel( const std::string& source ) const { - // --------------------------------------------------------------------------- std::unique_lock lock( m_thresholdMapMutex ); auto it = m_thresholdMap.find( source ); - return it != m_thresholdMap.end() ? it->second : m_outputLevel.value(); + return it != m_thresholdMap.end() ? it->second : outputLevel(); } // --------------------------------------------------------------------------- void MessageSvc::setOutputLevel( int new_level ) { - // --------------------------------------------------------------------------- - m_outputLevel = new_level; + getProperty( "OutputLevel" ).fromString( std::to_string( new_level ) ).ignore(); } // --------------------------------------------------------------------------- diff --git a/GaudiExamples/src/ExtendedProperties/ArrayProperties.cpp b/GaudiExamples/src/ExtendedProperties/ArrayProperties.cpp index 905236572c..ac5fd08b72 100644 --- a/GaudiExamples/src/ExtendedProperties/ArrayProperties.cpp +++ b/GaudiExamples/src/ExtendedProperties/ArrayProperties.cpp @@ -7,6 +7,8 @@ // ============================================================================ // GaudiKernel // ============================================================================ +#include "Gaudi/Logging/LevelAsProperty.h" + #define NO_C_ARRAY_AS_PROPERTY_WARNING #include "GaudiKernel/CArrayAsProperty.h" // ============================================================================ diff --git a/GaudiExamples/src/ExtendedProperties/ExtendedProperties.cpp b/GaudiExamples/src/ExtendedProperties/ExtendedProperties.cpp index 4586b96a20..39aa5256c2 100644 --- a/GaudiExamples/src/ExtendedProperties/ExtendedProperties.cpp +++ b/GaudiExamples/src/ExtendedProperties/ExtendedProperties.cpp @@ -15,6 +15,7 @@ // ============================================================================ // Include parsers for creating parser that handles tuple // ============================================================================ +#include "Gaudi/Logging/LevelAsProperty.h" #include "GaudiKernel/StdArrayAsProperty.h" #include diff --git a/GaudiExamples/src/ExtendedProperties/ExtendedProperties2.cpp b/GaudiExamples/src/ExtendedProperties/ExtendedProperties2.cpp index 0eb0d61411..b8f6a0b62b 100644 --- a/GaudiExamples/src/ExtendedProperties/ExtendedProperties2.cpp +++ b/GaudiExamples/src/ExtendedProperties/ExtendedProperties2.cpp @@ -16,6 +16,7 @@ #include "GaudiKernel/Vector3DTypes.h" #include "GaudiKernel/Vector4DTypes.h" // ============================================================================ +#include "Gaudi/Logging/LevelAsProperty.h" #include "GaudiKernel/SVectorAsProperty.h" #include "GaudiKernel/VectorsAsProperty.h" // ============================================================================ diff --git a/GaudiExamples/src/Histograms/Aida2Root.cpp b/GaudiExamples/src/Histograms/Aida2Root.cpp index 0a1122166f..5b1bf0e327 100644 --- a/GaudiExamples/src/Histograms/Aida2Root.cpp +++ b/GaudiExamples/src/Histograms/Aida2Root.cpp @@ -83,16 +83,6 @@ private: // ============================================================================ DECLARE_COMPONENT( Aida2Root ) // ============================================================================ -namespace -{ - inline std::string print( const double aida, const double root, const std::string& name, const std::string& format ) - { - boost::format fmt( format ); - fmt % name % aida % root % ( aida - root ); - return fmt.str(); - } -} -// ============================================================================ /// finalize the algorithm // ============================================================================ StatusCode Aida2Root::finalize() @@ -118,19 +108,20 @@ StatusCode Aida2Root::finalize() root->Print(); info() << " | Compare | AIDA/HistoStats | ROOT/TH1 | Delta | " << endmsg; - const std::string format = " | %1$-14.14s | %2$ 15.8g | %3$- 15.8g | %4$= 15.8g | "; - info() << print( Gaudi::Utils::HistoStats::mean( aida ), root->GetMean(), "'mean'", format ) << endmsg; - info() << print( Gaudi::Utils::HistoStats::meanErr( aida ), root->GetMeanError(), "'meanErr'", format ) << endmsg; - info() << print( Gaudi::Utils::HistoStats::rms( aida ), root->GetRMS(), "'rms'", format ) << endmsg; - info() << print( Gaudi::Utils::HistoStats::rmsErr( aida ), root->GetRMSError(), "'rmsErr'", format ) << endmsg; - info() << print( Gaudi::Utils::HistoStats::skewness( aida ), root->GetSkewness(), "'skewness'", format ) - << endmsg; - info() << print( Gaudi::Utils::HistoStats::skewnessErr( aida ), root->GetSkewness( 11 ), "'skewnessErr'", format ) - << endmsg; - info() << print( Gaudi::Utils::HistoStats::kurtosis( aida ), root->GetKurtosis(), "'kurtosis'", format ) - << endmsg; - info() << print( Gaudi::Utils::HistoStats::kurtosisErr( aida ), root->GetKurtosis( 11 ), "'kurtosisErr'", format ) - << endmsg; + + const auto compare = [this]( const char* name, const double a, const double b ) { + // same output as + // boost::format{" | %1$-14.14s | %2$ 15.8g | %3$- 15.8g | %4$= 15.8g | "} % name % a % b % (a - b) + info( " | {:<14s} | {: 15.8g} | {:< 15.8g} | {:^ 16.8g}|", name, a, b, a - b ); + }; + compare( "'mean'", Gaudi::Utils::HistoStats::mean( aida ), root->GetMean() ); + compare( "'meanErr'", Gaudi::Utils::HistoStats::meanErr( aida ), root->GetMeanError() ); + compare( "'rms'", Gaudi::Utils::HistoStats::rms( aida ), root->GetRMS() ); + compare( "'rmsErr'", Gaudi::Utils::HistoStats::rmsErr( aida ), root->GetRMSError() ); + compare( "'skewness'", Gaudi::Utils::HistoStats::skewness( aida ), root->GetSkewness() ); + compare( "'skewnessErr'", Gaudi::Utils::HistoStats::skewnessErr( aida ), root->GetSkewness( 11 ) ); + compare( "'kurtosis'", Gaudi::Utils::HistoStats::kurtosis( aida ), root->GetKurtosis() ); + compare( "'kurtosisErr'", Gaudi::Utils::HistoStats::kurtosisErr( aida ), root->GetKurtosis( 11 ) ); } } diff --git a/GaudiExamples/src/Maps/MapAlg.cpp b/GaudiExamples/src/Maps/MapAlg.cpp index 7e3f5a4235..21085467e0 100644 --- a/GaudiExamples/src/Maps/MapAlg.cpp +++ b/GaudiExamples/src/Maps/MapAlg.cpp @@ -1,6 +1,10 @@ // ============================================================================ // Include files // ============================================================================ +// GaudiAlg +// ============================================================================ +#include "GaudiAlg/GaudiAlgorithm.h" +// ============================================================================ // from GaudiKernel // ============================================================================ #include "GaudiKernel/HashMap.h" @@ -11,10 +15,6 @@ #include "GaudiKernel/ToStream.h" #include "GaudiKernel/VectorMap.h" // ============================================================================ -// GaudiAlg -// ============================================================================ -#include "GaudiAlg/GaudiAlgorithm.h" -// ============================================================================ /** @file * * Simple example which shows various maps available in Gaudi diff --git a/GaudiExamples/src/MultipleLogStreams/QotdAlg.cpp b/GaudiExamples/src/MultipleLogStreams/QotdAlg.cpp index ef5fb26018..e930adead0 100644 --- a/GaudiExamples/src/MultipleLogStreams/QotdAlg.cpp +++ b/GaudiExamples/src/MultipleLogStreams/QotdAlg.cpp @@ -17,9 +17,12 @@ QotdAlg::QotdAlg( const std::string& name, ISvcLocator* pSvcLocator ) : Algorith StatusCode QotdAlg::initialize() //------------------------------------------------------------------------------ { + StatusCode sc = Algorithm::initialize(); + if ( !sc ) return sc; + info() << "Initializing " << name() << "..." << endmsg; - return StatusCode::SUCCESS; + return sc; } //------------------------------------------------------------------------------ diff --git a/GaudiExamples/src/Properties/CustomPropertiesAlg.cpp b/GaudiExamples/src/Properties/CustomPropertiesAlg.cpp index 7c525037f1..baf7c0ab60 100644 --- a/GaudiExamples/src/Properties/CustomPropertiesAlg.cpp +++ b/GaudiExamples/src/Properties/CustomPropertiesAlg.cpp @@ -12,6 +12,8 @@ typedef std::unordered_map MyCustomType; // Define the parser #include +#include "Gaudi/Logging/LevelAsProperty.h" + namespace Gaudi { namespace Parsers diff --git a/GaudiExamples/src/RandomNumber/RandomNumberAlg.cpp b/GaudiExamples/src/RandomNumber/RandomNumberAlg.cpp index 7af1e17ddd..7267613648 100644 --- a/GaudiExamples/src/RandomNumber/RandomNumberAlg.cpp +++ b/GaudiExamples/src/RandomNumber/RandomNumberAlg.cpp @@ -1,3 +1,5 @@ +#include "RandomNumberAlg.h" + // Framework include files #include "GaudiKernel/DataObject.h" #include "GaudiKernel/IDataProviderSvc.h" @@ -15,9 +17,6 @@ #include "AIDA/IHistogram1D.h" using AIDA::IHistogram1D; -// Example related include files -#include "RandomNumberAlg.h" - namespace { namespace QuasiRandom = Gaudi::Utils::QuasiRandom; diff --git a/GaudiExamples/src/Selections/SelFilter.cpp b/GaudiExamples/src/Selections/SelFilter.cpp index 1e13fbdc59..3d4a46b684 100644 --- a/GaudiExamples/src/Selections/SelFilter.cpp +++ b/GaudiExamples/src/Selections/SelFilter.cpp @@ -1,16 +1,16 @@ // ============================================================================ // Include files // ============================================================================ +// GaudiAlg +// ============================================================================ +#include "GaudiAlg/GaudiAlgorithm.h" +// ============================================================================ // GaudiKernel // ============================================================================ #include "GaudiKernel/DataObjectHandle.h" #include "GaudiKernel/IRndmGenSvc.h" #include "GaudiKernel/RndmGenerators.h" // ============================================================================ -// GaudiAlg -// ============================================================================ -#include "GaudiAlg/GaudiAlgorithm.h" -// ============================================================================ // Local // ============================================================================ #include "GaudiExamples/MyTrack.h" diff --git a/GaudiExamples/src/ToolHandles/Algorithms.cpp b/GaudiExamples/src/ToolHandles/Algorithms.cpp index 034b0ce573..37c07af806 100644 --- a/GaudiExamples/src/ToolHandles/Algorithms.cpp +++ b/GaudiExamples/src/ToolHandles/Algorithms.cpp @@ -1,8 +1,9 @@ -#include "FloatTool.h" #include #include #include +#include "FloatTool.h" + namespace Gaudi { namespace Examples diff --git a/GaudiHive/src/CPUCruncher.cpp b/GaudiHive/src/CPUCruncher.cpp index 9c3324edec..ca0db3b32e 100644 --- a/GaudiHive/src/CPUCruncher.cpp +++ b/GaudiHive/src/CPUCruncher.cpp @@ -254,7 +254,7 @@ StatusCode CPUCruncher::execute() // the execution of the algorithm unif2 = getUnifRandom( seed ); } while ( unif1 == 0. ); - const double normal = sqrt( -2. * log( unif1 ) ) * cos( 2 * M_PI * unif2 ); + const double normal = sqrt( -2. * ::log( unif1 ) ) * cos( 2 * M_PI * unif2 ); return normal * sigma + mean; }; diff --git a/GaudiHive/src/HiveSlimEventLoopMgr.cpp b/GaudiHive/src/HiveSlimEventLoopMgr.cpp index 1f6567a3c0..10fc69f5ff 100644 --- a/GaudiHive/src/HiveSlimEventLoopMgr.cpp +++ b/GaudiHive/src/HiveSlimEventLoopMgr.cpp @@ -15,10 +15,10 @@ // Instantiation of a static factory class used by clients to create instances of this service DECLARE_COMPONENT( HiveSlimEventLoopMgr ) -#define ON_DEBUG if ( msgLevel( MSG::DEBUG ) ) +#define ON_DEBUG if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) #define DEBUG_MSG ON_DEBUG debug() -#define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) ) +#define ON_VERBOSE if ( UNLIKELY( msgLevel( MSG::VERBOSE ) ) ) #define VERBOSE_MSG ON_VERBOSE verbose() //-------------------------------------------------------------------------------------------- diff --git a/GaudiHive/src/HiveWhiteBoard.cpp b/GaudiHive/src/HiveWhiteBoard.cpp index ef03fde52f..1778ef16f3 100644 --- a/GaudiHive/src/HiveWhiteBoard.cpp +++ b/GaudiHive/src/HiveWhiteBoard.cpp @@ -517,7 +517,7 @@ public: svc->setProperty( m_forceLeaves ).ignore(); svc->setProperty( m_enableFaultHdlr ).ignore(); // make sure that CommonMessaging is initialized - svc->setProperty( m_outputLevel ).ignore(); + svc->setProperty( getProperty( "OutputLevel" ) ).ignore(); sc = svc->initialize(); if ( !sc.isSuccess() ) { diff --git a/GaudiHive/src/PrecedenceRulesGraph.h b/GaudiHive/src/PrecedenceRulesGraph.h index 2862c32c31..4aa3a33fae 100644 --- a/GaudiHive/src/PrecedenceRulesGraph.h +++ b/GaudiHive/src/PrecedenceRulesGraph.h @@ -651,18 +651,29 @@ namespace concurrency // ========================================================================== - struct IPrecedenceRulesGraph { - virtual ~IPrecedenceRulesGraph() = default; - }; - - class PrecedenceRulesGraph : public CommonMessaging + class PrecedenceRulesGraph : public PropertyHolder>>, + public Gaudi::Logging::Logger { public: + using PropertyHolder::info; + using PropertyHolder::debug; + using PropertyHolder::verbose; + using PropertyHolder::warning; + using PropertyHolder::error; + using PropertyHolder::fatal; + + using Gaudi::Logging::Logger::info; + using Gaudi::Logging::Logger::debug; + using Gaudi::Logging::Logger::verbose; + using Gaudi::Logging::Logger::warning; + using Gaudi::Logging::Logger::error; + using Gaudi::Logging::Logger::fatal; + /// Constructor PrecedenceRulesGraph( const std::string& name, SmartIF svc ) : m_svcLocator( svc ), m_name( name ) { // make sure that CommonMessaging is initialized - setUpMessaging(); + getProperty( "OutputLevel" ).fromString( std::to_string( setUpMessaging() ) ).ignore(); } /// Initialize graph diff --git a/GaudiKernel/Gaudi/Logging/Logger.h b/GaudiKernel/Gaudi/Logging/Logger.h index a2800b4847..bf24a5247d 100644 --- a/GaudiKernel/Gaudi/Logging/Logger.h +++ b/GaudiKernel/Gaudi/Logging/Logger.h @@ -23,8 +23,11 @@ namespace Gaudi template class Logger { + /// \fixme m_logMgr because it's needed in component managers (or ToolSvc) + protected: std::weak_ptr m_logMgr; + private: Gaudi::Property m_level{static_cast( this ), "OutputLevel", Level::INFO}; inline bool enabled( const Level l ) const { return l >= m_level; } diff --git a/GaudiKernel/GaudiKernel/AlgTool.h b/GaudiKernel/GaudiKernel/AlgTool.h index 834394d785..21c3aa6288 100644 --- a/GaudiKernel/GaudiKernel/AlgTool.h +++ b/GaudiKernel/GaudiKernel/AlgTool.h @@ -2,6 +2,9 @@ #define GAUDIKERNEL_ALGTOOL_H // ============================================================================ // Include files +/// \fixme the order of inclusion is important (wrt Property.h) +#include "Gaudi/Logging/Logger.h" + #include "GaudiKernel/CommonMessaging.h" #include "GaudiKernel/DataObjID.h" #include "GaudiKernel/IAlgTool.h" @@ -48,13 +51,28 @@ class ToolSvc; */ class GAUDI_API AlgTool : public DataHandleHolderBase< - PropertyHolder>>> + PropertyHolder>>>, + public Gaudi::Logging::Logger { friend ToolSvc; public: using Factory = Gaudi::PluginService::Factory; + using DataHandleHolderBase::info; + using DataHandleHolderBase::debug; + using DataHandleHolderBase::verbose; + using DataHandleHolderBase::warning; + using DataHandleHolderBase::error; + using DataHandleHolderBase::fatal; + + using Gaudi::Logging::Logger::info; + using Gaudi::Logging::Logger::debug; + using Gaudi::Logging::Logger::verbose; + using Gaudi::Logging::Logger::warning; + using Gaudi::Logging::Logger::error; + using Gaudi::Logging::Logger::fatal; + /// Query for a given interface StatusCode queryInterface( const InterfaceID& riid, void** ppvUnknown ) override; @@ -307,8 +325,6 @@ private: InterfaceList m_interfaceList; ///< Interface list // Properties - Gaudi::Property m_outputLevel{this, "OutputLevel", MSG::NIL, "output level"}; - Gaudi::Property m_monitorSvcName{this, "MonitorService", "MonitorSvc", "name to use for Monitor Service"}; diff --git a/GaudiKernel/GaudiKernel/Algorithm.h b/GaudiKernel/GaudiKernel/Algorithm.h index 56c49a7512..0812245d8e 100644 --- a/GaudiKernel/GaudiKernel/Algorithm.h +++ b/GaudiKernel/GaudiKernel/Algorithm.h @@ -3,6 +3,9 @@ // ============================================================================ // Include files // ============================================================================ +/// \fixme the order of inclusion is important (wrt Property.h) +#include "Gaudi/Logging/Logger.h" + #include "GaudiKernel/IAlgorithm.h" #include "GaudiKernel/IMessageSvc.h" #include "GaudiKernel/IProperty.h" @@ -78,13 +81,28 @@ class AlgorithmManager; */ class GAUDI_API Algorithm : public DataHandleHolderBase< - PropertyHolder>>> + PropertyHolder>>>, + public Gaudi::Logging::Logger { public: using Factory = Gaudi::PluginService::Factory; friend AlgorithmManager; + using DataHandleHolderBase::info; + using DataHandleHolderBase::debug; + using DataHandleHolderBase::verbose; + using DataHandleHolderBase::warning; + using DataHandleHolderBase::error; + using DataHandleHolderBase::fatal; + + using Gaudi::Logging::Logger::info; + using Gaudi::Logging::Logger::debug; + using Gaudi::Logging::Logger::verbose; + using Gaudi::Logging::Logger::warning; + using Gaudi::Logging::Logger::error; + using Gaudi::Logging::Logger::fatal; + /** Constructor * @param name The algorithm object's name * @param svcloc A pointer to a service location service @@ -559,7 +577,6 @@ protected: private: // Properties - Gaudi::Property m_outputLevel{this, "OutputLevel", MSG::NIL, "output level"}; Gaudi::Property m_isEnabled{this, "Enable", true, "should the algorithm be executed or not"}; Gaudi::Property m_errorMax{this, "ErrorMax", 1, "[[deprecated]] max number of errors"}; diff --git a/GaudiKernel/GaudiKernel/Auditor.h b/GaudiKernel/GaudiKernel/Auditor.h index 7db495f992..4d1a8aac08 100644 --- a/GaudiKernel/GaudiKernel/Auditor.h +++ b/GaudiKernel/GaudiKernel/Auditor.h @@ -2,6 +2,8 @@ #define GAUDIKERNEL_AUDITOR_H // Include files +#include "Gaudi/Logging/Logger.h" + #include "GaudiKernel/CommonMessaging.h" #include "GaudiKernel/IAuditor.h" #include "GaudiKernel/IProperty.h" @@ -33,11 +35,26 @@ class Algorithm; @author Marco Clemencic @date 2008-03 */ -class GAUDI_API Auditor : public PropertyHolder>> +class GAUDI_API Auditor : public PropertyHolder>>, + public Gaudi::Logging::Logger { public: using Factory = Gaudi::PluginService::Factory; + using PropertyHolder::info; + using PropertyHolder::debug; + using PropertyHolder::verbose; + using PropertyHolder::warning; + using PropertyHolder::error; + using PropertyHolder::fatal; + + using Gaudi::Logging::Logger::info; + using Gaudi::Logging::Logger::debug; + using Gaudi::Logging::Logger::verbose; + using Gaudi::Logging::Logger::warning; + using Gaudi::Logging::Logger::error; + using Gaudi::Logging::Logger::fatal; + /** Constructor @param name The algorithm object's name @param svcloc A pointer to a service location service */ @@ -135,7 +152,6 @@ private: mutable SmartIF m_pSvcLocator; ///< Pointer to service locator service - Gaudi::Property m_outputLevel{this, "OutputLevel", MSG::NIL, "output level"}; Gaudi::Property m_isEnabled{this, "Enable", true, "should the auditor be used or not"}; bool m_isInitialized = false; ///< Auditor has been initialized flag diff --git a/GaudiKernel/GaudiKernel/ComponentManager.h b/GaudiKernel/GaudiKernel/ComponentManager.h index 007f42a213..925131fb89 100644 --- a/GaudiKernel/GaudiKernel/ComponentManager.h +++ b/GaudiKernel/GaudiKernel/ComponentManager.h @@ -1,9 +1,15 @@ #ifndef COMPONENTMANAGER_H_ #define COMPONENTMANAGER_H_ +#include "Gaudi/Logging/Logger.h" + #include "GaudiKernel/CommonMessaging.h" +#include "GaudiKernel/PropertyHolder.h" + #include "GaudiKernel/IComponentManager.h" +#include + class ApplicationMgr; /** @class ComponentManager ComponentManager.h @@ -12,9 +18,25 @@ class ApplicationMgr; * * @author Marco Clemencic */ -class GAUDI_API ComponentManager : public CommonMessaging> +class GAUDI_API ComponentManager + : public PropertyHolder>>, + public Gaudi::Logging::Logger { public: + using PropertyHolder::info; + using PropertyHolder::debug; + using PropertyHolder::verbose; + using PropertyHolder::warning; + using PropertyHolder::error; + using PropertyHolder::fatal; + + using Gaudi::Logging::Logger::info; + using Gaudi::Logging::Logger::debug; + using Gaudi::Logging::Logger::verbose; + using Gaudi::Logging::Logger::warning; + using Gaudi::Logging::Logger::error; + using Gaudi::Logging::Logger::fatal; + /// Constructor. /// @param application the manager of managers ComponentManager( IInterface* application, const InterfaceID& baseIID ); diff --git a/GaudiKernel/GaudiKernel/IProperty.h b/GaudiKernel/GaudiKernel/IProperty.h index 864c8fd1d0..bf318d9230 100644 --- a/GaudiKernel/GaudiKernel/IProperty.h +++ b/GaudiKernel/GaudiKernel/IProperty.h @@ -21,7 +21,7 @@ class GAUDI_API IProperty : virtual public IInterface { public: /// InterfaceID - DeclareInterfaceID( IProperty, 2, 1 ); + DeclareInterfaceID( IProperty, 3, 0 ); /// Set the property by property virtual StatusCode setProperty( const Gaudi::Details::PropertyBase& p // Reference to the input property @@ -34,8 +34,8 @@ public: virtual StatusCode getProperty( Gaudi::Details::PropertyBase* p // Pointer to property to be set ) const = 0; /// Get the property by name - virtual const Gaudi::Details::PropertyBase& getProperty( const std::string& name // Property name - ) const = 0; + virtual Gaudi::Details::PropertyBase& getProperty( const std::string& name ) = 0; + virtual const Gaudi::Details::PropertyBase& getProperty( const std::string& name ) const = 0; /// Get the property by std::string virtual StatusCode getProperty( const std::string& n, std::string& v ) const = 0; /// Get list of properties diff --git a/GaudiKernel/GaudiKernel/PropertyHolder.h b/GaudiKernel/GaudiKernel/PropertyHolder.h index be04f634f4..15d1d5ea73 100644 --- a/GaudiKernel/GaudiKernel/PropertyHolder.h +++ b/GaudiKernel/GaudiKernel/PropertyHolder.h @@ -247,6 +247,16 @@ public: return StatusCode::FAILURE; } // ========================================================================== + /** get the property by name + * @see IProperty + */ + Gaudi::Details::PropertyBase& getProperty( const std::string& name ) override + { + Gaudi::Details::PropertyBase* p = property( name ); + if ( !p ) throw std::out_of_range( "Property " + name + " not found." ); + return *p; + } + // ========================================================================== /** get the property by name * @see IProperty */ diff --git a/GaudiKernel/GaudiKernel/PropertyMgr.h b/GaudiKernel/GaudiKernel/PropertyMgr.h index 6e591963dd..76ae63b0af 100644 --- a/GaudiKernel/GaudiKernel/PropertyMgr.h +++ b/GaudiKernel/GaudiKernel/PropertyMgr.h @@ -93,6 +93,11 @@ public: */ StatusCode getProperty( Gaudi::Details::PropertyBase * p ) const override; // ========================================================================== + /** get the property by name + * @see IProperty + */ + Gaudi::Details::PropertyBase& getProperty( const std::string& name ) override; + // ========================================================================== /** get the property by name * @see IProperty */ diff --git a/GaudiKernel/GaudiKernel/Service.h b/GaudiKernel/GaudiKernel/Service.h index 1b4d6f745c..b70eb3c35c 100644 --- a/GaudiKernel/GaudiKernel/Service.h +++ b/GaudiKernel/GaudiKernel/Service.h @@ -3,6 +3,9 @@ // ============================================================================ // Include files // ============================================================================ +/// \fixme the order of inclusion is important (wrt Property.h) +#include "Gaudi/Logging/Logger.h" + #include "GaudiKernel/CommonMessaging.h" #include "GaudiKernel/IAuditorSvc.h" #include "GaudiKernel/IProperty.h" @@ -34,13 +37,28 @@ class ServiceManager; * @author Pere Mato * @author Marco Clemencic */ -class GAUDI_API Service : public PropertyHolder>> +class GAUDI_API Service : public PropertyHolder>>, + public Gaudi::Logging::Logger { public: using Factory = Gaudi::PluginService::Factory; friend class ServiceManager; + using PropertyHolder::info; + using PropertyHolder::debug; + using PropertyHolder::verbose; + using PropertyHolder::warning; + using PropertyHolder::error; + using PropertyHolder::fatal; + + using Gaudi::Logging::Logger::info; + using Gaudi::Logging::Logger::debug; + using Gaudi::Logging::Logger::verbose; + using Gaudi::Logging::Logger::warning; + using Gaudi::Logging::Logger::error; + using Gaudi::Logging::Logger::fatal; + /** Retrieve name of the service */ const std::string& name() const override; @@ -163,9 +181,6 @@ protected: /** Service state */ Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE; - /// get the @c Service's output level - int outputLevel() const { return m_outputLevel.value(); } - private: void sysInitialize_imp(); StatusCode m_initSC; @@ -182,7 +197,6 @@ private: protected: // Properties - Gaudi::Property m_outputLevel{this, "OutputLevel", MSG::NIL, "output level"}; Gaudi::Property m_auditInit{this, "AuditServices", false, "[[deprecated]] unused"}; Gaudi::Property m_auditorInitialize{this, "AuditInitialize", false, "trigger auditor on initialize()"}; Gaudi::Property m_auditorStart{this, "AuditStart", false, "trigger auditor on start()"}; diff --git a/GaudiKernel/src/Lib/AlgTool.cpp b/GaudiKernel/src/Lib/AlgTool.cpp index bc3724be0d..7f75c6c005 100644 --- a/GaudiKernel/src/Lib/AlgTool.cpp +++ b/GaudiKernel/src/Lib/AlgTool.cpp @@ -138,15 +138,17 @@ AlgTool::AlgTool( const std::string& type, const std::string& name, const IInter } // initialize output level from MessageSvc and initialize messaging (before enabling update handler) - m_outputLevel.value() = setUpMessaging(); - m_outputLevel.declareUpdateHandler( - [this]( Gaudi::Details::PropertyBase& ) { this->updateMsgStreamOutputLevel( this->m_outputLevel ); } ); + getProperty( "OutputLevel" ).declareUpdateHandler( [this]( Gaudi::Details::PropertyBase& p ) { + Gaudi::Property v; + v.assign( p ); + this->updateMsgStreamOutputLevel( v ); + } ); - // inherit output level from parent + // inherit initial output level from parent { // get the "OutputLevel" property from parent SmartIF pprop( _p ); if ( pprop && pprop->hasProperty( "OutputLevel" ) ) { - m_outputLevel.assign( pprop->getProperty( "OutputLevel" ) ); + getProperty( "OutputLevel" ).assign( pprop->getProperty( "OutputLevel" ) ); } } diff --git a/GaudiKernel/src/Lib/Algorithm.cpp b/GaudiKernel/src/Lib/Algorithm.cpp index 4557f1a14b..20660803cb 100644 --- a/GaudiKernel/src/Lib/Algorithm.cpp +++ b/GaudiKernel/src/Lib/Algorithm.cpp @@ -32,10 +32,7 @@ #include "GaudiKernel/StringKey.h" #include "GaudiKernel/ToolHandle.h" -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#include "GaudiKernel/Algorithm.h" -#pragma GCC diagnostic pop +#include "GaudiKernel/Message.h" namespace { @@ -73,22 +70,23 @@ Algorithm::Algorithm( const std::string& name, ISvcLocator* pSvcLocator, const s m_auditorStart = audit; m_auditorStop = audit; - // update handlers. - m_outputLevel.declareUpdateHandler( - [this]( Gaudi::Details::PropertyBase& ) { this->updateMsgStreamOutputLevel( this->m_outputLevel ); } ); + getProperty( "OutputLevel" ).declareUpdateHandler( [this]( Gaudi::Details::PropertyBase& p ) { + Gaudi::Property v; + v.assign( p ); + this->updateMsgStreamOutputLevel( v ); + } ); } // IAlgorithm implementation StatusCode Algorithm::sysInitialize() { - // Bypass the initialization if the algorithm // has already been initialized. if ( Gaudi::StateMachine::INITIALIZED <= FSMState() ) return StatusCode::SUCCESS; // this initializes the messaging, in case property update handlers need to print // and update the property value bypassing the update handler - m_outputLevel.value() = setUpMessaging(); + getProperty( "OutputLevel" ).fromString( std::to_string( setUpMessaging() ) ).ignore(); // Set the Algorithm's properties bindPropertiesTo( serviceLocator()->getOptsSvc() ); diff --git a/GaudiKernel/src/Lib/Auditor.cpp b/GaudiKernel/src/Lib/Auditor.cpp index 8aaebdc210..c01136a8ca 100644 --- a/GaudiKernel/src/Lib/Auditor.cpp +++ b/GaudiKernel/src/Lib/Auditor.cpp @@ -1,10 +1,10 @@ +#include "GaudiKernel/Auditor.h" + #include "GaudiKernel/IJobOptionsSvc.h" #include "GaudiKernel/IMessageSvc.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/Kernel.h" -#include "GaudiKernel/Auditor.h" - #include "GaudiKernel/GaudiException.h" #include "GaudiKernel/MsgStream.h" @@ -12,8 +12,11 @@ Auditor::Auditor( const std::string& name, ISvcLocator* pSvcLocator ) : m_name( name ), m_pSvcLocator( pSvcLocator ), m_isInitialized( false ), m_isFinalized( false ) { - m_outputLevel.declareUpdateHandler( - [this]( Gaudi::Details::PropertyBase& ) { this->updateMsgStreamOutputLevel( this->m_outputLevel ); } ); + getProperty( "OutputLevel" ).declareUpdateHandler( [this]( Gaudi::Details::PropertyBase& p ) { + Gaudi::Property v; + v.assign( p ); + this->updateMsgStreamOutputLevel( v ); + } ); } // IAuditor implementation @@ -30,7 +33,7 @@ StatusCode Auditor::sysInitialize() // this initializes the messaging, in case property update handlers need to print // and update the property value bypassing the update handler - m_outputLevel.value() = setUpMessaging(); + getProperty( "OutputLevel" ).fromString( std::to_string( setUpMessaging() ) ).ignore(); // Set the Algorithm's properties bindPropertiesTo( serviceLocator()->getOptsSvc() ); diff --git a/GaudiKernel/src/Lib/MinimalEventLoopMgr.cpp b/GaudiKernel/src/Lib/MinimalEventLoopMgr.cpp index 239f320e20..8801437898 100644 --- a/GaudiKernel/src/Lib/MinimalEventLoopMgr.cpp +++ b/GaudiKernel/src/Lib/MinimalEventLoopMgr.cpp @@ -42,8 +42,8 @@ namespace }; } -#define ON_DEBUG if ( UNLIKELY( outputLevel() <= MSG::DEBUG ) ) -#define ON_VERBOSE if ( UNLIKELY( outputLevel() <= MSG::VERBOSE ) ) +#define ON_DEBUG if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) +#define ON_VERBOSE if ( UNLIKELY( msgLevel( MSG::VERBOSE ) ) ) #define DEBMSG ON_DEBUG debug() #define VERMSG ON_VERBOSE verbose() diff --git a/GaudiKernel/src/Lib/PropertyMgr.cpp b/GaudiKernel/src/Lib/PropertyMgr.cpp index 1dad09ca5e..083bc40373 100644 --- a/GaudiKernel/src/Lib/PropertyMgr.cpp +++ b/GaudiKernel/src/Lib/PropertyMgr.cpp @@ -182,6 +182,17 @@ StatusCode PropertyMgr::getProperty( PropertyBase* p ) const * Implementation of IProperty::getProperty */ // ===================================================================== +PropertyBase& PropertyMgr::getProperty( const std::string& name ) +{ + PropertyBase* p = property( name ); + if ( !p ) throw std::out_of_range( "Property " + name + " not found." ); // Not found + return *p; // RETURN +} +// ===================================================================== +/* Get the property by name + * Implementation of IProperty::getProperty + */ +// ===================================================================== const PropertyBase& PropertyMgr::getProperty( const std::string& name ) const { const PropertyBase* p = property( name ); diff --git a/GaudiKernel/src/Lib/Service.cpp b/GaudiKernel/src/Lib/Service.cpp index 56d70f1246..16e4f0159c 100644 --- a/GaudiKernel/src/Lib/Service.cpp +++ b/GaudiKernel/src/Lib/Service.cpp @@ -1,5 +1,6 @@ // Include Files #include "GaudiKernel/Service.h" + #include "GaudiKernel/GaudiException.h" #include "GaudiKernel/Guards.h" #include "GaudiKernel/IAuditorSvc.h" @@ -37,12 +38,9 @@ void Service::sysInitialize_imp() // check if we want to audit the initialize ( m_auditorInitialize ) ? auditorSvc().get() : nullptr, IAuditor::Initialize ); - // initialize messaging (except for MessageSvc) - if ( name() != "MessageSvc" ) { - // this initializes the messaging, in case property update handlers need to print - // and update the property value bypassing the update handler - m_outputLevel.value() = setUpMessaging(); - } + // this initializes the messaging, in case property update handlers need to print + // and update the property value bypassing the update handler + getProperty( "OutputLevel" ).fromString( std::to_string( setUpMessaging() ) ).ignore(); bindPropertiesTo( serviceLocator()->getOptsSvc() ); @@ -301,8 +299,11 @@ SmartIF& Service::serviceLocator() const { return m_svcLocator; } Service::Service( std::string name, ISvcLocator* svcloc ) : m_name( std::move( name ) ), m_svcLocator( svcloc ) { if ( m_name != "MessageSvc" ) { // the MessageSvc should not notify itself - m_outputLevel.declareUpdateHandler( - [this]( Gaudi::Details::PropertyBase& ) { this->updateMsgStreamOutputLevel( this->m_outputLevel ); } ); + getProperty( "OutputLevel" ).declareUpdateHandler( [this]( Gaudi::Details::PropertyBase& p ) { + Gaudi::Property v; + v.assign( p ); + this->updateMsgStreamOutputLevel( v ); + } ); } // Initialize the default value from ApplicationMgr AuditAlgorithms diff --git a/GaudiMP/src/component/IoComponentMgr.cpp b/GaudiMP/src/component/IoComponentMgr.cpp index bd32acd689..de56f19507 100644 --- a/GaudiMP/src/component/IoComponentMgr.cpp +++ b/GaudiMP/src/component/IoComponentMgr.cpp @@ -19,8 +19,8 @@ #include #include -#define ON_DEBUG if ( UNLIKELY( outputLevel() <= MSG::DEBUG ) ) -#define ON_VERBOSE if ( UNLIKELY( outputLevel() <= MSG::VERBOSE ) ) +#define ON_DEBUG if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) +#define ON_VERBOSE if ( UNLIKELY( msgLevel( MSG::VERBOSE ) ) ) #define DEBMSG ON_DEBUG debug() #define VERMSG ON_VERBOSE verbose() diff --git a/GaudiMP/src/component/RecordOutputStream.cpp b/GaudiMP/src/component/RecordOutputStream.cpp index 150ee967ce..13dfe59234 100644 --- a/GaudiMP/src/component/RecordOutputStream.cpp +++ b/GaudiMP/src/component/RecordOutputStream.cpp @@ -1,6 +1,3 @@ -// Include files - -// local #include "RecordOutputStream.h" // ---------------------------------------------------------------------------- diff --git a/GaudiMP/src/component/ReplayOutputStream.cpp b/GaudiMP/src/component/ReplayOutputStream.cpp index c227b37d77..f05190da85 100644 --- a/GaudiMP/src/component/ReplayOutputStream.cpp +++ b/GaudiMP/src/component/ReplayOutputStream.cpp @@ -1,11 +1,9 @@ -// Include files +#include "ReplayOutputStream.h" +#include "RecordOutputStream.h" // From Gaudi #include "GaudiKernel/IAlgManager.h" #include "GaudiKernel/IDataManagerSvc.h" -// local -#include "RecordOutputStream.h" -#include "ReplayOutputStream.h" #include #include diff --git a/GaudiSvc/src/FileMgr/FileMgr.cpp b/GaudiSvc/src/FileMgr/FileMgr.cpp index dff9587677..c4b3401ad9 100644 --- a/GaudiSvc/src/FileMgr/FileMgr.cpp +++ b/GaudiSvc/src/FileMgr/FileMgr.cpp @@ -81,7 +81,7 @@ StatusCode FileMgr::initialize() // setup file handler for ROOT - msgSvc()->setOutputLevel( "RootFileHandler", m_outputLevel.value() ); + msgSvc()->setOutputLevel( "RootFileHandler", msgLevel() ); m_rfh.emplace( msgSvc(), m_ssl_proxy, m_ssl_cert ); auto& rfh = m_rfh.value(); // used in the lambdas to avoid capturing 'this' @@ -100,7 +100,7 @@ StatusCode FileMgr::initialize() // setup file handler for POSIX - msgSvc()->setOutputLevel( "POSIXFileHandler", m_outputLevel.value() ); + msgSvc()->setOutputLevel( "POSIXFileHandler", msgLevel() ); m_pfh.emplace( msgSvc() ); auto& pfh = m_pfh.value(); // used in the lambdas to avoid capturing 'this' -- GitLab From d4e44f0d45f84ee8a6a974960f72234a25b3ce92 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Tue, 28 Nov 2017 16:22:57 +0100 Subject: [PATCH 51/53] Make SvcLocator IProperty point to ApplicationMgr (backward compatibility hack) --- GaudiCoreSvc/src/ApplicationMgr/ServiceManager.cpp | 11 +++++++++++ GaudiCoreSvc/src/ApplicationMgr/ServiceManager.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/GaudiCoreSvc/src/ApplicationMgr/ServiceManager.cpp b/GaudiCoreSvc/src/ApplicationMgr/ServiceManager.cpp index 26bd3e8291..3841078a16 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/ServiceManager.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/ServiceManager.cpp @@ -551,4 +551,15 @@ void ServiceManager::outputLevelUpdate() } } +StatusCode ServiceManager::queryInterface( const InterfaceID& iid, void** pinterface ) +{ + /// \fixme we rely on SmartIF(serviceLocator()) being the ApplicationMgr + if ( iid == IProperty::interfaceID() ) { + warning( "return ApplicationMgr for SvcLocator IProperty interface" ); + return m_application->queryInterface( iid, pinterface ); + } + + return base_class::queryInterface( iid, pinterface ); +} + DECLARE_OBJECT_FACTORY( ServiceManager ) diff --git a/GaudiCoreSvc/src/ApplicationMgr/ServiceManager.h b/GaudiCoreSvc/src/ApplicationMgr/ServiceManager.h index f9cb8bbd84..176935bf71 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/ServiceManager.h +++ b/GaudiCoreSvc/src/ApplicationMgr/ServiceManager.h @@ -124,6 +124,9 @@ public: return SmartIF{service( typeName, createIf )}; } + /// Specialized queryInterface implementation. + StatusCode queryInterface( const InterfaceID& iid, void** pinterface ) override; + #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR ) using ISvcManager::createService; using ISvcManager::addService; -- GitLab From afe2ec72a4658a4ce365cd979bd1917848a3e851 Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Mon, 22 Oct 2018 10:35:01 +0200 Subject: [PATCH 52/53] Build or not fmtlib using the same policy as RangeV3 and C++GSL --- GaudiKernel/CMakeLists.txt | 40 +------------------------------------- cmake/externals.cmake | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/GaudiKernel/CMakeLists.txt b/GaudiKernel/CMakeLists.txt index 117790f23d..6f11d1f458 100644 --- a/GaudiKernel/CMakeLists.txt +++ b/GaudiKernel/CMakeLists.txt @@ -39,44 +39,6 @@ message(STATUS "Using VectorClass instrset_detect ${VectorClass_VERSION} at ${Ve include_directories(${VectorClass_INCLUDE_DIR}) -# get [fmt](http://fmtlib.net/latest/index.html) -set(fmt_DEFAULT_VERSION 5.2.0) -if(NOT USE_INTERNAL_fmt) - find_package(fmt ${fmt_DEFAULT_VERSION} QUIET) - if(fmt_FOUND) - message(STATUS "Found fmtlib ${fmt_VERSION}") - get_property(fmt_INCLUDE_DIRS TARGET fmt::fmt-header-only PROPERTY INTERFACE_INCLUDE_DIRECTORIES) - else() - message(STATUS "fmtlib not found") - set(USE_INTERNAL_fmt YES CACHE BOOL "using internal build of fmt") - endif() - set(fmt_LIB fmt::fmt) -endif() - -if(USE_INTERNAL_fmt) - set(fmt_VERSION ${fmt_DEFAULT_VERSION}) - message(STATUS "Building fmtlib ${fmt_VERSION}") - - set(fmt_LIB ${CMAKE_BINARY_DIR}/lib64/libfmt.a) - - include(ExternalProject) - ExternalProject_Add(fmt - GIT_REPOSITORY https://github.com/fmtlib/fmt.git - GIT_TAG ${fmt_VERSION} - CMAKE_ARGS -DFMT_DOC=OFF -DFMT_TEST=OFF - -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_CXX_FLAGS=-fPIC - #-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} - BUILD_BYPRODUCTS ${fmt_LIB} ${CMAKE_BINARY_DIR}/include/fmt/format.h - ) - # Ideally we could install directly to ${CMAKE_INSTALL_PREFIX}, but it - # would not be available in this project. - install(DIRECTORY ${CMAKE_BINARY_DIR}/include/fmt DESTINATION include) - install(DIRECTORY ${CMAKE_BINARY_DIR}/lib64/cmake/fmt DESTINATION lib/cmake) - install(FILES ${fmt_LIB} DESTINATION lib) -endif() - # Extra settings when building on MacOS: set( extra_sources ) set( extra_libraries ) @@ -102,7 +64,7 @@ gaudi_add_library(GaudiKernel src/Lib/*.cpp ${extra_sources} PUBLIC_HEADERS Gaudi GaudiKernel) target_link_libraries(GaudiKernel ${fmt_LIB}) -if(USE_INTERNAL_fmt) +if(NOT GAUDI_USE_SYSTEM_FMT) add_dependencies(GaudiKernel fmt) endif() diff --git a/cmake/externals.cmake b/cmake/externals.cmake index ff7a76af11..d9584f3464 100644 --- a/cmake/externals.cmake +++ b/cmake/externals.cmake @@ -63,3 +63,37 @@ if(RANGEV3_INCLUDE_DIR) set(RANGEV3_FOUND TRUE) set_property(GLOBAL APPEND PROPERTY GAUDI_REQUIRED_PATHS ${RANGEV3_INCLUDE_DIRS}) endif() + +# [fmtlib](http://fmtlib.net/latest/index.html) +option(GAUDI_USE_SYSTEM_FMT + "If to use the fmtlib library from the system or providing it through Gaudi" + ${GAUDI_USE_SYSTEM_LIBRARIES}) +if(NOT GAUDI_USE_SYSTEM_FMT) + set(fmt_DEFAULT_VERSION 5.2.1) + set(fmt_VERSION ${fmt_DEFAULT_VERSION}) + message(STATUS "Building fmtlib ${fmt_VERSION}") + + set(fmt_LIB ${CMAKE_BINARY_DIR}/lib64/libfmt.a) + + include(ExternalProject) + ExternalProject_Add(fmt + GIT_REPOSITORY https://github.com/fmtlib/fmt.git + GIT_TAG ${fmt_VERSION} + CMAKE_ARGS -DFMT_DOC=OFF -DFMT_TEST=OFF + -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_CXX_FLAGS=-fPIC + #-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + BUILD_BYPRODUCTS ${fmt_LIB} ${CMAKE_BINARY_DIR}/include/fmt/format.h + ) + # Ideally we could install directly to ${CMAKE_INSTALL_PREFIX}, but it + # would not be available in this project. + install(DIRECTORY ${CMAKE_BINARY_DIR}/include/fmt DESTINATION include) + install(DIRECTORY ${CMAKE_BINARY_DIR}/lib64/cmake/fmt DESTINATION lib/cmake) + install(FILES ${fmt_LIB} DESTINATION lib) +else() + find_package(fmt ${fmt_DEFAULT_VERSION} REQUIRED) + get_property(fmt_INCLUDE_DIRS TARGET fmt::fmt-header-only PROPERTY INTERFACE_INCLUDE_DIRECTORIES) + message(STATUS "Found fmtlib ${fmt_VERSION}: ${fmt_INCLUDE_DIRS}") + set(fmt_LIB fmt::fmt) +endif() -- GitLab From d463a243fbc7bf804be665b06119d46a56272ffc Mon Sep 17 00:00:00 2001 From: Marco Clemencic Date: Mon, 22 Oct 2018 10:37:22 +0200 Subject: [PATCH 53/53] temporary! Use internal fmtlib in CI job, while waiting for LCG 95 --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8cb5fa70f8..6ba269982f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,6 +16,8 @@ variables: LCG_contrib: "/cvmfs/sft.cern.ch/lcg/contrib" CLANG_FORMAT_VERSION: "3.9" CCACHE_VERSION: "3.3.4-e92e5" + # It requires LCG 95 to use _system_ fmtlib + CMAKEFLAGS: "-DGAUDI_USE_SYSTEM_FMT=NO" build:gcc7:opt: stage: build -- GitLab