| 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 | |
| 20 | #ifndef SIGC_CONNECTION_HPP |
| 21 | #define SIGC_CONNECTION_HPPcxx . . $ `sigc++/connection.h:21:9`! |
| 22 | |
| 23 | #include <sigc++config.h>cxx . . $ `<file>/config.h`/ |
| 24 | #include <sigc++/functors/slot_base.h>cxx . . $ `<file>/sigc++/functors/slot_base.h`/ |
| 25 | #include <sigc++/weak_raw_ptr.h>cxx . . $ `<file>/sigc++/weak_raw_ptr.h`/ |
| 26 | |
| 27 | namespace sigccxx . . $ sigc/ |
| 28 | { |
| 29 | |
| 30 | /** Convenience class for safe disconnection. |
| 31 | * |
| 32 | * This may be used to disconnect the referred slot at any time (disconnect()). |
| 33 | * @ref sigc::signal_with_accumulator::connect() "sigc::signal::connect()" and |
| 34 | * @ref sigc::signal_with_accumulator::connect_first() "sigc::signal::connect_first()" |
| 35 | * return a %sigc::connection. |
| 36 | * |
| 37 | * @code |
| 38 | * sigc::connection conn = sig.connect(sigc::mem_fun(a, &A::foo)); |
| 39 | * @endcode |
| 40 | * |
| 41 | * If the slot has already been destroyed, disconnect() does nothing. empty() or |
| 42 | * operator bool() can be used to test whether the connection is |
| 43 | * still active. The connection can be blocked (block(), unblock()). |
| 44 | * |
| 45 | * sigc::connection doesnʼt disconnect the slot automatically upon destruction. |
| 46 | * You do not need to keep the sigc::connection object to retain the connection |
| 47 | * of the slot to the signal. See also @ref sigc::scoped_connection, which does |
| 48 | * disconnect automatically when the connection object is destroyed or replaced. |
| 49 | * |
| 50 | * @ingroup signal |
| 51 | */ |
| 52 | struct SIGC_APIcxx . . $ `../sigc++config.h:63:9`! connectioncxx . . $ sigc/connection# |
| 53 | { |
| 54 | /** Constructs an empty connection object. */ |
| 55 | connectioncxx . . $ sigc/connection#connection(ced63f7c635d850d).() noexcept; |
| 56 | |
| 57 | /** Constructs a connection object copying an existing one. |
| 58 | * @param c The connection object to make a copy from. |
| 59 | */ |
| 60 | connectioncxx . . $ sigc/connection#connection(cbd5a85bb633e16b).(const connectioncxx . . $ sigc/connection#& c); |
| 61 | |
| 62 | /** Constructs a connection object from a slot object. |
| 63 | * @param slot The slot to operate on. |
| 64 | */ |
| 65 | explicit connectioncxx . . $ sigc/connection#connection(ae2cd3d898ca407b).(slot_basecxx . . $ sigc/slot_base#& slot); |
| 66 | |
| 67 | /** Overrides this connection object copying another one. |
| 68 | * @param src The connection object to make a copy from. |
| 69 | */ |
| 70 | connectioncxx . . $ sigc/connection#& operatorcxx . . $ sigc/connection#`operator=`(d6e79c7c2c834e86).=(const connectioncxx . . $ sigc/connection#& src); |
| 71 | |
| 72 | ~cxx . . $ sigc/connection#`~connection`(ced63f7c635d850d).connectioncxx . . $ sigc/connection#(); |
| 73 | |
| 74 | /** Returns whether the connection is still active. |
| 75 | * @return @p false if the connection is still active. |
| 76 | */ |
| 77 | bool emptycxx . . $ sigc/connection#empty(3482b152b9333168).() const noexcept; |
| 78 | |
| 79 | /** Returns whether the connection is still active. |
| 80 | * @return @p true if the connection is still active. |
| 81 | */ |
| 82 | bool connectedcxx . . $ sigc/connection#connected(3482b152b9333168).() const noexcept; |
| 83 | |
| 84 | /** Returns whether the connection is blocked. |
| 85 | * @return @p true if the connection is blocked. |
| 86 | */ |
| 87 | bool blockedcxx . . $ sigc/connection#blocked(3482b152b9333168).() const noexcept; |
| 88 | |
| 89 | /** Sets or unsets the blocking state of this connection. |
| 90 | * See slot_base::block() for details. |
| 91 | * @param should_block Indicates whether the blocking state should be set or unset. |
| 92 | * @return @p true if the connection has been in blocking state before. |
| 93 | */ |
| 94 | bool blockcxx . . $ sigc/connection#block(4264aff4942d46ac).(bool should_block = true) noexcept; |
| 95 | |
| 96 | /** Unsets the blocking state of this connection. |
| 97 | * @return @p true if the connection has been in blocking state before. |
| 98 | */ |
| 99 | bool unblockcxx . . $ sigc/connection#unblock(77ce49a7840d23c7).() noexcept; |
| 100 | |
| 101 | /// Disconnects the referred slot. |
| 102 | void disconnectcxx . . $ sigc/connection#disconnect(49f6e7a06ebc5aa8).(); |
| 103 | |
| 104 | /** Returns whether the connection is still active. |
| 105 | * @return @p true if the connection is still active. |
| 106 | */ |
| 107 | explicit operatorcxx . . $ sigc/connection#`operator bool`(3482b152b9333168). bool() const noexcept; |
| 108 | |
| 109 | private: |
| 110 | void set_slotcxx . . $ sigc/connection#set_slot(802e204df22cf6d).(const sigccxx . . $ sigc/::internalcxx . . $ sigc/internal/::weak_raw_ptrcxx . . $ sigc/internal/weak_raw_ptr#<slot_basecxx . . $ sigc/slot_base#>& sl); |
| 111 | |
| 112 | /* Referred slot. Set to nullptr when the referred slot is deleted. |
| 113 | * A value of nullptr indicates an "empty" connection. |
| 114 | */ |
| 115 | sigccxx . . $ sigc/::internalcxx . . $ sigc/internal/::weak_raw_ptrcxx . . $ sigc/internal/weak_raw_ptr#<slot_basecxx . . $ sigc/slot_base#> slot_cxx . . $ sigc/connection#slot_.; |
| 116 | }; |
| 117 | |
| 118 | } /* namespace sigc */ |
| 119 | |
| 120 | #endif /* SIGC_CONNECTION_HPP */ |