The Battle for Wesnoth  1.17.0-dev
notifiee.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2021
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include <cstdlib>
19 
20 namespace gui2
21 {
22 
23 template <class T>
24 class notifier;
25 
26 /**
27  * Helper class to implement callbacks with lifetime management.
28  *
29  * This part manages the lifetime off the callback.
30  */
31 template <class FUNCTOR>
32 class notifiee
33 {
34 public:
35  typedef FUNCTOR functor_t;
36  friend class notifier<functor_t>;
37 
38  notifiee() : notifier_(nullptr)
39  {
40  }
41 
43  {
44  if(notifier_) {
46  }
47  }
48 
49 private:
50  /** Pointer the the notifier that's linked to us. */
52 };
53 
54 } // namespace gui2
FUNCTOR functor_t
Definition: notifiee.hpp:35
void disconnect_notifiee(notifiee< functor_t > &target)
Disconnects a callback.
Definition: notifier.hpp:77
Helper class to implement callbacks with lifetime management.
Definition: notifiee.hpp:24
Generic file dialog.
Definition: field-fwd.hpp:23
Helper class to implement callbacks with lifetime management.
Definition: notifiee.hpp:32
notifier< functor_t > * notifier_
Pointer the the notifier that&#39;s linked to us.
Definition: notifiee.hpp:51