Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:53:06

0001 /*************************************************************************
0002  * Copyright (C) 1995-2022, Rene Brun and Fons Rademakers.               *
0003  * All rights reserved.                                                  *
0004  *                                                                       *
0005  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0006  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0007  *************************************************************************/
0008 
0009 #ifndef ROOT_RDF_DETAIL_RACTIONIMPL
0010 #define ROOT_RDF_DETAIL_RACTIONIMPL
0011 
0012 #include <ROOT/RDF/RSampleInfo.hxx> // SampleCallback_t
0013 
0014 #include <memory> // std::unique_ptr
0015 #include <stdexcept> // std::logic_error
0016 #include <utility> // std::declval
0017 
0018 namespace ROOT {
0019 namespace Detail {
0020 namespace RDF {
0021 
0022 class RMergeableValueBase;
0023 
0024 /// Base class for action helpers, see RInterface::Book() for more information.
0025 template <typename Helper>
0026 class R__CLING_PTRCHECK(off) RActionImpl {
0027 public:
0028    virtual ~RActionImpl() = default;
0029    // call Helper::FinalizeTask if present, do nothing otherwise
0030    template <typename T = Helper>
0031    auto CallFinalizeTask(unsigned int slot) -> decltype(std::declval<T>().FinalizeTask(slot))
0032    {
0033       static_cast<Helper *>(this)->FinalizeTask(slot);
0034    }
0035 
0036    template <typename... Args>
0037    void CallFinalizeTask(unsigned int, Args...) {}
0038 
0039    template <typename H = Helper>
0040    auto CallPartialUpdate(unsigned int slot) -> decltype(std::declval<H>().PartialUpdate(slot), (void *)(nullptr))
0041    {
0042       return &static_cast<Helper *>(this)->PartialUpdate(slot);
0043    }
0044 
0045    template <typename... Args>
0046    [[noreturn]] void *CallPartialUpdate(...)
0047    {
0048       throw std::logic_error("This action does not support callbacks!");
0049    }
0050 
0051    template <typename T = Helper>
0052    auto CallMakeNew(void *typeErasedResSharedPtr) -> decltype(std::declval<T>().MakeNew(typeErasedResSharedPtr))
0053    {
0054       return static_cast<Helper *>(this)->MakeNew(typeErasedResSharedPtr);
0055    }
0056 
0057    template <typename... Args>
0058    [[noreturn]] Helper CallMakeNew(void *, Args...)
0059    {
0060       const auto &actionName = static_cast<Helper *>(this)->GetActionName();
0061       throw std::logic_error("The MakeNew method is not implemented for this action helper (" + actionName +
0062                              "). Cannot Vary its result.");
0063    }
0064 
0065    // Helper functions for RMergeableValue
0066    virtual std::unique_ptr<RMergeableValueBase> GetMergeableValue() const
0067    {
0068       throw std::logic_error("`GetMergeableValue` is not implemented for this type of action.");
0069    }
0070 
0071    /// Override this method to register a callback that is executed before the processing a new data sample starts.
0072    /// The callback will be invoked in the same conditions as with DefinePerSample().
0073    virtual ROOT::RDF::SampleCallback_t GetSampleCallback() { return {}; }
0074 };
0075 
0076 } // namespace RDF
0077 } // namespace Detail
0078 } // namespace ROOT
0079 
0080 #endif // ROOT_RDF_DETAIL_RACTIONIMPL
0081