CAPI removal
[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) 2014 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 DALI_IMPORT_API
25 {
26
27 class CallbackBase;
28
29 /**
30  * @brief Slot connection is the connection information held by a connection tracker.
31  *
32  * A slot can have zero to many connection objects, depending
33  * on how many signals it is connected to.
34  *
35  * A connection contains:
36  * - Callback (slot)
37  * - SlotObserver -interface provided by the signal
38  *
39  * It takes ownership of the callback, and will delete it when
40  * the connection is destroyed.
41  */
42 class SlotConnection
43 {
44 public:
45
46   /**
47    * @brief Constructor.
48    *
49    * @param[in] slotObserver The slot observer.
50    * @param[in] callback Ownership of this callback object is taken.
51    */
52   SlotConnection(SlotObserver* slotObserver, CallbackBase* callback);
53
54   /**
55    * @brief Non-virtual destructor, not intended as a base class.
56    */
57   ~SlotConnection();
58
59   /**
60    * @brief Retrieve the callback.
61    *
62    * @return A pointer to the callback.
63    */
64   CallbackBase* GetCallback();
65
66   /**
67    * @brief Retrieve the slot observer.
68    *
69    * @return A pointer to the slot observer.
70    */
71   SlotObserver* GetSlotObserver();
72
73 private:
74
75   SlotConnection( const SlotConnection& );            ///< undefined copy constructor
76   SlotConnection& operator=( const SlotConnection& ); ///< undefined assignment operator
77
78 private:
79
80   SlotObserver* mSlotObserver; ///< a pointer to the slot observer (not owned)
81   CallbackBase* mCallback;     ///< callback, has ownership
82 };
83
84 /**
85  * @brief SignalConnection is the connection information held by the signal.
86  *
87  * A signal can have zero to many connections, depending on how
88  * many slots are connected to this signal.
89  *
90  * A connection contains:
91  * - Callback (slot)
92  * - SignalObserver - interface provided by a slot owning object.
93  *
94  * It holds a pointer to the callback, but does not own it.
95  *
96  */
97 class SignalConnection
98 {
99 public:
100
101   /**
102    * @brief Constructor.
103    *
104    * @param[in] callback The callback which should be a C function.
105    */
106   SignalConnection( CallbackBase* callback );
107
108   /**
109    * @brief Constructor.
110    *
111    * @param[in] signalObserver The signal observer.
112    * @param[in] callback The callback which should be a member function of the signalObserver.
113    */
114   SignalConnection( SignalObserver* signalObserver, CallbackBase* callback );
115
116   /**
117    * @brief Non-virtual destructor, not intended as a base class.
118    */
119   ~SignalConnection();
120
121   /**
122    * @brief Disconnect the signal from the slot.
123    *
124    * @param[in] slotObserver The signal disconnecting from the slot.
125    */
126   void Disconnect( SlotObserver* slotObserver );
127
128   /**
129    * @brief Retrieve the callback.
130    *
131    * @return A pointer to the callback.
132    */
133   CallbackBase* GetCallback();
134
135 private:
136
137   SignalConnection( const SignalConnection& );            ///< undefined copy constructor
138   SignalConnection& operator=( const SignalConnection& ); ///< undefined assignment operator
139
140 private:
141
142   SignalObserver* mSignalObserver; ///< a pointer to the signal observer (not owned)
143   CallbackBase* mCallback;         ///< The callback. This is not owned, the corresponding SlotConnection has ownership.
144 };
145
146 } // namespace Dali
147
148 #endif // __DALI_SIGNAL_SLOT_CONNECTIONS_H__