Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:31:58

0001 // Author: Enrico Guiraud, 2021
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers.               *
0005  * All rights reserved.                                                  *
0006  *                                                                       *
0007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0009  *************************************************************************/
0010 
0011 #ifndef ROOT_RDF_RNEWSAMPLENOTIFIER
0012 #define ROOT_RDF_RNEWSAMPLENOTIFIER
0013 
0014 #include <TNotifyLink.h>
0015 
0016 #include <memory>
0017 
0018 namespace ROOT {
0019 namespace Internal {
0020 namespace RDF {
0021 
0022 struct RNewSampleFlag {
0023    bool fFlag = false;
0024 
0025 public:
0026    void SetFlag() { fFlag = true; }
0027    void UnsetFlag() { fFlag = false; }
0028    bool CheckFlag() const { return fFlag; }
0029    bool Notify()
0030    {
0031       SetFlag();
0032       return true;
0033    }
0034 };
0035 
0036 class RNewSampleNotifier {
0037    // TNotifyLink and RNewSampleFlags per processing slot
0038    std::vector<std::unique_ptr<TNotifyLink<RNewSampleFlag>>> fNotifyLink{};
0039    std::vector<RNewSampleFlag> fFlags{};
0040 
0041 public:
0042    RNewSampleNotifier() = default;
0043    RNewSampleNotifier(unsigned int nSlots) : fNotifyLink(nSlots), fFlags(nSlots) {}
0044    bool CheckFlag(unsigned int slot) const { return fFlags[slot].CheckFlag(); }
0045    void SetFlag(unsigned int slot) { fFlags[slot].SetFlag(); }
0046    void UnsetFlag(unsigned int slot) { fFlags[slot].UnsetFlag(); }
0047    TNotifyLink<RNewSampleFlag> &GetChainNotifyLink(unsigned int slot)
0048    {
0049       if (fNotifyLink[slot] == nullptr)
0050          fNotifyLink[slot] = std::make_unique<TNotifyLink<RNewSampleFlag>>(&fFlags[slot]);
0051       return *fNotifyLink[slot];
0052    }
0053 };
0054 } // namespace RDF
0055 } // namespace Internal
0056 } // namespace ROOT
0057 
0058 #endif // ROOT_RDF_RDATABLOCKNOTIFIER