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
10#include "GRootCommands.h"
11
12class GNotifier : public TNamed {
13public:
14 static GNotifier* Get();
15 ~GNotifier() = default;
16
17 void Print(Option_t* = "") const override {}
18 void Clear(Option_t* = "") override {}
19 bool Notify() override;
20
21#ifdef __CINT__
22 static void AddCallback(void (*func)());
23#else
24 template <typename T>
25 static void AddCallback(T callback)
26 {
27 Get()->fCallbacks.push_back(callback);
28 }
29
30 static void AddCallback(void (*func)()) { Get()->fCallbacks.emplace_back(func); }
31#endif
32
33private:
34 GNotifier() = default;
35 GNotifier(const GNotifier&) = default;
36 GNotifier(GNotifier&&) noexcept = default;
37 GNotifier& operator=(const GNotifier&) = default;
38 GNotifier& operator=(GNotifier&&) noexcept = default;
39
40#ifndef __CINT__
41 std::vector<std::function<void()>> fCallbacks;
42#endif
43
45
46 /// /cond CLASSIMP
47 ClassDefOverride(GNotifier, 0) // NOLINT(readability-else-after-return)
48 /// /endcond
49};
50
51#endif
void Print(Option_t *="") const override
Definition GNotifier.h:17
static void AddCallback(void(*func)())
Definition GNotifier.h:30
GNotifier(const GNotifier &)=default
GNotifier(GNotifier &&) noexcept=default
std::vector< std::function< void()> > fCallbacks
Definition GNotifier.h:41
GNotifier()=default
static GNotifier * Get()
Definition GNotifier.cxx:11
void Clear(Option_t *="") override
Definition GNotifier.h:18
~GNotifier()=default
bool Notify() override
Definition GNotifier.cxx:19
static GNotifier * fGNotifier
Definition GNotifier.h:44
static void AddCallback(T callback)
Definition GNotifier.h:25