| 1 | /* |
| 2 | * Copyright 2002 - 2016, The libsigc++ Development Team |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Lesser General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2.1 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public |
| 15 | * License along with this library; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | */ |
| 19 | #ifndef SIGC_TRACKABLE_HPP |
| 20 | #define SIGC_TRACKABLE_HPPcxx . . $ `sigc++/trackable.h:20:9`! |
| 21 | #include <list> |
| 22 | #include <sigc++config.h>cxx . . $ `<file>/config.h`/ |
| 23 | |
| 24 | namespace sigccxx . . $ sigc/ |
| 25 | { |
| 26 | |
| 27 | struct notifiablecxx . . $ sigc/notifiable#; |
| 28 | |
| 29 | namespace internalcxx . . $ sigc/internal/ |
| 30 | { |
| 31 | |
| 32 | using func_destroy_notifycxx . . $ sigc/internal/func_destroy_notify# = void (*)(notifiablecxx . . $ sigc/notifiable#* data); |
| 33 | |
| 34 | /** Destroy notification callback. |
| 35 | * A destroy notification callback consists of a data pointer and a |
| 36 | * function pointer. The function is executed from the owning callback |
| 37 | * list (of type sigc::internal::trackable_callback_list) when its parent |
| 38 | * object (of type sigc::trackable) is destroyed or overwritten. |
| 39 | */ |
| 40 | struct SIGC_APIcxx . . $ `../sigc++config.h:63:9`! trackable_callbackcxx . . $ sigc/internal/trackable_callback# |
| 41 | { |
| 42 | notifiablecxx . . $ sigc/notifiable#* data_cxx . . $ sigc/internal/trackable_callback#data_.; |
| 43 | func_destroy_notifycxx . . $ sigc/internal/func_destroy_notify# func_cxx . . $ sigc/internal/trackable_callback#func_.; |
| 44 | trackable_callbackcxx . . $ sigc/internal/trackable_callback#trackable_callback(31e37e50dec1f931).(notifiablecxx . . $ sigc/notifiable#* data, func_destroy_notifycxx . . $ sigc/internal/func_destroy_notify# func) noexcept : data_cxx . . $ sigc/internal/trackable_callback#data_.(data), func_cxx . . $ sigc/internal/trackable_callback#func_.(func) |
| 45 | { |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | /** Callback list. |
| 50 | * A callback list holds an STL list of callbacks of type |
| 51 | * trackable_callback. Callbacks are added and removed with |
| 52 | * add_callback(), remove_callback() and clear(). The callbacks |
| 53 | * are invoked from clear() and from the destructor. |
| 54 | */ |
| 55 | struct SIGC_APIcxx . . $ `../sigc++config.h:63:9`! trackable_callback_listcxx . . $ sigc/internal/trackable_callback_list# |
| 56 | { |
| 57 | /** Add a callback function. |
| 58 | * @param data Data that will be sent as a parameter to teh callback function. |
| 59 | * @param func The callback function. |
| 60 | * |
| 61 | */ |
| 62 | void add_callbackcxx . . $ sigc/internal/trackable_callback_list#add_callback(ac3cffc818ecd34a).(notifiablecxx . . $ sigc/notifiable#* data, func_destroy_notifycxx . . $ sigc/internal/func_destroy_notify# func); |
| 63 | |
| 64 | /** Remove the callback which has this data associated with it. |
| 65 | * @param data The data that was given as a parameter to add_callback(). |
| 66 | */ |
| 67 | void remove_callbackcxx . . $ sigc/internal/trackable_callback_list#remove_callback(a64f0c2c305282d1).(notifiablecxx . . $ sigc/notifiable#* data); |
| 68 | |
| 69 | /** This invokes all of the callback functions. |
| 70 | */ |
| 71 | void clearcxx . . $ sigc/internal/trackable_callback_list#clear(49f6e7a06ebc5aa8).(); |
| 72 | |
| 73 | trackable_callback_listcxx . . $ sigc/internal/trackable_callback_list#trackable_callback_list(49f6e7a06ebc5aa8).() : clearing_cxx . . $ sigc/internal/trackable_callback_list#clearing_.(false) {} |
| 74 | |
| 75 | trackable_callback_listcxx . . $ sigc/internal/trackable_callback_list#trackable_callback_list(aae56abd10033444).(const trackable_callback_listcxx . . $ sigc/internal/trackable_callback_list#& src) = delete; |
| 76 | trackable_callback_listcxx . . $ sigc/internal/trackable_callback_list#& operatorcxx . . $ sigc/internal/trackable_callback_list#`operator=`(3b20c06b45eac453).=(const trackable_callback_listcxx . . $ sigc/internal/trackable_callback_list#& src) = delete; |
| 77 | trackable_callback_listcxx . . $ sigc/internal/trackable_callback_list#trackable_callback_list(a14bf45a84e80af8).(trackable_callback_listcxx . . $ sigc/internal/trackable_callback_list#&& src) = delete; |
| 78 | trackable_callback_listcxx . . $ sigc/internal/trackable_callback_list#& operatorcxx . . $ sigc/internal/trackable_callback_list#`operator=`(e95280db0f2bfd36).=(trackable_callback_listcxx . . $ sigc/internal/trackable_callback_list#&& src) = delete; |
| 79 | |
| 80 | /** This invokes all of the callback functions. |
| 81 | */ |
| 82 | ~cxx . . $ sigc/internal/trackable_callback_list#`~trackable_callback_list`(49f6e7a06ebc5aa8).trackable_callback_listcxx . . $ sigc/internal/trackable_callback_list#(); |
| 83 | |
| 84 | private: |
| 85 | using callback_listcxx . . $ sigc/internal/trackable_callback_list#callback_list# = stdcxx . . $ std/::listcxx . . $ std/__cxx11/list#<trackable_callbackcxx . . $ sigc/internal/trackable_callback#>; |
| 86 | callback_listcxx . . $ sigc/internal/trackable_callback_list#callback_list# callbacks_cxx . . $ sigc/internal/trackable_callback_list#callbacks_.; |
| 87 | bool clearing_cxx . . $ sigc/internal/trackable_callback_list#clearing_.; |
| 88 | }; |
| 89 | |
| 90 | } /* namespace internal */ |
| 91 | |
| 92 | struct SIGC_APIcxx . . $ `../sigc++config.h:63:9`! notifiablecxx . . $ sigc/notifiable# |
| 93 | { |
| 94 | using func_destroy_notifycxx . . $ sigc/notifiable#func_destroy_notify# = internalcxx . . $ sigc/internal/::func_destroy_notifycxx . . $ sigc/internal/func_destroy_notify#; |
| 95 | }; |
| 96 | |
| 97 | /** Base class for objects with auto-disconnection. |
| 98 | * trackable must be inherited when objects shall automatically |
| 99 | * invalidate slots referring to them on destruction. |
| 100 | * A slot built from a member function of a trackable derived |
| 101 | * type installs a callback that is invoked when the trackable object |
| 102 | * is destroyed or overwritten. |
| 103 | * |
| 104 | * add_destroy_notify_callback() and remove_destroy_notify_callback() |
| 105 | * can be used to manually install and remove callbacks when |
| 106 | * notification of the object dying is needed. |
| 107 | * |
| 108 | * notify_callbacks() invokes and removes all previously installed |
| 109 | * callbacks and can therefore be used to disconnect from all signals. |
| 110 | * |
| 111 | * Note that there is no virtual destructor. Don't use @p trackable* |
| 112 | * as pointer type for managing your data or the destructors of |
| 113 | * your derived types won't be called when deleting your objects. |
| 114 | * |
| 115 | * @ingroup signal |
| 116 | */ |
| 117 | struct SIGC_APIcxx . . $ `../sigc++config.h:63:9`! trackablecxx . . $ sigc/trackable# : public notifiablecxx . . $ sigc/notifiable# |
| 118 | { |
| 119 | // Concerning noexcept specifications: |
| 120 | // libsigc++ does not have complete control of what happens when notify_callbacks() |
| 121 | // is called. It may throw an exception. A method that calls notify_callbacks() |
| 122 | // shall not be declared noexcept. |
| 123 | |
| 124 | trackablecxx . . $ sigc/trackable#trackable(ced63f7c635d850d).() noexcept; |
| 125 | |
| 126 | trackablecxx . . $ sigc/trackable#trackable(746918fe6afd4586).(const trackablecxx . . $ sigc/trackable#& src) noexcept; |
| 127 | |
| 128 | trackablecxx . . $ sigc/trackable#trackable(4c2748790abfa513).(trackablecxx . . $ sigc/trackable#&& src) noexcept; |
| 129 | |
| 130 | trackablecxx . . $ sigc/trackable#& operatorcxx . . $ sigc/trackable#`operator=`(ed0c0ea1e014c72c).=(const trackablecxx . . $ sigc/trackable#& src); |
| 131 | |
| 132 | trackablecxx . . $ sigc/trackable#& operatorcxx . . $ sigc/trackable#`operator=`(619f9e53b8e16e0a).=(trackablecxx . . $ sigc/trackable#&& src) noexcept; |
| 133 | |
| 134 | ~cxx . . $ sigc/trackable#`~trackable`(ced63f7c635d850d).trackablecxx . . $ sigc/trackable#(); |
| 135 | |
| 136 | /*virtual ~trackable() {} */ /* we would need a virtual dtor for users |
| 137 | who insist on using "trackable*" as |
| 138 | pointer type for their own derived objects */ |
| 139 | |
| 140 | using func_destroy_notifycxx . . $ sigc/trackable#func_destroy_notify# = internalcxx . . $ sigc/internal/::func_destroy_notifycxx . . $ sigc/internal/func_destroy_notify#; |
| 141 | |
| 142 | /** Add a callback that is executed (notified) when the trackable object is detroyed. |
| 143 | * @param data Passed into func upon notification. |
| 144 | * @param func Callback executed upon destruction of the object. |
| 145 | */ |
| 146 | void add_destroy_notify_callbackcxx . . $ sigc/trackable#add_destroy_notify_callback(ae8c96f91df34487).(notifiablecxx . . $ sigc/notifiable#* data, func_destroy_notifycxx . . $ sigc/trackable#func_destroy_notify# func) const; |
| 147 | |
| 148 | /** Remove a callback previously installed with add_destroy_notify_callback(). |
| 149 | * The callback is not executed. |
| 150 | * @param data Parameter passed into previous call to add_destroy_notify_callback(). |
| 151 | */ |
| 152 | void remove_destroy_notify_callbackcxx . . $ sigc/trackable#remove_destroy_notify_callback(3f7bb6b0b7f0cabe).(notifiablecxx . . $ sigc/notifiable#* data) const; |
| 153 | |
| 154 | /// Execute and remove all previously installed callbacks. |
| 155 | void notify_callbackscxx . . $ sigc/trackable#notify_callbacks(49f6e7a06ebc5aa8).(); |
| 156 | |
| 157 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 158 | private: |
| 159 | /* The callbacks are held in a list of type trackable_callback_list. |
| 160 | * This list is allocated dynamically when the first callback is added. |
| 161 | */ |
| 162 | internalcxx . . $ sigc/internal/::trackable_callback_listcxx . . $ sigc/internal/trackable_callback_list#* callback_listcxx . . $ sigc/trackable#callback_list(b7ddef075ca57414).() const; |
| 163 | mutable internalcxx . . $ sigc/internal/::trackable_callback_listcxx . . $ sigc/internal/trackable_callback_list#* callback_list_cxx . . $ sigc/trackable#callback_list_.; |
| 164 | #endif |
| 165 | }; |
| 166 | |
| 167 | } /* namespace sigc */ |
| 168 | |
| 169 | #endif /* SIGC_TRACKABLE_HPP */ |