Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  namespace Functional {
16 
17  // This utility is needed when the inputs of a functional algorithm may be stored in several locations
19  return boost::algorithm::join( c, ":" );
20  }
21 
22  template <typename... Strings>
23  std::string concat_alternatives( const Strings&... s ) {
25  }
26 
27  inline void 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  inline void updateHandleLocations( IProperty& parent, const std::string& prop,
33  const std::vector<std::string>& newLocs ) {
35  GaudiUtils::details::ostream_joiner( ss << '[', newLocs, ", ", []( std::ostream & os, const auto& i ) -> auto& {
36  return os << "'" << i << "'";
37  } ) << ']';
38  auto sc = parent.setProperty( prop, ss.str() );
39  if ( sc.isFailure() ) throw GaudiException( "Could not set Property", prop + " -> " + ss.str(), sc );
40  }
41 
42  [[deprecated( "please use updateHandleLocation instead" )]] inline void
43  updateReadHandleLocation( IProperty& parent, const std::string& prop, const std::string& newLoc ) {
44  return updateHandleLocation( parent, prop, newLoc );
45  }
46 
47  namespace Traits {
48 
49  // traits classes used to customize Transformer and FilterPredicate
50  // Define the types to to be used as baseclass, and as in- resp. output hanldes.
51  // In case a type is not specified in the traits struct, a default is used.
52  //
53  // The defaults are:
54  //
55  // using BaseClass = GaudiAlgorithm
56  // template <typename T> using InputHandle = DataObjectHandle<T>;
57  // template <typename T> using OutputHandle = DataObjectHandle<T>;
58  //
59 
60  // the best way to 'compose' traits is by inheriting them one-by-one...
61  template <typename... Base>
62  struct use_ : Base... {};
63 
64  // helper classes one can inherit from to specify a specific trait
65  template <typename Base>
66  struct BaseClass_t {
67  using BaseClass = Base;
68  };
69 
70  template <template <typename> class Handle>
71  struct InputHandle_t {
72  template <typename T>
73  using InputHandle = Handle<T>;
74  };
75 
76  template <template <typename> class Handle>
77  struct OutputHandle_t {
78  template <typename T>
79  using OutputHandle = Handle<T>;
80  };
81 
82  // this uses the defaults -- and it itself is the default ;-)
84 
85  // this example uses GaudiHistoAlg as baseclass, and the default handle types for
86  // input and output
88  } // namespace Traits
89  } // namespace Functional
90 } // namespace Gaudi
91 
92 #endif
Define general base for Gaudi exception.
std::string concat_alternatives(std::initializer_list< std::string > c)
Header file for class GaudiAlgorithm.
struct deprecated("use MergingTransformer instead")]] ListTransformer
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:37
string s
Definition: gaudirun.py:312
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