Merge "Fix indenting" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / signals / signal-slot-connections.h
1 #ifndef DALI_SIGNAL_SLOT_CONNECTIONS_H
2 #define DALI_SIGNAL_SLOT_CONNECTIONS_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/signals/signal-slot-observers.h>
23
24 namespace Dali
25 {
26 /**
27  * @addtogroup dali_core_signals
28  * @{
29  */
30
31 class CallbackBase;
32
33 /**
34  * @brief Slot connection is the connection information held by a connection tracker.
35  *
36  * A slot can have zero to many connection objects, depending
37  * on how many signals it is connected to.
38  *
39  * A connection contains:
40  * - Callback (slot)
41  * - SlotObserver -interface provided by the signal
42  *
43  * It holds a pointer to the callback, but does not own it.
44  * @SINCE_1_0.0
45  */
46 class DALI_CORE_API SlotConnection
47 {
48 public:
49
50   /**
51    * @brief Constructor.
52    *
53    * @SINCE_1_0.0
54    * @param[in] slotObserver The slot observer
55    * @param[in] callback A callback object (not owned)
56    */
57   SlotConnection(SlotObserver* slotObserver, CallbackBase* callback);
58
59   /**
60    * @brief Non-virtual destructor, not intended as a base class.
61    * @SINCE_1_0.0
62    */
63   ~SlotConnection();
64
65   /**
66    * @brief Retrieves the callback.
67    *
68    * @SINCE_1_0.0
69    * @return A pointer to the callback
70    */
71   CallbackBase* GetCallback();
72
73   /**
74    * @brief Retrieves the slot observer.
75    *
76    * @SINCE_1_0.0
77    * @return A pointer to the slot observer
78    */
79   SlotObserver* GetSlotObserver();
80
81 private:
82
83   SlotConnection( const SlotConnection& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0
84   SlotConnection( SlotConnection&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25
85   SlotConnection& operator=( const SlotConnection& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0
86   SlotConnection& operator=( SlotConnection&& ) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25
87
88 private:
89
90   SlotObserver* mSlotObserver; ///< a pointer to the slot observer (not owned)
91   CallbackBase* mCallback;     ///< The callback. This is not owned, the corresponding SignalConnection has ownership.
92 };
93
94 /**
95  * @brief SignalConnection is the connection information held by the signal.
96  *
97  * A signal can have zero to many connections, depending on how
98  * many slots are connected to this signal.
99  *
100  * A connection contains:
101  * - Callback (slot)
102  * - SignalObserver - interface provided by a slot owning object.
103  *
104  * It takes ownership of the callback, and will delete it when
105  * the connection is destroyed.
106  * @SINCE_1_0.0
107  */
108 class DALI_CORE_API SignalConnection
109 {
110 public:
111
112   /**
113    * @brief Constructor.
114    *
115    * @SINCE_1_0.0
116    * @param[in] callback The callback which should be a C function
117    */
118   SignalConnection( CallbackBase* callback );
119
120   /**
121    * @brief Constructor.
122    *
123    * @SINCE_1_0.0
124    * @param[in] signalObserver The signal observer
125    * @param[in] callback Ownership of this callback object is taken
126    */
127   SignalConnection( SignalObserver* signalObserver, CallbackBase* callback );
128
129   /**
130    * @brief Non-virtual destructor, not intended as a base class.
131    * @SINCE_1_0.0
132    */
133   ~SignalConnection();
134
135   /**
136    * @brief Disconnects the signal from the slot.
137    *
138    * @SINCE_1_0.0
139    * @param[in] slotObserver The signal disconnecting from the slot
140    */
141   void Disconnect( SlotObserver* slotObserver );
142
143   /**
144    * @brief Retrieves the callback.
145    *
146    * @SINCE_1_0.0
147    * @return A pointer to the callback
148    */
149   CallbackBase* GetCallback();
150
151 private:
152
153   SignalConnection( const SignalConnection& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0
154   SignalConnection( SignalConnection&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25
155   SignalConnection& operator=( const SignalConnection& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0
156   SignalConnection& operator=( SignalConnection&& ) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25
157
158 private:
159
160   SignalObserver* mSignalObserver; ///< a pointer to the signal observer (not owned)
161   CallbackBase* mCallback;         ///< The callback, has ownership.
162 };
163
164 /**
165  * @}
166  */
167 } // namespace Dali
168
169 #endif // DALI_SIGNAL_SLOT_CONNECTIONS_H