The Gaudi Framework  v32r2 (46d42edc)
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::Functional {
15 
16  // This utility is needed when the inputs of a functional algorithm may be stored in several locations
18  return boost::algorithm::join( c, ":" );
19  }
20 
21  template <typename... Strings>
22  std::string concat_alternatives( const Strings&... s ) {
24  }
25 
26  [[deprecated( "please use `updateHandleLocation` instead of `Gaudi::Functional::updateHandleLocation`" )]] inline void
27  updateHandleLocation( IProperty& parent, const std::string& prop, const std::string& newLoc ) {
28  auto sc = parent.setProperty( prop, newLoc );
29  if ( sc.isFailure() ) throw GaudiException( "Could not set Property", prop + " -> " + newLoc, sc );
30  }
31 
32  [[deprecated(
33  "please use `updateHandleLocations` instead of `Gaudi::Functional::updateHandleLocations`" )]] inline void
34  updateHandleLocations( IProperty& parent, const std::string& prop, const std::vector<std::string>& newLocs ) {
37  ss << '[', newLocs, ", ", []( std::ostream & os, const auto& i ) -> auto& { return os << "'" << i << "'"; } )
38  << ']';
39  auto sc = parent.setProperty( prop, ss.str() );
40  if ( sc.isFailure() ) throw GaudiException( "Could not set Property", prop + " -> " + ss.str(), sc );
41  }
42 
43  namespace Traits {
44 
45  // traits classes used to customize Transformer and FilterPredicate
46  // Define the types to to be used as baseclass, and as in- resp. output hanldes.
47  // In case a type is not specified in the traits struct, a default is used.
48  //
49  // The defaults are:
50  //
51  // using BaseClass = GaudiAlgorithm
52  // template <typename T> using InputHandle = DataObjectHandle<T>;
53  // template <typename T> using OutputHandle = DataObjectHandle<T>;
54  //
55 
56  // the best way to 'compose' traits is by inheriting them one-by-one...
57  template <typename... Base>
58  struct use_ : Base... {};
59 
60  // helper classes one can inherit from to specify a specific trait
61  template <typename Base>
62  struct BaseClass_t {
63  using BaseClass = Base;
64  };
65 
66  template <template <typename> class Handle>
67  struct InputHandle_t {
68  template <typename T>
69  using InputHandle = Handle<T>;
70  };
71 
72  template <template <typename> class Handle>
73  struct OutputHandle_t {
74  template <typename T>
75  using OutputHandle = Handle<T>;
76  };
77 
78  // this uses the defaults -- and it itself is the default ;-)
80 
81  // this example uses GaudiHistoAlg as baseclass, and the default handle types for
82  // input and output
84 
85  // use Gaudi::Algorithm as base class -- this should be the base class!
87 
88  // use the legacy GaudiAlgorithm as base class -- this is (annoyingly) the current default
90 
91  } // namespace Traits
92 } // namespace Gaudi::Functional
93 
94 #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,...
STL class.
virtual StatusCode setProperty(const Gaudi::Details::PropertyBase &p)=0
Set the property by property.
T str(T... args)
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:37
string s
Definition: gaudirun.py:318
The IProperty is the basic interface for all components which have properties that can be set or get.
Definition: IProperty.h:20
STL class.