GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
GNotifier.h
Go to the documentation of this file.
1#ifndef GRUTNOTIFIER_H
2#define GRUTNOTIFIER_H
3
4#ifndef __CINT__
5#include <functional>
6#endif
7
8#include "TNamed.h"
9
10class GNotifier : public TNamed {
11public:
12 static GNotifier* Get();
13 ~GNotifier() = default;
14
15 void Print(Option_t* = "") const override {}
16 void Clear(Option_t* = "") override {}
17 bool Notify() override;
18
19#ifdef __CINT__
20 static void AddCallback(void (*func)());
21#else
22 template <typename T>
23 static void AddCallback(T callback)
24 {
25 Get()->fCallbacks.push_back(callback);
26 }
27
28 static void AddCallback(void (*func)()) { Get()->fCallbacks.emplace_back(func); }
29#endif
30
31private:
32 GNotifier() = default;
33 GNotifier(const GNotifier&) = default;
34 GNotifier(GNotifier&&) noexcept = default;
35 GNotifier& operator=(const GNotifier&) = default;
36 GNotifier& operator=(GNotifier&&) noexcept = default;
37
38#ifndef __CINT__
39 std::vector<std::function<void()>> fCallbacks;
40#endif
41
43
44 /// /cond CLASSIMP
45 ClassDefOverride(GNotifier, 0) // NOLINT(readability-else-after-return)
46 /// /endcond
47};
48
49#endif
void Print(Option_t *="") const override
Definition GNotifier.h:15
static void AddCallback(void(*func)())
Definition GNotifier.h:28
GNotifier(const GNotifier &)=default
GNotifier(GNotifier &&) noexcept=default
std::vector< std::function< void()> > fCallbacks
Definition GNotifier.h:39
GNotifier()=default
static GNotifier * Get()
Definition GNotifier.cxx:11
void Clear(Option_t *="") override
Definition GNotifier.h:16
~GNotifier()=default
bool Notify() override
Definition GNotifier.cxx:19
static GNotifier * fGNotifier
Definition GNotifier.h:42
static void AddCallback(T callback)
Definition GNotifier.h:23