12 #ifndef ROOT_TNotifyLink
13 #define ROOT_TNotifyLink
32 class TNotifyLinkBase :
public TObject {
34 TNotifyLinkBase *fPrevious =
nullptr;
35 TObject *fNext =
nullptr;
43 void Clear(Option_t * =
"") {
46 auto next =
dynamic_cast<TNotifyLinkBase*
>(fNext);
47 current->ResetBit(kLinked);
48 current->fPrevious =
nullptr;
49 current->fNext =
nullptr;
54 template <
class Notifier>
55 void PrependLink(Notifier ¬ifier) {
58 fNext = notifier.GetNotify();
59 if (
auto link = dynamic_cast<TNotifyLinkBase*>(fNext)) {
60 link->fPrevious =
this;
62 notifier.SetNotify(
this);
65 template <
class Notifier>
66 void RemoveLink(Notifier ¬ifier) {
69 if (notifier.GetNotify() ==
this) {
70 R__ASSERT(fPrevious ==
nullptr &&
"The TNotifyLink head node should not have a previous element.");
71 notifier.SetNotify(fNext);
72 }
else if (fPrevious) {
73 fPrevious->fNext = fNext;
75 if (
auto link = dynamic_cast<TNotifyLinkBase*>(fNext)) {
76 link->fPrevious = fPrevious;
83 return TestBit(kLinked);
86 ClassDef(TNotifyLinkBase, 0);
90 class TNotifyLink :
public TNotifyLinkBase {
95 TNotifyLink(Type *current) : fCurrent(current) {}
98 Bool_t Notify()
override
100 auto result = fCurrent ? fCurrent->Notify() : kTRUE;
101 if (fNext) result &= fNext->Notify();
105 ClassDefOverride(TNotifyLink, 0);
108 #endif // ROOT_TNotifyLink