The Gaudi Framework  v30r3 (a5ef0a68)
FunctionalUtilities.h
Go to the documentation of this file.
1 #ifndef FUNCTIONAL_UTILITIES_H
2 #define FUNCTIONAL_UTILITIES_H
3 
4 #include "boost/algorithm/string/join.hpp"
5 #include <initializer_list>
6 #include <string>
7 
8 // TODO: fwd declare instead?
10 #include "GaudiAlg/GaudiHistoAlg.h"
13 
14 namespace Gaudi
15 {
16  namespace Functional
17  {
18 
19  // This utility is needed when the inputs of a functional algorithm may be stored in several locations
21  {
22  return boost::algorithm::join( c, ":" );
23  }
24 
25  template <typename... Strings>
26  std::string concat_alternatives( const Strings&... s )
27  {
29  }
30 
31  inline void updateHandleLocation( IProperty& parent, const std::string& prop, const std::string& newLoc )
32  {
33  auto sc = parent.setProperty( prop, newLoc );
34  if ( sc.isFailure() ) throw GaudiException( "Could not set Property", prop + " -> " + newLoc, sc );
35  }
36 
37  inline void updateHandleLocations( IProperty& parent, const std::string& prop,
38  const std::vector<std::string>& newLocs )
39  {
41  GaudiUtils::details::ostream_joiner( ss << '[', newLocs, ", ", []( std::ostream & os, const auto& i ) -> auto& {
42  return os << "'" << i << "'";
43  } ) << ']';
44  auto sc = parent.setProperty( prop, ss.str() );
45  if ( sc.isFailure() ) throw GaudiException( "Could not set Property", prop + " -> " + ss.str(), sc );
46  }
47 
48  [[deprecated( "please use updateHandleLocation instead" )]] inline void
49  updateReadHandleLocation( IProperty& parent, const std::string& prop, const std::string& newLoc )
50  {
51  return updateHandleLocation( parent, prop, newLoc );
52  }
53 
54  namespace Traits
55  {
56 
57  // traits classes used to customize Transformer and FilterPredicate
58  // Define the types to to be used as baseclass, and as in- resp. output hanldes.
59  // In case a type is not specified in the traits struct, a default is used.
60  //
61  // The defaults are:
62  //
63  // using BaseClass = GaudiAlgorithm
64  // template <typename T> using InputHandle = DataObjectHandle<T>;
65  // template <typename T> using OutputHandle = DataObjectHandle<T>;
66  //
67 
68  // the best way to 'compose' traits is by inheriting them one-by-one...
69  template <typename... Base>
70  struct use_ : Base... {
71  };
72 
73  // helper classes one can inherit from to specify a specific trait
74  template <typename Base>
75  struct BaseClass_t {
76  using BaseClass = Base;
77  };
78 
79  template <template <typename> class Handle>
80  struct InputHandle_t {
81  template <typename T>
82  using InputHandle = Handle<T>;
83  };
84 
85  template <template <typename> class Handle>
86  struct OutputHandle_t {
87  template <typename T>
88  using OutputHandle = Handle<T>;
89  };
90 
91  // this uses the defaults -- and it itself is the default ;-)
93 
94  // this example uses GaudiHistoAlg as baseclass, and the default handle types for
95  // input and output
97  }
98  }
99 }
100 
101 #endif
Define general base for Gaudi exception.
std::string concat_alternatives(std::initializer_list< std::string > c)
Header file for class GaudiAlgorithm.
void updateHandleLocation(IProperty &parent, const std::string &prop, const std::string &newLoc)
Provide serialization function (output only) for some common STL classes (vectors, lists, pairs, maps) plus GaudiUtils::Map and GaudiUtils::HashMap.
void updateReadHandleLocation(IProperty &parent, const std::string &prop, const std::string &newLoc)
STL class.
virtual StatusCode setProperty(const Gaudi::Details::PropertyBase &p)=0
Set the property by property.
void updateHandleLocations(IProperty &parent, const std::string &prop, const std::vector< std::string > &newLocs)
Stream & ostream_joiner(Stream &os, Iterator first, Iterator last, Separator sep, OutputElement output=OutputElement{})
Definition: SerializeSTL.h:40
string s
Definition: gaudirun.py:253
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
STL class.
Helper functions to set/get the application return code.
Definition: __init__.py:1