Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 09:09:48

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #pragma once
0012 
0013 #include <GaudiKernel/DataObjectHandle.h>
0014 #include <GaudiKernel/SerializeSTL.h>
0015 #include <boost/algorithm/string/join.hpp>
0016 #include <initializer_list>
0017 #include <string>
0018 
0019 namespace Gaudi::Functional {
0020 
0021   namespace Traits {
0022 
0023     // traits classes used to customize Transformer and FilterPredicate
0024     // Define the types to to be used as baseclass, and as in- resp. output hanldes.
0025     // In case a type is not specified in the traits struct, a default is used.
0026     //
0027     // The defaults are:
0028     //
0029     //      using BaseClass = GaudiAlgorithm
0030     //      template <typename T> using InputHandle = DataObjectHandle<T>;
0031     //      template <typename T> using OutputHandle = DataObjectHandle<T>;
0032     //
0033 
0034     // the best way to 'compose' traits is by inheriting them one-by-one...
0035     template <typename... Base>
0036     struct use_ : Base... {};
0037 
0038     // helper classes one can inherit from to specify a specific trait
0039     template <typename Base>
0040     struct BaseClass_t {
0041       using BaseClass = Base;
0042     };
0043 
0044     template <template <typename> class Handle>
0045     struct InputHandle_t {
0046       template <typename T>
0047       using InputHandle = Handle<T>;
0048     };
0049 
0050     template <template <typename> class Handle>
0051     struct OutputHandle_t {
0052       template <typename T>
0053       using OutputHandle = Handle<T>;
0054     };
0055 
0056     template <typename Data, typename View>
0057     struct writeViewFor {
0058       template <typename T>
0059       using OutputHandle = std::enable_if_t<std::is_same_v<T, Data>, DataObjectWriteHandle<View, Data>>;
0060     };
0061 
0062     // add support for objects that should reside in the TES for lifetime management, but should not
0063     // be used explicitly and/or directly by downstream code.
0064     template <typename Data>
0065     struct WriteOpaqueFor {
0066       struct OpaqueView {
0067         OpaqueView() = default;
0068         template <typename T>
0069         OpaqueView( T const& ) {}
0070       };
0071 
0072       template <typename T>
0073       using OutputHandle = std::enable_if_t<std::is_same_v<T, Data>, DataObjectWriteHandle<OpaqueView, Data>>;
0074     };
0075 
0076     // this uses the defaults -- and it itself is the default ;-)
0077     using useDefaults = use_<>;
0078   } // namespace Traits
0079 } // namespace Gaudi::Functional