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 <initializer_list>
5 #include <string>
6 #include "boost/algorithm/string/join.hpp"
7 
8 // TODO: fwd declare instead?
13 #include "GaudiAlg/GaudiHistoAlg.h"
14 
15 namespace Gaudi { 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, const std::vector<std::string>& newLocs) {
34  GaudiUtils::details::ostream_joiner( ss << '[', newLocs, ", " ,
35  [](std::ostream& os, const auto& i)
36  -> auto& { return os << "'" << i << "'"; } ) << ']';
37  auto sc = parent.setProperty(prop,ss.str());
38  if (sc.isFailure()) throw GaudiException("Could not set Property",prop + " -> " + ss.str(),sc);
39  }
40 
41  [[deprecated("please use updateHandleLocation instead")]]
42  inline void updateReadHandleLocation(IProperty& parent, const std::string& prop, const std::string& newLoc)
43  { return updateHandleLocation(parent,prop,newLoc); }
44 
45 namespace Traits {
46 
47  // traits classes used to customize Transformer and FilterPredicate
48  // Define the types to to be used as baseclass, and as in- resp. output hanldes.
49  // In case a type is not specified in the traits struct, a default is used.
50  //
51  // The defaults are:
52  //
53  // using BaseClass = GaudiAlgorithm
54  // template <typename T> using InputHandle = DataObjectHandle<T>;
55  // template <typename T> using OutputHandle = DataObjectHandle<T>;
56  //
57 
58  // the best way to 'compose' traits is by inheriting them one-by-one...
59  template <typename ... Base> struct use_ : Base... {};
60 
61  // helper classes one can inherit from to specify a specific trait
62  template <typename Base>
63  struct BaseClass_t { using BaseClass = Base; };
64 
65  template <template<typename> class Handle>
66  struct InputHandle_t { template <typename T> using InputHandle = Handle<T>; };
67 
68  template <template<typename> class Handle>
69  struct OutputHandle_t { template <typename T> using OutputHandle = Handle<T>; };
70 
71  // this uses the defaults -- and it itself is the default ;-)
73 
74  // example: use AnyDataHandle as input and output, and the default BaseClass
77 
78  // this example uses GaudiHistoAlg as baseclass, and the default handle types for
79  // input and output
81 
82 }
83 
84 }}
85 
86 #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:35
string s
Definition: gaudirun.py:245
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