Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / capi / 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) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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  * @addtogroup CAPI_DALI_SIGNALS_MODULE
22  * @{
23  */
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/common/dali-common.h>
27 #include <dali/public-api/signals/signal-slot-observers.h>
28
29 namespace Dali DALI_IMPORT_API
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  */
53 class ConnectionTrackerInterface : public SignalObserver
54 {
55 public:
56
57   /**
58    * @brief Constructor.
59    */
60   ConnectionTrackerInterface();
61
62   /**
63    * @brief Virtual destructor.
64    */
65   virtual ~ConnectionTrackerInterface();
66
67   /**
68    * @brief Called when a signal is connected.
69    *
70    * @param[in] slotObserver The slot observer i.e. a signal.
71    * @param[in] callback The call back.
72    */
73   virtual void SignalConnected( SlotObserver* slotObserver, CallbackBase* callback ) = 0;
74
75   /**
76    * @brief Query the connection count.
77    *
78    * @return The number of signal/slot connections know by the connection tracker.
79    */
80   virtual std::size_t GetConnectionCount() const = 0;
81
82 private:
83
84   ConnectionTrackerInterface( const ConnectionTrackerInterface& );            ///< undefined copy constructor
85   ConnectionTrackerInterface& operator=( const ConnectionTrackerInterface& ); ///< undefined assignment operator
86 };
87
88 } // namespace Dali
89
90 /**
91  * @}
92  */
93 #endif // __DALI_CONNECTION_TRACKER_INTERFACE_H__