Dali 3D User Interface Engine
signal-delegate.h
Go to the documentation of this file.
1 #ifndef __DALI_SIGNAL_DELEGATE_H__
2 #define __DALI_SIGNAL_DELEGATE_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 // INTERNAL INCLUDES
24 
25 namespace Dali
26 {
27 
35 {
36 public:
37 
44  SignalDelegate( Dali::Actor connectActor, const std::string& signalName );
45 
50  {
51  }
52 
53 public:
54 
66  bool Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* functorDelegate )
67  {
68  if( !mCallbackFunctor )
69  {
70  // Note: We have to new the CallbackBaseFunctor rather than have it as a concrete object, as it
71  // is converted to a FunctorDelegate again within ConnectSignal. FunctorDelegates gain ownership
72  // of any functor they are created from and therefore always attempt to delete them.
73  mCallbackFunctor = new CallbackBaseFunctor( new CallbackFunctorDelegate0( functorDelegate ) );
74  mConnectActor.ConnectSignal( connectionTracker, mSignalName, *mCallbackFunctor );
75 
76  return true;
77  }
78 
79  return false;
80  }
81 
91  template< class T >
92  bool Connect( T* object, void ( T::*memberFunction )( void ) )
93  {
94  if( !mCallbackFunctor )
95  {
96  mCallbackFunctor = new CallbackBaseFunctor( MakeCallback( object, memberFunction ) );
97  mConnectActor.ConnectSignal( object, mSignalName, *mCallbackFunctor );
98 
99  return true;
100  }
101 
102  return false;
103  }
104 
111  bool IsConnected();
112 
113 
114 private:
115 
123  {
129  CallbackBaseFunctor( CallbackBase* callback );
130 
134  void operator()();
135 
143 
144  private:
145 
147  };
148 
149 private:
150 
154  SignalDelegate( const SignalDelegate& rhs );
155 
159  const SignalDelegate& operator=( const SignalDelegate& rhs );
160 
161 private:
162 
165  std::string mSignalName;
166 
167 };
168 
169 } // namespace Dali
170 
171 #endif // __DALI_SIGNAL_DELEGATE_H__
Dali Docs Home
Read more about Dali