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