Merge "Added New() function creating Renderer with RenderCallback" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / signals / connection-tracker-interface.h
1 #ifndef DALI_CONNECTION_TRACKER_INTERFACE_H
2 #define DALI_CONNECTION_TRACKER_INTERFACE_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/common/dali-common.h>
23 #include <dali/public-api/signals/signal-slot-observers.h>
24
25 namespace Dali
26 {
27 /**
28  * @addtogroup dali_core_signals
29  * @{
30  */
31
32 /**
33  * @brief Interface used to track connections between signals and slots.
34  *
35  * Performs automatic connection and disconnection when either the slot or signal dies.
36  *
37  * @code
38  * class MyApp : public ConnectionTracker
39  * {
40  *   Button.ClickedSignal().Connect( this, &MyApp::OnPress );
41  *
42  *   void OnPress()
43  *   {
44  *     std::cout << "hello world" << std::endl;
45  *   }
46  * }
47  * @endcode
48  *
49  * When MyApp is destroyed, it automatically disconnects from Button.ClickSignal.
50  * It provides a signal observer interface, to observer when signals are destroyed
51  * e.g. if Button object is destroyed while it is still connected.
52  * @SINCE_1_0.0
53  */
54 class DALI_CORE_API ConnectionTrackerInterface : public SignalObserver
55 {
56 public:
57   /**
58    * @brief Constructor.
59    * @SINCE_1_0.0
60    */
61   ConnectionTrackerInterface();
62
63   /**
64    * @brief Virtual destructor.
65    * @SINCE_1_0.0
66    */
67   ~ConnectionTrackerInterface() override;
68
69   /**
70    * @brief Called when a signal is connected.
71    *
72    * @SINCE_1_0.0
73    * @param[in] slotObserver The slot observer i.e. a signal. Ownership is not passed
74    * @param[in] callback The call back. Ownership is not passed
75    */
76   virtual void SignalConnected(SlotObserver* slotObserver, CallbackBase* callback) = 0;
77
78 private:
79   ConnectionTrackerInterface(const ConnectionTrackerInterface&) = delete;            ///< Deleted copy constructor. @SINCE_1_0.0
80   ConnectionTrackerInterface(ConnectionTrackerInterface&&)      = delete;            ///< Deleted move constructor. @SINCE_1_9.25
81   ConnectionTrackerInterface& operator=(const ConnectionTrackerInterface&) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0
82   ConnectionTrackerInterface& operator=(ConnectionTrackerInterface&&) = delete;      ///< Deleted move assignment operator. @SINCE_1_9.25
83 };
84
85 /**
86  * @}
87  */
88 } // namespace Dali
89
90 #endif // DALI_CONNECTION_TRACKER_INTERFACE_H