Fix various Klocwork errors
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / popup / confirmation-popup-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_CONFIRMATION_POPUP_H__
2 #define __DALI_TOOLKIT_INTERNAL_CONFIRMATION_POPUP_H__
3
4 /*
5  * Copyright (c) 2015 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 // EXTERNAL INCLUDES
22 #include <dali/public-api/animation/animation.h>
23 #include <dali/public-api/common/dali-vector.h>
24 #include <dali/devel-api/signals/signal-delegate.h>
25
26 // INTERNAL INCLUDES
27 #include "popup-impl.h"
28 #include <dali-toolkit/devel-api/controls/popup/confirmation-popup.h>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 namespace Internal
37 {
38
39 #define MAXIMUM_NUMBER_OF_CONTROLS 2
40
41 /**
42  * ConfirmationPopup implementation class.
43  *
44  * \sa Dali::Toolkit::ConfirmationPopup
45  */
46 class ConfirmationPopup : public Dali::Toolkit::Internal::Popup
47 {
48 public:
49
50   /**
51    * Create a new ConfirmationPopup.
52    * @return A smart-pointer to the newly allocated ConfirmationPopup.
53    */
54   static Dali::Toolkit::ConfirmationPopup New();
55
56 protected:
57
58   /**
59    * Construct a new ConfirmationPopup.
60    */
61   ConfirmationPopup();
62
63   /**
64    * A reference counted object may only be deleted by calling Unreference()
65    */
66   virtual ~ConfirmationPopup();
67
68 public:
69
70   /**
71    * Called when a property of an object of this type is set.
72    * @param[in] object The object whose property is set.
73    * @param[in] propertyIndex The property index.
74    * @param[in] value The new property value.
75    */
76   static void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value );
77
78   /**
79    * Called to retrieve a property of an object of this type.
80    * @param[in] object The object whose property is to be retrieved.
81    * @param[in] propertyIndex The property index.
82    * @return The current value of the property.
83    */
84   static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
85
86   /**
87    * Connects a callback function with the object's signals.
88    * @param[in] object The object providing the signal.
89    * @param[in] tracker Used to disconnect the signal.
90    * @param[in] signalName The signal to connect to.
91    * @param[in] functor A newly allocated FunctorDelegate.
92    * @return True if the signal was connected.
93    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
94    */
95   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
96
97 private:
98
99   /**
100    * This type houses a list of dynamically created signals.
101    */
102   typedef std::vector< std::pair< std::string, SignalDelegate* > > SignalContainerType;
103
104 private:
105
106   /**
107    * Sets the name of the signal to connect to within the specified actor.
108    *
109    * @param[in] controlNumber The index of the control.
110    * @param[in] signalName The name of the signal to connect to.
111    */
112   void SetControlSignalName( const unsigned int controlNumber, const std::string& signalName );
113
114   /**
115    * Gets the name of the signal to connect to within the specified actor.
116    *
117    * @param[in] controlNumber The index of the control.
118    * @return The name of the signal to connect to.
119    */
120   std::string GetControlSignalName( unsigned int controlNumber ) const;
121
122   /**
123    * @copydoc Control::GetControlSignal()
124    */
125   SignalDelegate* GetControlSignal( const std::string& signalName );
126
127 private:
128
129   // Undefined
130   ConfirmationPopup( const ConfirmationPopup& );
131
132   // Undefined
133   ConfirmationPopup& operator=( const ConfirmationPopup& );
134
135 private:
136
137   // Properties:
138
139   std::string mControlSignalNames[ MAXIMUM_NUMBER_OF_CONTROLS ]; ///< Stores the names of the signals to connect to per control.
140
141   // Internal variables:
142
143   SignalContainerType mControlSignals;                           ///< Stores the dynamically created signals.
144
145 };
146
147 } // namespace Internal
148
149
150 // Helpers for public-api forwarding methods
151
152 inline Toolkit::Internal::ConfirmationPopup& GetDerivedImplementation( Toolkit::ConfirmationPopup& popup )
153 {
154   DALI_ASSERT_ALWAYS( popup );
155
156   Dali::RefObject& handle = popup.GetImplementation();
157
158   return static_cast<Toolkit::Internal::ConfirmationPopup&>( handle );
159 }
160
161 inline const Toolkit::Internal::ConfirmationPopup& GetDerivedImplementation( const Toolkit::ConfirmationPopup& popup )
162 {
163   DALI_ASSERT_ALWAYS( popup );
164
165   const Dali::RefObject& handle = popup.GetImplementation();
166
167   return static_cast<const Toolkit::Internal::ConfirmationPopup&>( handle );
168 }
169
170
171 } // namespace Toolkit
172
173 } // namespace Dali
174
175 #endif // __DALI_TOOLKIT_INTERNAL_CONFIRMATION_POPUP_H__