{
struct MyTestCustomActor : public CustomActorImpl
{
- typedef SignalV2< void ()> SignalType;
- typedef SignalV2< void (float)> SignalTypeFloat;
+ typedef Signal< void ()> SignalType;
+ typedef Signal< void (float)> SignalTypeFloat;
MyTestCustomActor() : CustomActorImpl( true ) // requires touch
{ }
{
public:
- typedef SignalV2< void ()> SignalType;
- typedef SignalV2< void (float)> SignalTypeFloat;
+ typedef Signal< void ()> SignalType;
+ typedef Signal< void (float)> SignalTypeFloat;
MyTestCustomActor()
{
utc-Dali-RenderableActor.cpp
utc-Dali-ShaderEffect.cpp
utc-Dali-SignalTemplatesFunctors.cpp
- utc-Dali-SignalTemplatesV2.cpp
+ utc-Dali-SignalTemplates.cpp
utc-Dali-Stage.cpp
utc-Dali-TapGesture.cpp
utc-Dali-TapGestureDetector.cpp
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <iostream>
+#include <stdlib.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+void utc_dali_signal_templates_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_signal_templates_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+namespace {
+
+class TestButton
+{
+public:
+
+ TestButton( unsigned int id )
+ : mId(id)
+ {
+ }
+
+ void Press()
+ {
+ mPanelDown.Emit( *this );
+ }
+
+ void Release()
+ {
+ mPanelUp.Emit( *this );
+ }
+
+ typedef Signal< void (TestButton&) > PanelDownSignal;
+ typedef Signal< void (TestButton&) > PanelUpSignal;
+
+ PanelDownSignal& DownSignal()
+ {
+ return mPanelDown;
+ }
+
+ PanelUpSignal& SignalUp()
+ {
+ return mPanelUp;
+ }
+
+ int GetId()
+ {
+ return mId;
+ }
+
+private:
+
+ int mId;
+ PanelDownSignal mPanelDown;
+ PanelUpSignal mPanelUp;
+};
+
+class TestApp : public ConnectionTracker
+{
+public:
+
+ TestApp()
+ : mButtonPressed( false ),
+ mVoidFunctionCalled( false )
+ {
+ }
+
+ void OnButtonPress( TestButton& button )
+ {
+ mButtonPressed = true;
+ mButtonId = button.GetId();
+ }
+
+ void OnButtonRelease( TestButton& button )
+ {
+ mButtonPressed = false;
+ mButtonId = button.GetId();
+ }
+
+ int GetButtonPressedId()
+ {
+ return mButtonId;
+ }
+
+ bool BoolReturnTestFalse()
+ {
+ return false;
+ }
+
+ bool BoolReturnTestTrue()
+ {
+ return true;
+ }
+
+ void VoidFunction()
+ {
+ mVoidFunctionCalled = true;
+ }
+
+ bool mButtonPressed;
+ bool mVoidFunctionCalled;
+ int mButtonId;
+};
+
+class TestSignals
+{
+public:
+
+ // Void return, no parameters
+ typedef Signal<void ()> VoidRetNoParamSignal;
+
+ // Void return, 1 value parameter
+ typedef Signal<void (int)> VoidRet1ValueParamSignal;
+
+ // Void return, 1 reference parameter
+ typedef Signal< void (int&)> VoidRet1RefParamSignal;
+
+ // Void return, 2 value parameters
+ typedef Signal<void (int, int)> VoidRet2ValueParamSignal;
+
+ // bool return, 1 value parameter
+ typedef Signal< bool (float)> BoolRet1ValueParamSignal;
+
+ // bool return, 2 value parameter
+ typedef Signal<bool (float, int) > BoolRet2ValueParamSignal;
+
+ // int return, 2 value parameter
+ typedef Signal<int (float, int)> IntRet2ValueParamSignal;
+
+ // float return, 0 parameters
+ typedef Signal< float () > FloatRet0ParamSignal;
+
+ // float return, 2 value parameters
+ typedef Signal<float (float, float) > FloatRet2ValueParamSignal;
+
+ // void return, 3 value parameters
+ typedef Signal<void (float, float, float) > VoidSignalTypeFloatValue3;
+
+ // float return, 3 value parameters
+ typedef Signal<float (float, float, float) > FloatSignalTypeFloatValue3;
+
+ VoidRetNoParamSignal& SignalVoidNone() { return mSignalVoid0; }
+ VoidRet1RefParamSignal& SignalVoid1Ref() { return mSignalVoid1R; }
+ VoidRet1ValueParamSignal& SignalVoid1Value() { return mSignalVoid1V; }
+ VoidRet2ValueParamSignal& SignalVoid2Value() { return mSignalVoid2V; }
+
+ BoolRet1ValueParamSignal& SignalBool1Value() { return mSignalBool1V; }
+ BoolRet2ValueParamSignal& SignalBool2Value() { return mSignalBool2V; }
+ IntRet2ValueParamSignal& SignalInt2Value() { return mSignalInt2V; }
+ FloatRet0ParamSignal& SignalFloat0() { return mSignalFloat0; }
+ FloatRet2ValueParamSignal& SignalFloat2Value() { return mSignalFloat2V; }
+
+ VoidSignalTypeFloatValue3& VoidSignalFloatValue3() { return mVoidSignalFloatValue3; }
+ FloatSignalTypeFloatValue3& FloatSignalFloatValue3() { return mFloatSignalFloatValue3; }
+
+ TestSignals()
+ {
+ }
+
+ void CheckNoConnections()
+ {
+ DALI_TEST_EQUALS( mSignalVoid0.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( mSignalVoid1R.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( mSignalVoid1V.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( mSignalVoid2V.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( mSignalBool1V.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( mSignalBool2V.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( mSignalInt2V.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( mSignalFloat0.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( mSignalFloat2V.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( mVoidSignalFloatValue3.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( mFloatSignalFloatValue3.GetConnectionCount(), 0u, TEST_LOCATION );
+ }
+
+ void EmitVoidSignalVoid()
+ {
+ mSignalVoid0.Emit();
+ }
+
+ void EmitVoidSignalIntRef(int& ref)
+ {
+ mSignalVoid1R.Emit(ref);
+ }
+
+ void EmitVoidSignalIntValue(int p1)
+ {
+ mSignalVoid1V.Emit(p1);
+ }
+
+ void EmitVoidSignalIntValueIntValue(int p1, int p2)
+ {
+ mSignalVoid2V.Emit(p1,p2);
+ }
+
+ bool EmitBoolSignalFloatValue(float p1)
+ {
+ return mSignalBool1V.Emit(p1);
+ }
+
+ bool EmitBoolSignalFloatValueIntValue(float p1, int p2)
+ {
+ return mSignalBool2V.Emit(p1, p2);
+ }
+
+ int EmitIntSignalFloatValueIntValue(float p1, int p2)
+ {
+ return mSignalInt2V.Emit(p1, p2);
+ }
+
+ float EmitFloat2VSignal(float p1, float p2)
+ {
+ return mSignalFloat2V.Emit(p1, p2);
+ }
+
+ float EmitFloat0Signal()
+ {
+ return mSignalFloat0.Emit();
+ }
+
+ void EmitVoidSignalFloatValue3(float p1, float p2, float p3)
+ {
+ mVoidSignalFloatValue3.Emit(p1, p2, p3);
+ }
+
+ float EmitFloatSignalFloatValue3(float p1, float p2, float p3)
+ {
+ return mFloatSignalFloatValue3.Emit(p1, p2, p3);
+ }
+
+private:
+
+ VoidRetNoParamSignal mSignalVoid0;
+ VoidRet1RefParamSignal mSignalVoid1R;
+ VoidRet1ValueParamSignal mSignalVoid1V;
+ VoidRet2ValueParamSignal mSignalVoid2V;
+ BoolRet1ValueParamSignal mSignalBool1V;
+ BoolRet2ValueParamSignal mSignalBool2V;
+ IntRet2ValueParamSignal mSignalInt2V;
+ FloatRet0ParamSignal mSignalFloat0;
+ FloatRet2ValueParamSignal mSignalFloat2V;
+ VoidSignalTypeFloatValue3 mVoidSignalFloatValue3;
+ FloatSignalTypeFloatValue3 mFloatSignalFloatValue3;
+};
+
+/**
+ * A helper class with various slots
+ */
+class TestSlotHandler : public ConnectionTracker
+{
+public:
+
+ TestSlotHandler()
+ : mIntParam1( 0 ),
+ mIntParam2( 0 ),
+ mIntParam3( 0 ),
+ mFloatParam1( 0.0f ),
+ mFloatParam2( 0.0f ),
+ mFloatParam3( 0.0f ),
+ mBoolReturn( false ),
+ mIntReturn( 0 ),
+ mFloatReturn( 0.0f ),
+ mHandled( false ),
+ mHandledCount( 0 )
+ {
+ }
+
+ void Reset()
+ {
+ mIntParam1 = 0;
+ mIntParam2 = 0;
+ mIntParam3 = 0;
+ mFloatParam1 = 0.0f;
+ mFloatParam2 = 0.0f;
+ mFloatParam3 = 0.0f;
+ mBoolReturn = false;
+ mIntReturn = 0;
+ mFloatReturn = 0.0f;
+ mHandled = false;
+ }
+
+ void VoidSlotVoid()
+ {
+ mHandled = true;
+ ++mHandledCount;
+ }
+
+ void VoidSlotIntRef( int& p1 )
+ {
+ mIntParam1 = p1;
+ mHandled = true;
+ ++mHandledCount;
+ }
+
+ void VoidSlotIntValue( int p1 )
+ {
+ mIntParam1 = p1;
+ mHandled = true;
+ ++mHandledCount;
+ }
+
+ void VoidDuplicateSlotIntValue( int p1 )
+ {
+ mIntParam2 = p1;
+ mHandled = true;
+ ++mHandledCount;
+ }
+
+ void VoidSlotIntValueIntValue( int p1, int p2 )
+ {
+ mIntParam1 = p1;
+ mIntParam2 = p2;
+ mHandled = true;
+ ++mHandledCount;
+ }
+
+ bool BoolSlotFloatValue( float p1 )
+ {
+ mFloatParam1 = p1;
+ mHandled = true;
+ ++mHandledCount;
+ return mBoolReturn;
+ }
+
+ bool BoolSlotFloatValueIntValue( float p1, int p2 )
+ {
+ mFloatParam1 = p1;
+ mIntParam2 = p2;
+ mHandled = true;
+ ++mHandledCount;
+ return mBoolReturn;
+ }
+
+ int IntSlotFloatValueIntValue( float p1, int p2 )
+ {
+ mFloatParam1 = p1;
+ mIntParam2 = p2;
+ mHandled = true;
+ ++mHandledCount;
+ return mIntReturn;
+ }
+
+ float FloatSlotVoid()
+ {
+ mHandled = true;
+ ++mHandledCount;
+ return mFloatReturn;
+ }
+
+ float FloatSlotFloatValueFloatValue( float p1, float p2 )
+ {
+ mFloatParam1 = p1;
+ mFloatParam2 = p2;
+ mHandled = true;
+ ++mHandledCount;
+ return mFloatReturn;
+ }
+
+ void VoidSlotFloatValue3( float p1, float p2, float p3 )
+ {
+ mFloatParam1 = p1;
+ mFloatParam2 = p2;
+ mFloatParam3 = p3;
+ mHandled = true;
+ ++mHandledCount;
+ }
+
+ float FloatSlotFloatValue3( float p1, float p2, float p3 )
+ {
+ mFloatParam1 = p1;
+ mFloatParam2 = p2;
+ mFloatParam3 = p3;
+ mHandled = true;
+ ++mHandledCount;
+ return mFloatReturn;
+ }
+
+ int mIntParam1, mIntParam2, mIntParam3;
+ float mFloatParam1, mFloatParam2, mFloatParam3;
+ bool mBoolReturn;
+ int mIntReturn;
+ float mFloatReturn;
+ bool mHandled;
+ int mHandledCount;
+};
+
+/**
+ * A version of TestSlotHandler which disconnects during the callback
+ */
+class TestSlotDisconnector : public ConnectionTracker
+{
+public:
+
+ TestSlotDisconnector()
+ : mIntParam1( 0 ),
+ mIntParam2( 0 ),
+ mIntParam3( 0 ),
+ mFloatParam1( 0.0f ),
+ mFloatParam2( 0.0f ),
+ mBoolReturn( false ),
+ mIntReturn( 0 ),
+ mFloatReturn( 0.0f ),
+ mHandled( false )
+ {
+ }
+
+ void Reset()
+ {
+ mIntParam1 = 0;
+ mIntParam2 = 0;
+ mIntParam3 = 0;
+ mFloatParam1 = 0.0f;
+ mFloatParam2 = 0.0f;
+ mBoolReturn = false;
+ mIntReturn = 0;
+ mFloatReturn = 0.0f;
+ mHandled = false;
+ }
+
+ void VoidConnectVoid( TestSignals::VoidRetNoParamSignal& signal )
+ {
+ mVoidSignalVoid = &signal;
+ signal.Connect( this, &TestSlotDisconnector::VoidSlotVoid );
+ }
+
+ void VoidSlotVoid()
+ {
+ mVoidSignalVoid->Disconnect( this, &TestSlotDisconnector::VoidSlotVoid );
+ mHandled = true;
+ }
+
+ void VoidConnectIntRef( TestSignals::VoidRet1RefParamSignal& signal )
+ {
+ mVoidSignalIntRef = &signal;
+ signal.Connect( this, &TestSlotDisconnector::VoidSlotIntRef );
+ }
+
+ void VoidSlotIntRef( int& p1 )
+ {
+ mVoidSignalIntRef->Disconnect( this, &TestSlotDisconnector::VoidSlotIntRef );
+ mIntParam1 = p1;
+ mHandled = true;
+ }
+
+ void VoidSlotIntValue( int p1 )
+ {
+ mIntParam1 = p1;
+ mHandled = true;
+ }
+
+ void VoidSlotIntValueIntValue( int p1, int p2 )
+ {
+ mIntParam1 = p1;
+ mIntParam2 = p2;
+ mHandled = true;
+ }
+
+ bool BoolSlotFloatValue( float p1 )
+ {
+ mFloatParam1 = p1;
+ mHandled = true;
+ return mBoolReturn;
+ }
+
+ bool BoolSlotFloatValueIntValue( float p1, int p2 )
+ {
+ mFloatParam1 = p1;
+ mIntParam2 = p2;
+ mHandled = true;
+ return mBoolReturn;
+ }
+
+ int IntSlotFloatValueIntValue( float p1, int p2 )
+ {
+ mFloatParam1 = p1;
+ mIntParam2 = p2;
+ mHandled = true;
+ return mIntReturn;
+ }
+
+ float FloatSlotVoid()
+ {
+ mHandled = true;
+ return mFloatReturn;
+ }
+
+ float FloatSlotFloatValueFloatValue( float p1, float p2 )
+ {
+ mFloatParam1 = p1;
+ mFloatParam2 = p2;
+ mHandled = true;
+ return mFloatReturn;
+ }
+
+ TestSignals::VoidRetNoParamSignal* mVoidSignalVoid;
+ TestSignals::VoidRet1RefParamSignal* mVoidSignalIntRef;
+
+ int mIntParam1, mIntParam2, mIntParam3;
+ float mFloatParam1, mFloatParam2;
+ bool mBoolReturn;
+ int mIntReturn;
+ float mFloatReturn;
+ bool mHandled;
+};
+
+/**
+ * A more complicated version of TestSlotDisconnector, which disconnects some but not all callbacks
+ */
+class TestSlotMultiDisconnector : public ConnectionTracker
+{
+public:
+
+ static const int NUM_SLOTS = 10;
+
+ TestSlotMultiDisconnector()
+ : mVoidSignalVoid( NULL )
+ {
+ Reset();
+ }
+
+ void Reset()
+ {
+ for( int i=0; i<NUM_SLOTS; ++i )
+ {
+ mSlotHandled[i] = false;
+ }
+ }
+
+ void ConnectAll( TestSignals::VoidRetNoParamSignal& signal )
+ {
+ mVoidSignalVoid = &signal;
+ signal.Connect( this, &TestSlotMultiDisconnector::Slot0 );
+ signal.Connect( this, &TestSlotMultiDisconnector::Slot1 );
+ signal.Connect( this, &TestSlotMultiDisconnector::Slot2 );
+ signal.Connect( this, &TestSlotMultiDisconnector::Slot3 );
+ signal.Connect( this, &TestSlotMultiDisconnector::Slot4 );
+ signal.Connect( this, &TestSlotMultiDisconnector::Slot5 );
+ signal.Connect( this, &TestSlotMultiDisconnector::Slot6 );
+ signal.Connect( this, &TestSlotMultiDisconnector::Slot7 );
+ signal.Connect( this, &TestSlotMultiDisconnector::Slot8 );
+ signal.Connect( this, &TestSlotMultiDisconnector::Slot9 );
+ }
+
+ void Slot0()
+ {
+ mSlotHandled[0] = true;
+ }
+
+ void Slot1()
+ {
+ mSlotHandled[1] = true;
+ }
+
+ void Slot2()
+ {
+ mSlotHandled[2] = true;
+ }
+
+ void Slot3()
+ {
+ mSlotHandled[3] = true;
+
+ // Disconnect the odd numbered lots, because we can
+ mVoidSignalVoid->Disconnect( this, &TestSlotMultiDisconnector::Slot1 );
+ mVoidSignalVoid->Disconnect( this, &TestSlotMultiDisconnector::Slot3 );
+ mVoidSignalVoid->Disconnect( this, &TestSlotMultiDisconnector::Slot5 );
+ mVoidSignalVoid->Disconnect( this, &TestSlotMultiDisconnector::Slot7 );
+ mVoidSignalVoid->Disconnect( this, &TestSlotMultiDisconnector::Slot9 );
+ }
+
+ void Slot4()
+ {
+ mSlotHandled[4] = true;
+ }
+
+ void Slot5()
+ {
+ mSlotHandled[5] = true;
+ }
+
+ void Slot6()
+ {
+ mSlotHandled[6] = true;
+ }
+
+ void Slot7()
+ {
+ mSlotHandled[7] = true;
+ }
+
+ void Slot8()
+ {
+ mSlotHandled[8] = true;
+ }
+
+ void Slot9()
+ {
+ mSlotHandled[9] = true;
+ }
+
+ TestSignals::VoidRetNoParamSignal* mVoidSignalVoid;
+
+ bool mSlotHandled[NUM_SLOTS];
+};
+
+
+/**
+ * A version of TestSlotHandler which disconnects during the callback
+ */
+class TestEmitDuringCallback : public ConnectionTracker
+{
+public:
+
+ TestEmitDuringCallback()
+ : mVoidSignalVoid( NULL ),
+ mHandled( false )
+ {
+ }
+
+ void VoidConnectVoid( TestSignals::VoidRetNoParamSignal& signal )
+ {
+ mVoidSignalVoid = &signal;
+ signal.Connect( this, &TestEmitDuringCallback::VoidSlotVoid );
+ }
+
+ void VoidSlotVoid()
+ {
+ // Emitting during Emit is very bad!
+ mVoidSignalVoid->Emit();
+
+ mHandled = true;
+ }
+
+ TestSignals::VoidRetNoParamSignal* mVoidSignalVoid;
+
+ bool mHandled;
+};
+
+
+/**
+ * A version of TestSlotHandler which uses SlotDelegate
+ */
+class TestSlotDelegateHandler // This does not inherit from ConnectionTrackerInterface!
+{
+public:
+
+ TestSlotDelegateHandler()
+ : mSlotDelegate( this ),
+ mIntParam1( 0 ),
+ mIntParam2( 0 ),
+ mIntParam3( 0 ),
+ mFloatParam1( 0.0f ),
+ mFloatParam2( 0.0f ),
+ mFloatParam3( 0.0f ),
+ mBoolReturn( false ),
+ mIntReturn( 0 ),
+ mFloatReturn( 0.0f ),
+ mHandled( false ),
+ mHandledCount( 0 )
+ {
+ }
+
+ void Reset()
+ {
+ mIntParam1 = 0;
+ mIntParam2 = 0;
+ mIntParam3 = 0;
+ mFloatParam1 = 0.0f;
+ mFloatParam2 = 0.0f;
+ mFloatParam3 = 0.0f;
+ mBoolReturn = false;
+ mIntReturn = 0;
+ mFloatReturn = 0.0f;
+ mHandled = false;
+ }
+
+ void VoidSlotVoid()
+ {
+ mHandled = true;
+ ++mHandledCount;
+ }
+
+ void VoidSlotIntRef( int& p1 )
+ {
+ mIntParam1 = p1;
+ mHandled = true;
+ ++mHandledCount;
+ }
+
+ void VoidSlotIntValue( int p1 )
+ {
+ mIntParam1 = p1;
+ mHandled = true;
+ ++mHandledCount;
+ }
+
+ void VoidDuplicateSlotIntValue( int p1 )
+ {
+ mIntParam2 = p1;
+ mHandled = true;
+ ++mHandledCount;
+ }
+
+ void VoidSlotIntValueIntValue( int p1, int p2 )
+ {
+ mIntParam1 = p1;
+ mIntParam2 = p2;
+ mHandled = true;
+ ++mHandledCount;
+ }
+
+ bool BoolSlotFloatValue( float p1 )
+ {
+ mFloatParam1 = p1;
+ mHandled = true;
+ ++mHandledCount;
+ return mBoolReturn;
+ }
+
+ bool BoolSlotFloatValueIntValue( float p1, int p2 )
+ {
+ mFloatParam1 = p1;
+ mIntParam2 = p2;
+ mHandled = true;
+ ++mHandledCount;
+ return mBoolReturn;
+ }
+
+ int IntSlotFloatValueIntValue( float p1, int p2 )
+ {
+ mFloatParam1 = p1;
+ mIntParam2 = p2;
+ mHandled = true;
+ ++mHandledCount;
+ return mIntReturn;
+ }
+
+ float FloatSlotVoid()
+ {
+ mHandled = true;
+ ++mHandledCount;
+ return mFloatReturn;
+ }
+
+ float FloatSlotFloatValueFloatValue( float p1, float p2 )
+ {
+ mFloatParam1 = p1;
+ mFloatParam2 = p2;
+ mHandled = true;
+ ++mHandledCount;
+ return mFloatReturn;
+ }
+
+ void VoidSlotFloatValue3( float p1, float p2, float p3 )
+ {
+ mFloatParam1 = p1;
+ mFloatParam2 = p2;
+ mFloatParam3 = p3;
+ mHandled = true;
+ ++mHandledCount;
+ }
+
+ float FloatSlotFloatValue3( float p1, float p2, float p3 )
+ {
+ mFloatParam1 = p1;
+ mFloatParam2 = p2;
+ mFloatParam3 = p3;
+ mHandled = true;
+ ++mHandledCount;
+ return mFloatReturn;
+ }
+
+ SlotDelegate<TestSlotDelegateHandler> mSlotDelegate;
+
+ int mIntParam1, mIntParam2, mIntParam3;
+ float mFloatParam1, mFloatParam2, mFloatParam3;
+ bool mBoolReturn;
+ int mIntReturn;
+ float mFloatReturn;
+ bool mHandled;
+ int mHandledCount;
+};
+
+/**
+ * Test that reimplmenting ConnectionTrackerInterface actually works.
+ * This basic connection tracker only allows one callback to be connected.
+ */
+class TestBasicConnectionTrackerInterface : public ConnectionTrackerInterface
+{
+public:
+
+ TestBasicConnectionTrackerInterface()
+ : mCallbackHandled( false ),
+ mCallback( NULL ),
+ mSlotObserver( NULL )
+ {
+ }
+
+ ~TestBasicConnectionTrackerInterface()
+ {
+ if( mSlotObserver && mCallback )
+ {
+ // Notify signal since the slot has been destroyed
+ mSlotObserver->SlotDisconnected( mCallback );
+ // mCallback and mSlotObserver are not owned
+ }
+ }
+
+ /**
+ * An example slot
+ */
+ void VoidSlotVoid()
+ {
+ mCallbackHandled = true;
+ }
+
+ /**
+ * @copydoc ConnectionTrackerInterface::GetConnectionCount
+ */
+ virtual std::size_t GetConnectionCount() const
+ {
+ if( mCallback )
+ {
+ return 1u;
+ }
+
+ return 0u;
+ }
+
+ /**
+ * @copydoc ConnectionTrackerInterface::SignalConnected
+ */
+ virtual void SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
+ {
+ DALI_ASSERT_ALWAYS( NULL == mCallback && "Only one connection supported!" );
+
+ mCallback = callback;
+ mSlotObserver = slotObserver;
+ }
+
+ /**
+ * @copydoc ConnectionTrackerInterface::SignalDisconnected
+ */
+ virtual void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
+ {
+ if( mSlotObserver == slotObserver )
+ {
+ mSlotObserver = NULL;
+ mCallback = NULL;
+ // mCallback and mSlotObserver are not owned
+ }
+ }
+
+private:
+
+ TestBasicConnectionTrackerInterface( const TestBasicConnectionTrackerInterface& ); ///< undefined copy constructor
+ TestBasicConnectionTrackerInterface& operator=( const TestBasicConnectionTrackerInterface& ); ///< undefined assignment operator
+
+public:
+
+ bool mCallbackHandled;
+
+private:
+
+ CallbackBase* mCallback; ///< callback, has ownership
+ SlotObserver* mSlotObserver; ///< a pointer to the slot observer (not owned)
+};
+
+
+bool wasStaticVoidCallbackVoidCalled = false;
+bool wasStaticFloatCallbackVoidCalled = false;
+bool wasStaticVoidCallbackIntValueCalled = false;
+int staticIntValue = 0;
+bool wasStaticFloatCallbackFloatValueFloatValueCalled = false;
+float staticFloatValue1 = 0.0f;
+float staticFloatValue2 = 0.0f;
+
+static void StaticVoidCallbackVoid()
+{
+ wasStaticVoidCallbackVoidCalled = true;
+}
+
+static float StaticFloatCallbackVoid()
+{
+ wasStaticFloatCallbackVoidCalled = true;
+ return 7.0f;
+}
+
+static void StaticVoidCallbackIntValue( int value )
+{
+ wasStaticVoidCallbackIntValueCalled = true;
+ staticIntValue = value;
+}
+
+static float StaticFloatCallbackFloatValueFloatValue( float value1, float value2 )
+{
+ wasStaticFloatCallbackFloatValueFloatValueCalled = true;
+ staticFloatValue1 = value1;
+ staticFloatValue2 = value2;
+ return value1 + value2;
+}
+
+} // anon namespace
+
+
+int UtcDaliSignalEmptyCheck(void)
+{
+ // Test that Empty() check works before & after signal connection
+
+ {
+ TestSignals::VoidRetNoParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::VoidSlotVoid );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+
+ {
+ TestSignals::VoidRet1ValueParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::VoidSlotIntValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+
+ {
+ TestSignals::VoidRet1RefParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::VoidSlotIntRef );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+
+ {
+ TestSignals::VoidRet2ValueParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::VoidSlotIntValueIntValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+
+ {
+ TestSignals::BoolRet1ValueParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::BoolSlotFloatValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+
+ {
+ TestSignals::BoolRet2ValueParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::BoolSlotFloatValueIntValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+
+ {
+ TestSignals::IntRet2ValueParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::IntSlotFloatValueIntValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+
+ {
+ TestSignals::FloatRet0ParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::FloatSlotVoid );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+
+ {
+ TestSignals::FloatRet2ValueParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect(&handler, &TestSlotHandler::FloatSlotFloatValueFloatValue);
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ END_TEST;
+}
+
+int UtcDaliSignalEmptyCheckSlotDestruction(void)
+{
+ // Test that signal disconnect works when slot is destroyed (goes out of scope)
+
+ {
+ TestSignals::VoidRetNoParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::VoidSlotVoid );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ signal.Emit();
+ }
+
+ {
+ TestSignals::VoidRet1ValueParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::VoidSlotIntValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ signal.Emit( 10 );
+ }
+
+ {
+ TestSignals::VoidRet1RefParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::VoidSlotIntRef );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ int temp( 5 );
+ signal.Emit( temp );
+ }
+
+ {
+ TestSignals::VoidRet2ValueParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::VoidSlotIntValueIntValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ signal.Emit( 1, 2 );
+ }
+
+ {
+ TestSignals::BoolRet1ValueParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::BoolSlotFloatValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ bool blah = signal.Emit( 1.0f );
+ DALI_TEST_CHECK( ! blah );
+ }
+
+ {
+ TestSignals::BoolRet2ValueParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::BoolSlotFloatValueIntValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ bool blah = signal.Emit( 1.0f, 2 );
+ DALI_TEST_CHECK( ! blah );
+ }
+
+ {
+ TestSignals::IntRet2ValueParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::IntSlotFloatValueIntValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ int blah = signal.Emit( 10.0f, 100 );
+ DALI_TEST_CHECK( 0 == blah );
+ }
+
+ {
+ TestSignals::FloatRet0ParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect( &handler, &TestSlotHandler::FloatSlotVoid );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ float blah = signal.Emit();
+ DALI_TEST_CHECK( 0.0f == blah );
+ }
+
+ {
+ TestSignals::FloatRet2ValueParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotHandler handler;
+ signal.Connect(&handler, &TestSlotHandler::FloatSlotFloatValueFloatValue);
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ float blah = signal.Emit( 3.0f, 4.0f );
+ DALI_TEST_CHECK( 0.0f == blah );
+ }
+ END_TEST;
+}
+
+// Positive test case for a method
+int UtcDaliSignalConnectAndEmit(void)
+{
+ // Test basic signal emission for each slot type
+
+ TestSignals signals;
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalVoidNone().Connect(&handlers, &TestSlotHandler::VoidSlotVoid);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ signals.EmitVoidSignalVoid();
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+
+ // Test double emission
+ handlers.mHandled = false;
+ signals.EmitVoidSignalVoid();
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalVoid1Ref().Connect(&handlers, &TestSlotHandler::VoidSlotIntRef);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ int x = 7;
+ signals.EmitVoidSignalIntRef(x);
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 7, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalVoid1Value().Connect(&handlers, &TestSlotHandler::VoidSlotIntValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ signals.EmitVoidSignalIntValue(5);
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 5, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalVoid2Value().Connect(&handlers, &TestSlotHandler::VoidSlotIntValueIntValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ signals.EmitVoidSignalIntValueIntValue(6, 7);
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 6, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam2, 7, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalBool1Value().Connect(&handlers, &TestSlotHandler::BoolSlotFloatValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+
+ handlers.mBoolReturn = true;
+ DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
+
+ // repeat with opposite return value
+ handlers.mBoolReturn = false;
+ handlers.mHandled = false;
+ DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(6.0f), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 6.0f, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalBool2Value().Connect(&handlers, &TestSlotHandler::BoolSlotFloatValueIntValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mBoolReturn = true;
+ DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam2, 10, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalInt2Value().Connect(&handlers, &TestSlotHandler::IntSlotFloatValueIntValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mIntReturn = 27;
+ int x = signals.EmitIntSignalFloatValueIntValue(33.5f, 5);
+ DALI_TEST_EQUALS( x, 27, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 33.5f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam2, 5, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalFloat0().Connect(&handlers, &TestSlotHandler::FloatSlotVoid);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mFloatReturn = 27.0f;
+ float f = signals.EmitFloat0Signal();
+ DALI_TEST_EQUALS( f, 27.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalFloat2Value().Connect(&handlers, &TestSlotHandler::FloatSlotFloatValueFloatValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mFloatReturn = 27.0f;
+ float f = signals.EmitFloat2VSignal(5, 33.0f);
+ DALI_TEST_EQUALS( f, 27.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotHandler handlers;
+ signals.VoidSignalFloatValue3().Connect(&handlers, &TestSlotHandler::VoidSlotFloatValue3);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ signals.EmitVoidSignalFloatValue3(5, 33.0f, 100.0f);
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam3, 100.0f, 0.001f, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotHandler handlers;
+ signals.FloatSignalFloatValue3().Connect(&handlers, &TestSlotHandler::FloatSlotFloatValue3);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mFloatReturn = 27.0f;
+ float returnValue = signals.EmitFloatSignalFloatValue3(5, 33.0f, 100.0f);
+ DALI_TEST_EQUALS( returnValue, 27.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam3, 100.0f, 0.001f, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+ END_TEST;
+}
+
+int UtcDaliSignalDisconnect(void)
+{
+ // Test that callbacks don't occur if a signal is disconnected before emission
+
+ TestSignals signals;
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalVoidNone().Connect(&handlers, &TestSlotHandler::VoidSlotVoid);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ signals.SignalVoidNone().Disconnect(&handlers, &TestSlotHandler::VoidSlotVoid);
+ signals.EmitVoidSignalVoid();
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalVoid1Ref().Connect(&handlers, &TestSlotHandler::VoidSlotIntRef);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ int r = 7;
+ handlers.mIntReturn = 5;
+ signals.SignalVoid1Ref().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntRef);
+ signals.EmitVoidSignalIntRef(r);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( r, 7, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalVoid1Value().Connect(&handlers, &TestSlotHandler::VoidSlotIntValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ signals.SignalVoid1Value().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntValue);
+ signals.EmitVoidSignalIntValue(5);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalVoid2Value().Connect(&handlers, &TestSlotHandler::VoidSlotIntValueIntValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ signals.SignalVoid2Value().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntValueIntValue);
+ signals.EmitVoidSignalIntValueIntValue(5, 10);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalBool1Value().Connect(&handlers, &TestSlotHandler::BoolSlotFloatValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mBoolReturn = true;
+ signals.SignalBool1Value().Disconnect(&handlers, &TestSlotHandler::BoolSlotFloatValue);
+ DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalBool2Value().Connect(&handlers, &TestSlotHandler::BoolSlotFloatValueIntValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mBoolReturn = true;
+ signals.SignalBool2Value().Disconnect(&handlers, &TestSlotHandler::BoolSlotFloatValueIntValue);
+ DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalInt2Value().Connect(&handlers, &TestSlotHandler::IntSlotFloatValueIntValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mIntReturn = 27;
+ signals.SignalInt2Value().Disconnect(&handlers, &TestSlotHandler::IntSlotFloatValueIntValue);
+ signals.EmitIntSignalFloatValueIntValue(5, 33.0f);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalFloat0().Connect(&handlers, &TestSlotHandler::FloatSlotVoid);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mFloatReturn = 27.0f;
+ signals.SignalFloat0().Disconnect(&handlers, &TestSlotHandler::FloatSlotVoid);
+ signals.EmitFloat0Signal();
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalFloat2Value().Connect(&handlers, &TestSlotHandler::FloatSlotFloatValueFloatValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mFloatReturn = 27.0f;
+ signals.SignalFloat2Value().Disconnect(&handlers, &TestSlotHandler::FloatSlotFloatValueFloatValue);
+ signals.EmitFloat2VSignal(5, 33.0f);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliSignalDisconnect2(void)
+{
+ // Test that nothing happens when attempting to disconnect an unconnected slot
+
+ TestSignals signals;
+ {
+ TestSlotHandler handlers;
+ signals.SignalVoidNone().Disconnect(&handlers, &TestSlotHandler::VoidSlotVoid);
+ signals.EmitVoidSignalVoid();
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ int r = 7;
+ signals.SignalVoid1Ref().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntRef);
+ signals.EmitVoidSignalIntRef(r);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( r, 7, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalVoid1Value().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntValue);
+ signals.EmitVoidSignalIntValue(5);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalVoid2Value().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntValueIntValue);
+ signals.EmitVoidSignalIntValueIntValue(5, 10);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ handlers.mBoolReturn = true;
+ signals.SignalBool1Value().Disconnect(&handlers, &TestSlotHandler::BoolSlotFloatValue);
+ DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ handlers.mBoolReturn = true;
+ signals.SignalBool2Value().Disconnect(&handlers, &TestSlotHandler::BoolSlotFloatValueIntValue);
+ DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ handlers.mIntReturn = 27;
+ signals.SignalInt2Value().Disconnect(&handlers, &TestSlotHandler::IntSlotFloatValueIntValue);
+ signals.EmitIntSignalFloatValueIntValue(5, 33.0f);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ handlers.mFloatReturn = 27.0f;
+ signals.SignalFloat2Value().Disconnect(&handlers, &TestSlotHandler::FloatSlotFloatValueFloatValue);
+ signals.EmitFloat2VSignal(5, 33.0f);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ handlers.mFloatReturn = 27.0f;
+ signals.SignalFloat0().Disconnect(&handlers, &TestSlotHandler::FloatSlotVoid);
+ signals.EmitFloat0Signal();
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliSignalDisconnect3(void)
+{
+ // Test that callbacks stop after a signal is disconnected
+
+ TestSignals signals;
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalVoidNone().Connect(&handlers, &TestSlotHandler::VoidSlotVoid);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+
+ // Emit first
+ signals.EmitVoidSignalVoid();
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+
+ // Disconnect and emit again
+ handlers.mHandled = false;
+ signals.SignalVoidNone().Disconnect(&handlers, &TestSlotHandler::VoidSlotVoid);
+ signals.EmitVoidSignalVoid();
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handlers;
+ signals.SignalVoid1Ref().Connect(&handlers, &TestSlotHandler::VoidSlotIntRef);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ int r = 7;
+
+ // Emit first
+ signals.EmitVoidSignalIntRef(r);
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 7, TEST_LOCATION );
+
+ // Disconnect and emit again
+ handlers.mHandled = false;
+ handlers.mIntParam1 = 0;
+ signals.SignalVoid1Ref().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntRef);
+ signals.EmitVoidSignalIntRef(r);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( r, 7, TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliSignalCustomConnectionTracker(void)
+{
+ // Test slot destruction
+ {
+ TestSignals::VoidRetNoParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestBasicConnectionTrackerInterface customTracker;
+ signal.Connect( &customTracker, &TestBasicConnectionTrackerInterface::VoidSlotVoid );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ signal.Emit();
+ }
+
+ TestBasicConnectionTrackerInterface customTracker2;
+
+ // Test signal emission & destruction
+ {
+ TestSignals::VoidRetNoParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+ DALI_TEST_EQUALS( 0u, customTracker2.GetConnectionCount(), TEST_LOCATION );
+
+ signal.Connect( &customTracker2, &TestBasicConnectionTrackerInterface::VoidSlotVoid );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ DALI_TEST_EQUALS( 1u, customTracker2.GetConnectionCount(), TEST_LOCATION );
+
+ DALI_TEST_EQUALS( customTracker2.mCallbackHandled, false, TEST_LOCATION );
+ signal.Emit();
+ DALI_TEST_EQUALS( customTracker2.mCallbackHandled, true, TEST_LOCATION );
+ }
+ DALI_TEST_EQUALS( 0u, customTracker2.GetConnectionCount(), TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliSignalMultipleConnections(void)
+{
+ // Test that multiple callbacks can be connected to the same signal
+
+ TestSignals signals;
+
+ {
+ TestSlotHandler handler1;
+ signals.SignalVoidNone().Connect( &handler1, &TestSlotHandler::VoidSlotVoid );
+ DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
+
+ TestSlotHandler handler2;
+ signals.SignalVoidNone().Connect( &handler2, &TestSlotHandler::VoidSlotVoid );
+ DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
+
+ signals.EmitVoidSignalVoid();
+ DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION );
+
+ // Remove first connection and repeat
+ handler1.Reset();
+ handler2.Reset();
+ signals.SignalVoidNone().Disconnect( &handler1, &TestSlotHandler::VoidSlotVoid );
+
+ signals.EmitVoidSignalVoid();
+ DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handler1;
+ signals.SignalVoid1Ref().Connect( &handler1, &TestSlotHandler::VoidSlotIntRef );
+ DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
+
+ TestSlotHandler handler2;
+ signals.SignalVoid1Ref().Connect( &handler2, &TestSlotHandler::VoidSlotIntRef );
+ DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
+
+ int x = 7;
+ signals.EmitVoidSignalIntRef(x);
+ DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler1.mIntParam1, 7, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mIntParam1, 7, TEST_LOCATION );
+
+ // Remove second connection and repeat
+ handler1.Reset();
+ handler2.Reset();
+ x = 8;
+ signals.SignalVoid1Ref().Disconnect( &handler2, &TestSlotHandler::VoidSlotIntRef );
+
+ signals.EmitVoidSignalIntRef(x);
+ DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler1.mIntParam1, 8, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mIntParam1, 0, TEST_LOCATION );
+ }
+
+ {
+ TestSlotHandler handler1;
+ signals.SignalVoid1Value().Connect( &handler1, &TestSlotHandler::VoidSlotIntValue );
+ DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
+
+ TestSlotHandler handler2;
+ signals.SignalVoid1Value().Connect( &handler2, &TestSlotHandler::VoidSlotIntValue );
+ DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
+
+ TestSlotHandler handler3;
+ signals.SignalVoid1Value().Connect( &handler3, &TestSlotHandler::VoidSlotIntValue );
+ DALI_TEST_EQUALS( handler3.mHandled, false, TEST_LOCATION );
+
+ signals.EmitVoidSignalIntValue( 5 );
+ DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler1.mIntParam1, 5, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mIntParam1, 5, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler3.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler3.mIntParam1, 5, TEST_LOCATION );
+
+ // Remove middle connection and repeat
+ handler1.Reset();
+ handler2.Reset();
+ handler3.Reset();
+ signals.SignalVoid1Value().Disconnect( &handler2, &TestSlotHandler::VoidSlotIntValue );
+
+ signals.EmitVoidSignalIntValue( 6 );
+ DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler1.mIntParam1, 6, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mIntParam1, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler3.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler3.mIntParam1, 6, TEST_LOCATION );
+ }
+
+ // Test that multiple callbacks are disconnected when a signal is destroyed
+
+ TestSlotHandler handler4;
+ TestSlotHandler handler5;
+ TestSlotHandler handler6;
+
+ {
+ TestSignals::VoidRet1ValueParamSignal tempSignal;
+
+ DALI_TEST_EQUALS( handler4.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler5.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler6.GetConnectionCount(), 0u, TEST_LOCATION );
+
+ tempSignal.Connect( &handler4, &TestSlotHandler::VoidSlotIntValue );
+ tempSignal.Connect( &handler5, &TestSlotHandler::VoidSlotIntValue );
+ tempSignal.Connect( &handler6, &TestSlotHandler::VoidSlotIntValue );
+
+ DALI_TEST_EQUALS( handler4.GetConnectionCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler5.GetConnectionCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler6.GetConnectionCount(), 1u, TEST_LOCATION );
+ }
+ // End of tempSignal lifetime
+
+ DALI_TEST_EQUALS( handler4.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler5.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler6.GetConnectionCount(), 0u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliSignalMultipleConnections2(void)
+{
+ TestSignals signals;
+
+ // Test that connecting the same callback twice is a NOOP
+ {
+ TestSlotHandler handler1;
+
+ // Note the double connection is intentional
+ signals.SignalVoid1Value().Connect( &handler1, &TestSlotHandler::VoidSlotIntValue );
+ signals.SignalVoid1Value().Connect( &handler1, &TestSlotHandler::VoidSlotIntValue );
+ DALI_TEST_EQUALS( handler1.mHandledCount, 0, TEST_LOCATION );
+
+ signals.EmitVoidSignalIntValue( 6 );
+ DALI_TEST_EQUALS( handler1.mHandledCount, 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler1.mIntParam1, 6, TEST_LOCATION );
+
+ // Calling Disconnect once should be enough
+ signals.SignalVoid1Value().Disconnect( &handler1, &TestSlotHandler::VoidSlotIntValue );
+ DALI_TEST_CHECK( signals.SignalVoid1Value().Empty() );
+ handler1.mIntParam1 = 0;
+
+ signals.EmitVoidSignalIntValue( 7 );
+ DALI_TEST_EQUALS( handler1.mHandledCount, 1/*not incremented since last check*/, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler1.mIntParam1, 0, TEST_LOCATION );
+ }
+
+ // Test automatic disconnect after multiple Connect() calls
+ {
+ TestSlotHandler handler2;
+ signals.SignalVoid1Value().Connect( &handler2, &TestSlotHandler::VoidSlotIntValue );
+ signals.SignalVoid1Value().Connect( &handler2, &TestSlotHandler::VoidSlotIntValue );
+
+ TestSlotHandler handler3;
+ signals.SignalBool1Value().Connect( &handler3, &TestSlotHandler::BoolSlotFloatValue );
+ signals.SignalBool1Value().Connect( &handler3, &TestSlotHandler::BoolSlotFloatValue );
+
+ DALI_TEST_EQUALS( handler2.mHandledCount, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler3.mHandledCount, 0, TEST_LOCATION );
+ DALI_TEST_CHECK( ! signals.SignalVoid1Value().Empty() );
+ DALI_TEST_CHECK( ! signals.SignalBool1Value().Empty() );
+ }
+ DALI_TEST_CHECK( signals.SignalVoid1Value().Empty() );
+ DALI_TEST_CHECK( signals.SignalBool1Value().Empty() );
+
+ // Should be NOOP
+ signals.EmitVoidSignalIntValue( 1 );
+ signals.EmitBoolSignalFloatValue( 1.0f );
+
+ // Test that connecting the same callback 10 times is a NOOP
+ TestSlotHandler handler4;
+ DALI_TEST_EQUALS( handler4.mHandledCount, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler4.mFloatParam1, 0.0f, TEST_LOCATION );
+
+ signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
+ signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
+ signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
+ signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
+ signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
+ signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
+ signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
+ signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
+ signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
+ signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
+
+ signals.EmitBoolSignalFloatValue( 2.0f );
+ DALI_TEST_EQUALS( handler4.mHandledCount, 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler4.mFloatParam1, 2.0f, TEST_LOCATION );
+
+ // Calling Disconnect once should be enough
+ signals.SignalBool1Value().Disconnect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
+ DALI_TEST_CHECK( signals.SignalBool1Value().Empty() );
+
+ signals.EmitBoolSignalFloatValue( 3.0f );
+ DALI_TEST_EQUALS( handler4.mHandledCount, 1/*not incremented since last check*/, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler4.mFloatParam1, 2.0f, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliSignalMultipleConnections3(void)
+{
+ TestSignals signals;
+
+ // Test connecting two difference callbacks for the same ConnectionTracker
+
+ TestSlotHandler handler1;
+
+ {
+ TestSignals::VoidRet1ValueParamSignal tempSignal;
+
+ DALI_TEST_EQUALS( handler1.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler1.mHandledCount, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler1.mIntParam1, 0, TEST_LOCATION );
+
+ // Note that the duplicate connection is deliberate
+ tempSignal.Connect( &handler1, &TestSlotHandler::VoidSlotIntValue );
+ tempSignal.Connect( &handler1, &TestSlotHandler::VoidDuplicateSlotIntValue );
+
+ DALI_TEST_EQUALS( handler1.GetConnectionCount(), 2u, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler1.mHandledCount, 0, TEST_LOCATION );
+
+ tempSignal.Emit( 10 );
+
+ DALI_TEST_EQUALS( handler1.mHandledCount, 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler1.mIntParam1, 10, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler1.mIntParam2, 10, TEST_LOCATION );
+ }
+ // End of tempSignal lifetime
+
+ DALI_TEST_EQUALS( handler1.GetConnectionCount(), 0u, TEST_LOCATION );
+ END_TEST;
+}
+
+
+int UtcDaliSignalDisconnectStatic(void)
+{
+ // void Func()
+
+ {
+ TestSignals::VoidRetNoParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+
+ signal.Connect( StaticVoidCallbackVoid );
+ DALI_TEST_CHECK( ! signal.Empty() );
+
+ wasStaticVoidCallbackVoidCalled = false;
+ signal.Emit();
+ DALI_TEST_EQUALS( wasStaticVoidCallbackVoidCalled, true, TEST_LOCATION );
+
+ signal.Disconnect( StaticVoidCallbackVoid );
+ DALI_TEST_CHECK( signal.Empty() );
+
+ wasStaticVoidCallbackVoidCalled = false;
+ signal.Emit();
+ DALI_TEST_EQUALS( wasStaticVoidCallbackVoidCalled, false, TEST_LOCATION );
+ }
+
+ // float Func()
+
+ {
+ TestSignals::FloatRet0ParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+
+ signal.Connect( StaticFloatCallbackVoid );
+ DALI_TEST_CHECK( ! signal.Empty() );
+
+ wasStaticFloatCallbackVoidCalled = false;
+ float result = signal.Emit();
+ DALI_TEST_EQUALS( wasStaticFloatCallbackVoidCalled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( result, 7.0f, TEST_LOCATION );
+
+ signal.Disconnect( StaticFloatCallbackVoid );
+ DALI_TEST_CHECK( signal.Empty() );
+
+ wasStaticFloatCallbackVoidCalled = false;
+ result = signal.Emit();
+ DALI_TEST_EQUALS( wasStaticFloatCallbackVoidCalled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( result, 0.0f, TEST_LOCATION );
+ }
+
+ // void Func( int )
+
+ {
+ TestSignals::VoidRet1ValueParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+
+ signal.Connect( StaticVoidCallbackIntValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+
+ wasStaticVoidCallbackIntValueCalled = false;
+ staticIntValue = 0;
+ signal.Emit( 10 );
+ DALI_TEST_EQUALS( wasStaticVoidCallbackIntValueCalled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( staticIntValue, 10, TEST_LOCATION );
+
+ signal.Disconnect( StaticVoidCallbackIntValue );
+ DALI_TEST_CHECK( signal.Empty() );
+
+ wasStaticVoidCallbackIntValueCalled = false;
+ staticIntValue = 0;
+ signal.Emit( 11 );
+ DALI_TEST_EQUALS( wasStaticVoidCallbackIntValueCalled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( staticIntValue, 0, TEST_LOCATION );
+ }
+
+ // float Func( float, float )
+
+ {
+ TestSignals::FloatRet2ValueParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+
+ signal.Connect( StaticFloatCallbackFloatValueFloatValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+
+ wasStaticFloatCallbackFloatValueFloatValueCalled = false;
+ staticFloatValue1 = 0.0f;
+ staticFloatValue2 = 0.0f;
+ float result = signal.Emit( 5.0f, 6.0f );
+ DALI_TEST_EQUALS( wasStaticFloatCallbackFloatValueFloatValueCalled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( staticFloatValue1, 5.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( staticFloatValue2, 6.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( result, 5.0f+6.0f, TEST_LOCATION );
+
+ signal.Disconnect( StaticFloatCallbackFloatValueFloatValue );
+ DALI_TEST_CHECK( signal.Empty() );
+
+ wasStaticFloatCallbackFloatValueFloatValueCalled = false;
+ staticFloatValue1 = 0.0f;
+ staticFloatValue2 = 0.0f;
+ result = signal.Emit( 7.0f, 8.0f );
+ DALI_TEST_EQUALS( wasStaticFloatCallbackFloatValueFloatValueCalled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( staticFloatValue1, 0.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( staticFloatValue2, 0.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( result, 0.0f, TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliSignalDisconnectDuringCallback(void)
+{
+ // Test disconnection during each callback
+
+ TestSignals::VoidRetNoParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+
+ TestSlotDisconnector handler1;
+ handler1.VoidConnectVoid( signal );
+ DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
+ DALI_TEST_CHECK( ! signal.Empty() );
+
+ signal.Emit();
+ DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Repeat with 2 callbacks
+
+ handler1.mHandled = false;
+
+ TestSlotDisconnector handler2;
+ handler1.VoidConnectVoid( signal );
+ handler2.VoidConnectVoid( signal );
+ DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
+ DALI_TEST_CHECK( ! signal.Empty() );
+
+ signal.Emit();
+ DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION );
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Repeat with no callbacks
+
+ handler1.mHandled = false;
+ handler2.mHandled = false;
+
+ signal.Emit();
+ DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
+
+ // Repeat with 3 callbacks
+
+ TestSlotDisconnector handler3;
+ handler1.VoidConnectVoid( signal );
+ handler2.VoidConnectVoid( signal );
+ handler3.VoidConnectVoid( signal );
+ DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler3.mHandled, false, TEST_LOCATION );
+ DALI_TEST_CHECK( ! signal.Empty() );
+
+ signal.Emit();
+ DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler3.mHandled, true, TEST_LOCATION );
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Repeat with no callbacks
+
+ handler1.mHandled = false;
+ handler2.mHandled = false;
+ handler3.mHandled = false;
+
+ signal.Emit();
+ DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler3.mHandled, false, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliSignalDisconnectDuringCallback2(void)
+{
+ // Test disconnection of some (but not all) callbacks during sigmal emission
+
+ TestSignals::VoidRetNoParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+
+ TestSlotMultiDisconnector handler;
+ handler.ConnectAll( signal );
+ DALI_TEST_EQUALS( handler.mSlotHandled[0], false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[1], false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[2], false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[3], false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[4], false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[5], false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[6], false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[7], false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[8], false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[9], false, TEST_LOCATION );
+ DALI_TEST_CHECK( ! signal.Empty() );
+
+ signal.Emit();
+
+ // Slots 5, 7, & 9 should be disconnected before being called
+ DALI_TEST_EQUALS( handler.mSlotHandled[0], true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[1], true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[2], true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[3], true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[4], true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[5], false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[6], true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[7], false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[8], true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handler.mSlotHandled[9], false, TEST_LOCATION );
+ DALI_TEST_CHECK( ! signal.Empty() );
+
+ // Odd slots are disconnected
+ DALI_TEST_EQUALS( handler.GetConnectionCount(), 5u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliSignalEmitDuringCallback(void)
+{
+ TestApplication app; // Create core for debug logging
+
+ TestSignals::VoidRetNoParamSignal signal;
+ DALI_TEST_CHECK( signal.Empty() );
+
+ TestEmitDuringCallback handler1;
+ handler1.VoidConnectVoid( signal );
+
+ // Test that this does not result in an infinite loop!
+ signal.Emit();
+ END_TEST;
+}
+
+int UtcDaliSignalTestApp01(void)
+{
+ // Test 1 signal connected to 1 Slot.
+ // Signal dies first.
+
+ TestButton* button = new TestButton(1);
+ TestApp app;
+ button->DownSignal().Connect(&app,&TestApp::OnButtonPress);
+
+ // check we have both the button, and the app have 1 connection
+ DALI_TEST_EQUALS( app.GetConnectionCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( button->DownSignal().GetConnectionCount(), 1u, TEST_LOCATION );
+
+ delete button; // should automatically destroy the connection
+
+ // check we have a 0 connections
+ DALI_TEST_EQUALS( app.GetConnectionCount(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliSignalTestApp02(void)
+{
+ // Test 1 signal connected to 1 Slot.
+ // Slot owning object dies first.
+
+ TestButton button(1);
+ TestApp *app = new TestApp;
+ button.DownSignal().Connect( app, &TestApp::OnButtonPress);
+
+ // check we have a 1 connection
+ DALI_TEST_EQUALS( app->GetConnectionCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 1u, TEST_LOCATION );
+
+ delete app; // should automatically destroy the connection
+
+ // check we have a 0 connections
+ DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 0u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliSignalTestApp03(void)
+{
+ // Test 1 Signal connect to 2 slots
+ // 1 of the slot owners dies. Then the second slot owner dies
+
+ TestButton button(1);
+ TestApp *app1 = new TestApp;
+ TestApp *app2 = new TestApp;
+
+ button.DownSignal().Connect( app1, &TestApp::OnButtonPress);
+ button.DownSignal().Connect( app2, &TestApp::OnButtonPress);
+
+ // check we have a 2 connections to the signal
+ DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 2u, TEST_LOCATION );
+
+ // kill the first slot
+ delete app1; // should automatically destroy the connection
+
+ // check we have 1 connection left
+ DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 1u, TEST_LOCATION );
+
+ button.Press(); // emit the signal (to ensure it doesn't seg fault)
+
+ // kill the second slot
+ delete app2; // should automatically destroy the connection
+
+ // check we have 1 connection left
+ DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliSignalTestApp04(void)
+{
+ // Test 1 Signal connected to 2 slots (with different owners)
+ // The Signal dies, check the 2 slots disconnect automatically
+
+ TestButton* button = new TestButton(1);
+ TestApp app1;
+ TestApp app2;
+
+ button->DownSignal().Connect(&app1,&TestApp::OnButtonPress);
+ button->DownSignal().Connect(&app2,&TestApp::OnButtonPress);
+
+ // check the connection counts
+ DALI_TEST_EQUALS( app1.GetConnectionCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( app2.GetConnectionCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( button->DownSignal().GetConnectionCount(), 2u, TEST_LOCATION );
+
+ delete button; // should automatically destroy the connection
+
+ // check both slot owners have zero connections
+ DALI_TEST_EQUALS( app1.GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( app2.GetConnectionCount(), 0u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliSignalTestApp05(void)
+{
+ // Test 2 Signals (with different owners) connected to 1 slots
+ // 1 Signal dies, check that the remaining connection is valid
+
+ TestButton* button1 = new TestButton(1); // use for signal 1
+ TestButton* button2 = new TestButton(2); // use for signal 2
+
+ TestApp app;
+
+ button1->DownSignal().Connect(&app,&TestApp::OnButtonPress);
+ button2->DownSignal().Connect(&app,&TestApp::OnButtonPress);
+
+ // check the connection counts
+ DALI_TEST_EQUALS( app.GetConnectionCount(), 2u, TEST_LOCATION );
+ DALI_TEST_EQUALS( button1->DownSignal().GetConnectionCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( button2->DownSignal().GetConnectionCount(), 1u, TEST_LOCATION );
+
+ // make sure both signals emit ok
+ button2->Press();
+ DALI_TEST_EQUALS( app.GetButtonPressedId() , 2 , TEST_LOCATION );
+
+ button1->Press();
+ DALI_TEST_EQUALS( app.GetButtonPressedId() , 1 , TEST_LOCATION );
+
+ delete button1; // should automatically destroy 1 connection
+
+ // check both slot owners have zero connections
+ DALI_TEST_EQUALS( app.GetConnectionCount(), 1u, TEST_LOCATION );
+
+ // check remaining connection still works
+ button2->Press();
+ DALI_TEST_EQUALS( app.GetButtonPressedId() , 2 , TEST_LOCATION );
+
+ // kill the last signal
+ delete button2;
+ DALI_TEST_EQUALS( app.GetConnectionCount(), 0u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliSignalTestApp06(void)
+{
+ Signal< bool () > boolSignal;
+ TestApp app;
+ bool result(false);
+
+ // connect a slot which will return false
+ boolSignal.Connect( &app, &TestApp::BoolReturnTestFalse);
+ result = boolSignal.Emit();
+ DALI_TEST_EQUALS( result, false, TEST_LOCATION );
+
+ // disconnect last slot, and connect a slot which returns true
+ boolSignal.Disconnect( &app, &TestApp::BoolReturnTestFalse);
+ boolSignal.Connect( &app, &TestApp::BoolReturnTestTrue);
+ result = boolSignal.Emit();
+ DALI_TEST_EQUALS( result, true, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliSlotDelegateConnection(void)
+{
+ TestSignals signals;
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalVoidNone().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotVoid );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ signals.EmitVoidSignalVoid();
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+
+ // Test double emission
+ handlers.mHandled = false;
+ signals.EmitVoidSignalVoid();
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalVoid1Ref().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntRef );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ int x = 7;
+ signals.EmitVoidSignalIntRef(x);
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 7, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalVoid1Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValue );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ signals.EmitVoidSignalIntValue(5);
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 5, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalVoid2Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValueIntValue );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ signals.EmitVoidSignalIntValueIntValue(6, 7);
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 6, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam2, 7, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalBool1Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValue );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+
+ handlers.mBoolReturn = true;
+ DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
+
+ // repeat with opposite return value
+ handlers.mBoolReturn = false;
+ handlers.mHandled = false;
+ DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(6.0f), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 6.0f, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalBool2Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValueIntValue );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mBoolReturn = true;
+ DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam2, 10, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalInt2Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::IntSlotFloatValueIntValue );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mIntReturn = 27;
+ int x = signals.EmitIntSignalFloatValueIntValue(33.5f, 5);
+ DALI_TEST_EQUALS( x, 27, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 33.5f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam2, 5, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalFloat0().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotVoid );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mFloatReturn = 27.0f;
+ float f = signals.EmitFloat0Signal();
+ DALI_TEST_EQUALS( f, 27.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalFloat2Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValueFloatValue );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mFloatReturn = 27.0f;
+ float f = signals.EmitFloat2VSignal(5, 33.0f);
+ DALI_TEST_EQUALS( f, 27.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.VoidSignalFloatValue3().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotFloatValue3 );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ signals.EmitVoidSignalFloatValue3(5, 33.0f, 100.0f);
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam3, 100.0f, 0.001f, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.FloatSignalFloatValue3().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValue3 );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mFloatReturn = 27.0f;
+ float returnValue = signals.EmitFloatSignalFloatValue3(5, 33.0f, 100.0f);
+ DALI_TEST_EQUALS( returnValue, 27.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam3, 100.0f, 0.001f, TEST_LOCATION );
+ }
+ signals.CheckNoConnections();
+ END_TEST;
+}
+
+int UtcDaliSignalSlotDelegateDestruction(void)
+{
+ // Test that signal disconnect works when slot-delegate is destroyed (goes out of scope)
+
+ {
+ TestSignals::VoidRetNoParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotDelegateHandler handler;
+ signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotVoid );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ signal.Emit();
+ }
+
+ {
+ TestSignals::VoidRet1ValueParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotDelegateHandler handler;
+ signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ signal.Emit( 10 );
+ }
+
+ {
+ TestSignals::VoidRet1RefParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotDelegateHandler handler;
+ signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntRef );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ int temp( 5 );
+ signal.Emit( temp );
+ }
+
+ {
+ TestSignals::VoidRet2ValueParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotDelegateHandler handler;
+ signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValueIntValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ signal.Emit( 1, 2 );
+ }
+
+ {
+ TestSignals::BoolRet1ValueParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotDelegateHandler handler;
+ signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ bool blah = signal.Emit( 1.0f );
+ DALI_TEST_CHECK( ! blah );
+ }
+
+ {
+ TestSignals::BoolRet2ValueParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotDelegateHandler handler;
+ signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValueIntValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ bool blah = signal.Emit( 1.0f, 2 );
+ DALI_TEST_CHECK( ! blah );
+ }
+
+ {
+ TestSignals::IntRet2ValueParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotDelegateHandler handler;
+ signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::IntSlotFloatValueIntValue );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ int blah = signal.Emit( 10.0f, 100 );
+ DALI_TEST_CHECK( 0 == blah );
+ }
+
+ {
+ TestSignals::FloatRet0ParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotDelegateHandler handler;
+ signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotVoid );
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ float blah = signal.Emit();
+ DALI_TEST_CHECK( 0.0f == blah );
+ }
+
+ {
+ TestSignals::FloatRet2ValueParamSignal signal;
+ {
+ DALI_TEST_CHECK( signal.Empty() );
+ TestSlotDelegateHandler handler;
+ signal.Connect(handler.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValueFloatValue);
+ DALI_TEST_CHECK( ! signal.Empty() );
+ }
+ // End of slot lifetime
+ DALI_TEST_CHECK( signal.Empty() );
+
+ // Signal emission should be a NOOP
+ float blah = signal.Emit( 3.0f, 4.0f );
+ DALI_TEST_CHECK( 0.0f == blah );
+ }
+ END_TEST;
+}
+
+int UtcDaliSlotHandlerDisconnect(void)
+{
+ // Test that callbacks don't occur if a signal is disconnected before emission
+
+ TestSignals signals;
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalVoidNone().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotVoid);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ signals.SignalVoidNone().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotVoid);
+ signals.EmitVoidSignalVoid();
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ }
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalVoid1Ref().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntRef);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ int r = 7;
+ handlers.mIntReturn = 5;
+ signals.SignalVoid1Ref().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntRef);
+ signals.EmitVoidSignalIntRef(r);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( r, 7, TEST_LOCATION );
+ }
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalVoid1Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ signals.SignalVoid1Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValue);
+ signals.EmitVoidSignalIntValue(5);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
+ }
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalVoid2Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValueIntValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ signals.SignalVoid2Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValueIntValue);
+ signals.EmitVoidSignalIntValueIntValue(5, 10);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION );
+ }
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalBool1Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mBoolReturn = true;
+ signals.SignalBool1Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValue);
+ DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
+ }
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalBool2Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValueIntValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mBoolReturn = true;
+ signals.SignalBool2Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValueIntValue);
+ DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION );
+ }
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalInt2Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::IntSlotFloatValueIntValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mIntReturn = 27;
+ signals.SignalInt2Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::IntSlotFloatValueIntValue);
+ signals.EmitIntSignalFloatValueIntValue(5, 33.0f);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
+ }
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalFloat0().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotVoid);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mFloatReturn = 27.0f;
+ signals.SignalFloat0().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotVoid);
+ signals.EmitFloat0Signal();
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
+ }
+
+ {
+ TestSlotDelegateHandler handlers;
+ signals.SignalFloat2Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValueFloatValue);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ handlers.mFloatReturn = 27.0f;
+ signals.SignalFloat2Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValueFloatValue);
+ signals.EmitFloat2VSignal(5, 33.0f);
+ DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
+ }
+ END_TEST;
+}
{
public:
- typedef SignalV2<void ()> VoidSignalVoid;
- typedef SignalV2<void (float)> VoidSignalFloat;
+ typedef Signal<void ()> VoidSignalVoid;
+ typedef Signal<void (float)> VoidSignalFloat;
- typedef SignalV2<float ()> FloatSignalVoid;
- typedef SignalV2<float (float)> FloatSignalFloat;
+ typedef Signal<float ()> FloatSignalVoid;
+ typedef Signal<float (float)> FloatSignalFloat;
TestSignals()
{
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <iostream>
-#include <stdlib.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-
-void utc_dali_signal_templates_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_signal_templates_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-namespace {
-
-class TestButton
-{
-public:
-
- TestButton( unsigned int id )
- : mId(id)
- {
- }
-
- void Press()
- {
- mPanelDown.Emit( *this );
- }
-
- void Release()
- {
- mPanelUp.Emit( *this );
- }
-
- typedef SignalV2< void (TestButton&) > PanelDownSignal;
- typedef SignalV2< void (TestButton&) > PanelUpSignal;
-
- PanelDownSignal& DownSignal()
- {
- return mPanelDown;
- }
-
- PanelUpSignal& SignalUp()
- {
- return mPanelUp;
- }
-
- int GetId()
- {
- return mId;
- }
-
-private:
-
- int mId;
- PanelDownSignal mPanelDown;
- PanelUpSignal mPanelUp;
-};
-
-class TestApp : public ConnectionTracker
-{
-public:
-
- TestApp()
- : mButtonPressed( false ),
- mVoidFunctionCalled( false )
- {
- }
-
- void OnButtonPress( TestButton& button )
- {
- mButtonPressed = true;
- mButtonId = button.GetId();
- }
-
- void OnButtonRelease( TestButton& button )
- {
- mButtonPressed = false;
- mButtonId = button.GetId();
- }
-
- int GetButtonPressedId()
- {
- return mButtonId;
- }
-
- bool BoolReturnTestFalse()
- {
- return false;
- }
-
- bool BoolReturnTestTrue()
- {
- return true;
- }
-
- void VoidFunction()
- {
- mVoidFunctionCalled = true;
- }
-
- bool mButtonPressed;
- bool mVoidFunctionCalled;
- int mButtonId;
-};
-
-class TestSignals
-{
-public:
-
- // Void return, no parameters
- typedef SignalV2<void ()> VoidRetNoParamSignal;
-
- // Void return, 1 value parameter
- typedef SignalV2<void (int)> VoidRet1ValueParamSignal;
-
- // Void return, 1 reference parameter
- typedef SignalV2< void (int&)> VoidRet1RefParamSignal;
-
- // Void return, 2 value parameters
- typedef SignalV2<void (int, int)> VoidRet2ValueParamSignal;
-
- // bool return, 1 value parameter
- typedef SignalV2< bool (float)> BoolRet1ValueParamSignal;
-
- // bool return, 2 value parameter
- typedef SignalV2<bool (float, int) > BoolRet2ValueParamSignal;
-
- // int return, 2 value parameter
- typedef SignalV2<int (float, int)> IntRet2ValueParamSignal;
-
- // float return, 0 parameters
- typedef SignalV2< float () > FloatRet0ParamSignal;
-
- // float return, 2 value parameters
- typedef SignalV2<float (float, float) > FloatRet2ValueParamSignal;
-
- // void return, 3 value parameters
- typedef SignalV2<void (float, float, float) > VoidSignalTypeFloatValue3;
-
- // float return, 3 value parameters
- typedef SignalV2<float (float, float, float) > FloatSignalTypeFloatValue3;
-
- VoidRetNoParamSignal& SignalVoidNone() { return mSignalVoid0; }
- VoidRet1RefParamSignal& SignalVoid1Ref() { return mSignalVoid1R; }
- VoidRet1ValueParamSignal& SignalVoid1Value() { return mSignalVoid1V; }
- VoidRet2ValueParamSignal& SignalVoid2Value() { return mSignalVoid2V; }
-
- BoolRet1ValueParamSignal& SignalBool1Value() { return mSignalBool1V; }
- BoolRet2ValueParamSignal& SignalBool2Value() { return mSignalBool2V; }
- IntRet2ValueParamSignal& SignalInt2Value() { return mSignalInt2V; }
- FloatRet0ParamSignal& SignalFloat0() { return mSignalFloat0; }
- FloatRet2ValueParamSignal& SignalFloat2Value() { return mSignalFloat2V; }
-
- VoidSignalTypeFloatValue3& VoidSignalFloatValue3() { return mVoidSignalFloatValue3; }
- FloatSignalTypeFloatValue3& FloatSignalFloatValue3() { return mFloatSignalFloatValue3; }
-
- TestSignals()
- {
- }
-
- void CheckNoConnections()
- {
- DALI_TEST_EQUALS( mSignalVoid0.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( mSignalVoid1R.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( mSignalVoid1V.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( mSignalVoid2V.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( mSignalBool1V.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( mSignalBool2V.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( mSignalInt2V.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( mSignalFloat0.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( mSignalFloat2V.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( mVoidSignalFloatValue3.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( mFloatSignalFloatValue3.GetConnectionCount(), 0u, TEST_LOCATION );
- }
-
- void EmitVoidSignalVoid()
- {
- mSignalVoid0.Emit();
- }
-
- void EmitVoidSignalIntRef(int& ref)
- {
- mSignalVoid1R.Emit(ref);
- }
-
- void EmitVoidSignalIntValue(int p1)
- {
- mSignalVoid1V.Emit(p1);
- }
-
- void EmitVoidSignalIntValueIntValue(int p1, int p2)
- {
- mSignalVoid2V.Emit(p1,p2);
- }
-
- bool EmitBoolSignalFloatValue(float p1)
- {
- return mSignalBool1V.Emit(p1);
- }
-
- bool EmitBoolSignalFloatValueIntValue(float p1, int p2)
- {
- return mSignalBool2V.Emit(p1, p2);
- }
-
- int EmitIntSignalFloatValueIntValue(float p1, int p2)
- {
- return mSignalInt2V.Emit(p1, p2);
- }
-
- float EmitFloat2VSignal(float p1, float p2)
- {
- return mSignalFloat2V.Emit(p1, p2);
- }
-
- float EmitFloat0Signal()
- {
- return mSignalFloat0.Emit();
- }
-
- void EmitVoidSignalFloatValue3(float p1, float p2, float p3)
- {
- mVoidSignalFloatValue3.Emit(p1, p2, p3);
- }
-
- float EmitFloatSignalFloatValue3(float p1, float p2, float p3)
- {
- return mFloatSignalFloatValue3.Emit(p1, p2, p3);
- }
-
-private:
-
- VoidRetNoParamSignal mSignalVoid0;
- VoidRet1RefParamSignal mSignalVoid1R;
- VoidRet1ValueParamSignal mSignalVoid1V;
- VoidRet2ValueParamSignal mSignalVoid2V;
- BoolRet1ValueParamSignal mSignalBool1V;
- BoolRet2ValueParamSignal mSignalBool2V;
- IntRet2ValueParamSignal mSignalInt2V;
- FloatRet0ParamSignal mSignalFloat0;
- FloatRet2ValueParamSignal mSignalFloat2V;
- VoidSignalTypeFloatValue3 mVoidSignalFloatValue3;
- FloatSignalTypeFloatValue3 mFloatSignalFloatValue3;
-};
-
-/**
- * A helper class with various slots
- */
-class TestSlotHandler : public ConnectionTracker
-{
-public:
-
- TestSlotHandler()
- : mIntParam1( 0 ),
- mIntParam2( 0 ),
- mIntParam3( 0 ),
- mFloatParam1( 0.0f ),
- mFloatParam2( 0.0f ),
- mFloatParam3( 0.0f ),
- mBoolReturn( false ),
- mIntReturn( 0 ),
- mFloatReturn( 0.0f ),
- mHandled( false ),
- mHandledCount( 0 )
- {
- }
-
- void Reset()
- {
- mIntParam1 = 0;
- mIntParam2 = 0;
- mIntParam3 = 0;
- mFloatParam1 = 0.0f;
- mFloatParam2 = 0.0f;
- mFloatParam3 = 0.0f;
- mBoolReturn = false;
- mIntReturn = 0;
- mFloatReturn = 0.0f;
- mHandled = false;
- }
-
- void VoidSlotVoid()
- {
- mHandled = true;
- ++mHandledCount;
- }
-
- void VoidSlotIntRef( int& p1 )
- {
- mIntParam1 = p1;
- mHandled = true;
- ++mHandledCount;
- }
-
- void VoidSlotIntValue( int p1 )
- {
- mIntParam1 = p1;
- mHandled = true;
- ++mHandledCount;
- }
-
- void VoidDuplicateSlotIntValue( int p1 )
- {
- mIntParam2 = p1;
- mHandled = true;
- ++mHandledCount;
- }
-
- void VoidSlotIntValueIntValue( int p1, int p2 )
- {
- mIntParam1 = p1;
- mIntParam2 = p2;
- mHandled = true;
- ++mHandledCount;
- }
-
- bool BoolSlotFloatValue( float p1 )
- {
- mFloatParam1 = p1;
- mHandled = true;
- ++mHandledCount;
- return mBoolReturn;
- }
-
- bool BoolSlotFloatValueIntValue( float p1, int p2 )
- {
- mFloatParam1 = p1;
- mIntParam2 = p2;
- mHandled = true;
- ++mHandledCount;
- return mBoolReturn;
- }
-
- int IntSlotFloatValueIntValue( float p1, int p2 )
- {
- mFloatParam1 = p1;
- mIntParam2 = p2;
- mHandled = true;
- ++mHandledCount;
- return mIntReturn;
- }
-
- float FloatSlotVoid()
- {
- mHandled = true;
- ++mHandledCount;
- return mFloatReturn;
- }
-
- float FloatSlotFloatValueFloatValue( float p1, float p2 )
- {
- mFloatParam1 = p1;
- mFloatParam2 = p2;
- mHandled = true;
- ++mHandledCount;
- return mFloatReturn;
- }
-
- void VoidSlotFloatValue3( float p1, float p2, float p3 )
- {
- mFloatParam1 = p1;
- mFloatParam2 = p2;
- mFloatParam3 = p3;
- mHandled = true;
- ++mHandledCount;
- }
-
- float FloatSlotFloatValue3( float p1, float p2, float p3 )
- {
- mFloatParam1 = p1;
- mFloatParam2 = p2;
- mFloatParam3 = p3;
- mHandled = true;
- ++mHandledCount;
- return mFloatReturn;
- }
-
- int mIntParam1, mIntParam2, mIntParam3;
- float mFloatParam1, mFloatParam2, mFloatParam3;
- bool mBoolReturn;
- int mIntReturn;
- float mFloatReturn;
- bool mHandled;
- int mHandledCount;
-};
-
-/**
- * A version of TestSlotHandler which disconnects during the callback
- */
-class TestSlotDisconnector : public ConnectionTracker
-{
-public:
-
- TestSlotDisconnector()
- : mIntParam1( 0 ),
- mIntParam2( 0 ),
- mIntParam3( 0 ),
- mFloatParam1( 0.0f ),
- mFloatParam2( 0.0f ),
- mBoolReturn( false ),
- mIntReturn( 0 ),
- mFloatReturn( 0.0f ),
- mHandled( false )
- {
- }
-
- void Reset()
- {
- mIntParam1 = 0;
- mIntParam2 = 0;
- mIntParam3 = 0;
- mFloatParam1 = 0.0f;
- mFloatParam2 = 0.0f;
- mBoolReturn = false;
- mIntReturn = 0;
- mFloatReturn = 0.0f;
- mHandled = false;
- }
-
- void VoidConnectVoid( TestSignals::VoidRetNoParamSignal& signal )
- {
- mVoidSignalVoid = &signal;
- signal.Connect( this, &TestSlotDisconnector::VoidSlotVoid );
- }
-
- void VoidSlotVoid()
- {
- mVoidSignalVoid->Disconnect( this, &TestSlotDisconnector::VoidSlotVoid );
- mHandled = true;
- }
-
- void VoidConnectIntRef( TestSignals::VoidRet1RefParamSignal& signal )
- {
- mVoidSignalIntRef = &signal;
- signal.Connect( this, &TestSlotDisconnector::VoidSlotIntRef );
- }
-
- void VoidSlotIntRef( int& p1 )
- {
- mVoidSignalIntRef->Disconnect( this, &TestSlotDisconnector::VoidSlotIntRef );
- mIntParam1 = p1;
- mHandled = true;
- }
-
- void VoidSlotIntValue( int p1 )
- {
- mIntParam1 = p1;
- mHandled = true;
- }
-
- void VoidSlotIntValueIntValue( int p1, int p2 )
- {
- mIntParam1 = p1;
- mIntParam2 = p2;
- mHandled = true;
- }
-
- bool BoolSlotFloatValue( float p1 )
- {
- mFloatParam1 = p1;
- mHandled = true;
- return mBoolReturn;
- }
-
- bool BoolSlotFloatValueIntValue( float p1, int p2 )
- {
- mFloatParam1 = p1;
- mIntParam2 = p2;
- mHandled = true;
- return mBoolReturn;
- }
-
- int IntSlotFloatValueIntValue( float p1, int p2 )
- {
- mFloatParam1 = p1;
- mIntParam2 = p2;
- mHandled = true;
- return mIntReturn;
- }
-
- float FloatSlotVoid()
- {
- mHandled = true;
- return mFloatReturn;
- }
-
- float FloatSlotFloatValueFloatValue( float p1, float p2 )
- {
- mFloatParam1 = p1;
- mFloatParam2 = p2;
- mHandled = true;
- return mFloatReturn;
- }
-
- TestSignals::VoidRetNoParamSignal* mVoidSignalVoid;
- TestSignals::VoidRet1RefParamSignal* mVoidSignalIntRef;
-
- int mIntParam1, mIntParam2, mIntParam3;
- float mFloatParam1, mFloatParam2;
- bool mBoolReturn;
- int mIntReturn;
- float mFloatReturn;
- bool mHandled;
-};
-
-/**
- * A more complicated version of TestSlotDisconnector, which disconnects some but not all callbacks
- */
-class TestSlotMultiDisconnector : public ConnectionTracker
-{
-public:
-
- static const int NUM_SLOTS = 10;
-
- TestSlotMultiDisconnector()
- : mVoidSignalVoid( NULL )
- {
- Reset();
- }
-
- void Reset()
- {
- for( int i=0; i<NUM_SLOTS; ++i )
- {
- mSlotHandled[i] = false;
- }
- }
-
- void ConnectAll( TestSignals::VoidRetNoParamSignal& signal )
- {
- mVoidSignalVoid = &signal;
- signal.Connect( this, &TestSlotMultiDisconnector::Slot0 );
- signal.Connect( this, &TestSlotMultiDisconnector::Slot1 );
- signal.Connect( this, &TestSlotMultiDisconnector::Slot2 );
- signal.Connect( this, &TestSlotMultiDisconnector::Slot3 );
- signal.Connect( this, &TestSlotMultiDisconnector::Slot4 );
- signal.Connect( this, &TestSlotMultiDisconnector::Slot5 );
- signal.Connect( this, &TestSlotMultiDisconnector::Slot6 );
- signal.Connect( this, &TestSlotMultiDisconnector::Slot7 );
- signal.Connect( this, &TestSlotMultiDisconnector::Slot8 );
- signal.Connect( this, &TestSlotMultiDisconnector::Slot9 );
- }
-
- void Slot0()
- {
- mSlotHandled[0] = true;
- }
-
- void Slot1()
- {
- mSlotHandled[1] = true;
- }
-
- void Slot2()
- {
- mSlotHandled[2] = true;
- }
-
- void Slot3()
- {
- mSlotHandled[3] = true;
-
- // Disconnect the odd numbered lots, because we can
- mVoidSignalVoid->Disconnect( this, &TestSlotMultiDisconnector::Slot1 );
- mVoidSignalVoid->Disconnect( this, &TestSlotMultiDisconnector::Slot3 );
- mVoidSignalVoid->Disconnect( this, &TestSlotMultiDisconnector::Slot5 );
- mVoidSignalVoid->Disconnect( this, &TestSlotMultiDisconnector::Slot7 );
- mVoidSignalVoid->Disconnect( this, &TestSlotMultiDisconnector::Slot9 );
- }
-
- void Slot4()
- {
- mSlotHandled[4] = true;
- }
-
- void Slot5()
- {
- mSlotHandled[5] = true;
- }
-
- void Slot6()
- {
- mSlotHandled[6] = true;
- }
-
- void Slot7()
- {
- mSlotHandled[7] = true;
- }
-
- void Slot8()
- {
- mSlotHandled[8] = true;
- }
-
- void Slot9()
- {
- mSlotHandled[9] = true;
- }
-
- TestSignals::VoidRetNoParamSignal* mVoidSignalVoid;
-
- bool mSlotHandled[NUM_SLOTS];
-};
-
-
-/**
- * A version of TestSlotHandler which disconnects during the callback
- */
-class TestEmitDuringCallback : public ConnectionTracker
-{
-public:
-
- TestEmitDuringCallback()
- : mVoidSignalVoid( NULL ),
- mHandled( false )
- {
- }
-
- void VoidConnectVoid( TestSignals::VoidRetNoParamSignal& signal )
- {
- mVoidSignalVoid = &signal;
- signal.Connect( this, &TestEmitDuringCallback::VoidSlotVoid );
- }
-
- void VoidSlotVoid()
- {
- // Emitting during Emit is very bad!
- mVoidSignalVoid->Emit();
-
- mHandled = true;
- }
-
- TestSignals::VoidRetNoParamSignal* mVoidSignalVoid;
-
- bool mHandled;
-};
-
-
-/**
- * A version of TestSlotHandler which uses SlotDelegate
- */
-class TestSlotDelegateHandler // This does not inherit from ConnectionTrackerInterface!
-{
-public:
-
- TestSlotDelegateHandler()
- : mSlotDelegate( this ),
- mIntParam1( 0 ),
- mIntParam2( 0 ),
- mIntParam3( 0 ),
- mFloatParam1( 0.0f ),
- mFloatParam2( 0.0f ),
- mFloatParam3( 0.0f ),
- mBoolReturn( false ),
- mIntReturn( 0 ),
- mFloatReturn( 0.0f ),
- mHandled( false ),
- mHandledCount( 0 )
- {
- }
-
- void Reset()
- {
- mIntParam1 = 0;
- mIntParam2 = 0;
- mIntParam3 = 0;
- mFloatParam1 = 0.0f;
- mFloatParam2 = 0.0f;
- mFloatParam3 = 0.0f;
- mBoolReturn = false;
- mIntReturn = 0;
- mFloatReturn = 0.0f;
- mHandled = false;
- }
-
- void VoidSlotVoid()
- {
- mHandled = true;
- ++mHandledCount;
- }
-
- void VoidSlotIntRef( int& p1 )
- {
- mIntParam1 = p1;
- mHandled = true;
- ++mHandledCount;
- }
-
- void VoidSlotIntValue( int p1 )
- {
- mIntParam1 = p1;
- mHandled = true;
- ++mHandledCount;
- }
-
- void VoidDuplicateSlotIntValue( int p1 )
- {
- mIntParam2 = p1;
- mHandled = true;
- ++mHandledCount;
- }
-
- void VoidSlotIntValueIntValue( int p1, int p2 )
- {
- mIntParam1 = p1;
- mIntParam2 = p2;
- mHandled = true;
- ++mHandledCount;
- }
-
- bool BoolSlotFloatValue( float p1 )
- {
- mFloatParam1 = p1;
- mHandled = true;
- ++mHandledCount;
- return mBoolReturn;
- }
-
- bool BoolSlotFloatValueIntValue( float p1, int p2 )
- {
- mFloatParam1 = p1;
- mIntParam2 = p2;
- mHandled = true;
- ++mHandledCount;
- return mBoolReturn;
- }
-
- int IntSlotFloatValueIntValue( float p1, int p2 )
- {
- mFloatParam1 = p1;
- mIntParam2 = p2;
- mHandled = true;
- ++mHandledCount;
- return mIntReturn;
- }
-
- float FloatSlotVoid()
- {
- mHandled = true;
- ++mHandledCount;
- return mFloatReturn;
- }
-
- float FloatSlotFloatValueFloatValue( float p1, float p2 )
- {
- mFloatParam1 = p1;
- mFloatParam2 = p2;
- mHandled = true;
- ++mHandledCount;
- return mFloatReturn;
- }
-
- void VoidSlotFloatValue3( float p1, float p2, float p3 )
- {
- mFloatParam1 = p1;
- mFloatParam2 = p2;
- mFloatParam3 = p3;
- mHandled = true;
- ++mHandledCount;
- }
-
- float FloatSlotFloatValue3( float p1, float p2, float p3 )
- {
- mFloatParam1 = p1;
- mFloatParam2 = p2;
- mFloatParam3 = p3;
- mHandled = true;
- ++mHandledCount;
- return mFloatReturn;
- }
-
- SlotDelegate<TestSlotDelegateHandler> mSlotDelegate;
-
- int mIntParam1, mIntParam2, mIntParam3;
- float mFloatParam1, mFloatParam2, mFloatParam3;
- bool mBoolReturn;
- int mIntReturn;
- float mFloatReturn;
- bool mHandled;
- int mHandledCount;
-};
-
-/**
- * Test that reimplmenting ConnectionTrackerInterface actually works.
- * This basic connection tracker only allows one callback to be connected.
- */
-class TestBasicConnectionTrackerInterface : public ConnectionTrackerInterface
-{
-public:
-
- TestBasicConnectionTrackerInterface()
- : mCallbackHandled( false ),
- mCallback( NULL ),
- mSlotObserver( NULL )
- {
- }
-
- ~TestBasicConnectionTrackerInterface()
- {
- if( mSlotObserver && mCallback )
- {
- // Notify signal since the slot has been destroyed
- mSlotObserver->SlotDisconnected( mCallback );
- // mCallback and mSlotObserver are not owned
- }
- }
-
- /**
- * An example slot
- */
- void VoidSlotVoid()
- {
- mCallbackHandled = true;
- }
-
- /**
- * @copydoc ConnectionTrackerInterface::GetConnectionCount
- */
- virtual std::size_t GetConnectionCount() const
- {
- if( mCallback )
- {
- return 1u;
- }
-
- return 0u;
- }
-
- /**
- * @copydoc ConnectionTrackerInterface::SignalConnected
- */
- virtual void SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
- {
- DALI_ASSERT_ALWAYS( NULL == mCallback && "Only one connection supported!" );
-
- mCallback = callback;
- mSlotObserver = slotObserver;
- }
-
- /**
- * @copydoc ConnectionTrackerInterface::SignalDisconnected
- */
- virtual void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
- {
- if( mSlotObserver == slotObserver )
- {
- mSlotObserver = NULL;
- mCallback = NULL;
- // mCallback and mSlotObserver are not owned
- }
- }
-
-private:
-
- TestBasicConnectionTrackerInterface( const TestBasicConnectionTrackerInterface& ); ///< undefined copy constructor
- TestBasicConnectionTrackerInterface& operator=( const TestBasicConnectionTrackerInterface& ); ///< undefined assignment operator
-
-public:
-
- bool mCallbackHandled;
-
-private:
-
- CallbackBase* mCallback; ///< callback, has ownership
- SlotObserver* mSlotObserver; ///< a pointer to the slot observer (not owned)
-};
-
-
-bool wasStaticVoidCallbackVoidCalled = false;
-bool wasStaticFloatCallbackVoidCalled = false;
-bool wasStaticVoidCallbackIntValueCalled = false;
-int staticIntValue = 0;
-bool wasStaticFloatCallbackFloatValueFloatValueCalled = false;
-float staticFloatValue1 = 0.0f;
-float staticFloatValue2 = 0.0f;
-
-static void StaticVoidCallbackVoid()
-{
- wasStaticVoidCallbackVoidCalled = true;
-}
-
-static float StaticFloatCallbackVoid()
-{
- wasStaticFloatCallbackVoidCalled = true;
- return 7.0f;
-}
-
-static void StaticVoidCallbackIntValue( int value )
-{
- wasStaticVoidCallbackIntValueCalled = true;
- staticIntValue = value;
-}
-
-static float StaticFloatCallbackFloatValueFloatValue( float value1, float value2 )
-{
- wasStaticFloatCallbackFloatValueFloatValueCalled = true;
- staticFloatValue1 = value1;
- staticFloatValue2 = value2;
- return value1 + value2;
-}
-
-} // anon namespace
-
-
-int UtcDaliSignalEmptyCheck(void)
-{
- // Test that Empty() check works before & after signal connection
-
- {
- TestSignals::VoidRetNoParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::VoidSlotVoid );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
-
- {
- TestSignals::VoidRet1ValueParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::VoidSlotIntValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
-
- {
- TestSignals::VoidRet1RefParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::VoidSlotIntRef );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
-
- {
- TestSignals::VoidRet2ValueParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::VoidSlotIntValueIntValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
-
- {
- TestSignals::BoolRet1ValueParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::BoolSlotFloatValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
-
- {
- TestSignals::BoolRet2ValueParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::BoolSlotFloatValueIntValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
-
- {
- TestSignals::IntRet2ValueParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::IntSlotFloatValueIntValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
-
- {
- TestSignals::FloatRet0ParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::FloatSlotVoid );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
-
- {
- TestSignals::FloatRet2ValueParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect(&handler, &TestSlotHandler::FloatSlotFloatValueFloatValue);
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- END_TEST;
-}
-
-int UtcDaliSignalEmptyCheckSlotDestruction(void)
-{
- // Test that signal disconnect works when slot is destroyed (goes out of scope)
-
- {
- TestSignals::VoidRetNoParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::VoidSlotVoid );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- signal.Emit();
- }
-
- {
- TestSignals::VoidRet1ValueParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::VoidSlotIntValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- signal.Emit( 10 );
- }
-
- {
- TestSignals::VoidRet1RefParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::VoidSlotIntRef );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- int temp( 5 );
- signal.Emit( temp );
- }
-
- {
- TestSignals::VoidRet2ValueParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::VoidSlotIntValueIntValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- signal.Emit( 1, 2 );
- }
-
- {
- TestSignals::BoolRet1ValueParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::BoolSlotFloatValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- bool blah = signal.Emit( 1.0f );
- DALI_TEST_CHECK( ! blah );
- }
-
- {
- TestSignals::BoolRet2ValueParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::BoolSlotFloatValueIntValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- bool blah = signal.Emit( 1.0f, 2 );
- DALI_TEST_CHECK( ! blah );
- }
-
- {
- TestSignals::IntRet2ValueParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::IntSlotFloatValueIntValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- int blah = signal.Emit( 10.0f, 100 );
- DALI_TEST_CHECK( 0 == blah );
- }
-
- {
- TestSignals::FloatRet0ParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect( &handler, &TestSlotHandler::FloatSlotVoid );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- float blah = signal.Emit();
- DALI_TEST_CHECK( 0.0f == blah );
- }
-
- {
- TestSignals::FloatRet2ValueParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotHandler handler;
- signal.Connect(&handler, &TestSlotHandler::FloatSlotFloatValueFloatValue);
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- float blah = signal.Emit( 3.0f, 4.0f );
- DALI_TEST_CHECK( 0.0f == blah );
- }
- END_TEST;
-}
-
-// Positive test case for a method
-int UtcDaliSignalConnectAndEmit(void)
-{
- // Test basic signal emission for each slot type
-
- TestSignals signals;
-
- {
- TestSlotHandler handlers;
- signals.SignalVoidNone().Connect(&handlers, &TestSlotHandler::VoidSlotVoid);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- signals.EmitVoidSignalVoid();
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
-
- // Test double emission
- handlers.mHandled = false;
- signals.EmitVoidSignalVoid();
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotHandler handlers;
- signals.SignalVoid1Ref().Connect(&handlers, &TestSlotHandler::VoidSlotIntRef);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- int x = 7;
- signals.EmitVoidSignalIntRef(x);
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 7, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotHandler handlers;
- signals.SignalVoid1Value().Connect(&handlers, &TestSlotHandler::VoidSlotIntValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- signals.EmitVoidSignalIntValue(5);
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 5, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotHandler handlers;
- signals.SignalVoid2Value().Connect(&handlers, &TestSlotHandler::VoidSlotIntValueIntValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- signals.EmitVoidSignalIntValueIntValue(6, 7);
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 6, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam2, 7, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotHandler handlers;
- signals.SignalBool1Value().Connect(&handlers, &TestSlotHandler::BoolSlotFloatValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
-
- handlers.mBoolReturn = true;
- DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
-
- // repeat with opposite return value
- handlers.mBoolReturn = false;
- handlers.mHandled = false;
- DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(6.0f), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 6.0f, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotHandler handlers;
- signals.SignalBool2Value().Connect(&handlers, &TestSlotHandler::BoolSlotFloatValueIntValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mBoolReturn = true;
- DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam2, 10, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotHandler handlers;
- signals.SignalInt2Value().Connect(&handlers, &TestSlotHandler::IntSlotFloatValueIntValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mIntReturn = 27;
- int x = signals.EmitIntSignalFloatValueIntValue(33.5f, 5);
- DALI_TEST_EQUALS( x, 27, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 33.5f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam2, 5, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotHandler handlers;
- signals.SignalFloat0().Connect(&handlers, &TestSlotHandler::FloatSlotVoid);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mFloatReturn = 27.0f;
- float f = signals.EmitFloat0Signal();
- DALI_TEST_EQUALS( f, 27.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotHandler handlers;
- signals.SignalFloat2Value().Connect(&handlers, &TestSlotHandler::FloatSlotFloatValueFloatValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mFloatReturn = 27.0f;
- float f = signals.EmitFloat2VSignal(5, 33.0f);
- DALI_TEST_EQUALS( f, 27.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotHandler handlers;
- signals.VoidSignalFloatValue3().Connect(&handlers, &TestSlotHandler::VoidSlotFloatValue3);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- signals.EmitVoidSignalFloatValue3(5, 33.0f, 100.0f);
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam3, 100.0f, 0.001f, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotHandler handlers;
- signals.FloatSignalFloatValue3().Connect(&handlers, &TestSlotHandler::FloatSlotFloatValue3);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mFloatReturn = 27.0f;
- float returnValue = signals.EmitFloatSignalFloatValue3(5, 33.0f, 100.0f);
- DALI_TEST_EQUALS( returnValue, 27.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam3, 100.0f, 0.001f, TEST_LOCATION );
- }
- signals.CheckNoConnections();
- END_TEST;
-}
-
-int UtcDaliSignalDisconnect(void)
-{
- // Test that callbacks don't occur if a signal is disconnected before emission
-
- TestSignals signals;
-
- {
- TestSlotHandler handlers;
- signals.SignalVoidNone().Connect(&handlers, &TestSlotHandler::VoidSlotVoid);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- signals.SignalVoidNone().Disconnect(&handlers, &TestSlotHandler::VoidSlotVoid);
- signals.EmitVoidSignalVoid();
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- signals.SignalVoid1Ref().Connect(&handlers, &TestSlotHandler::VoidSlotIntRef);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- int r = 7;
- handlers.mIntReturn = 5;
- signals.SignalVoid1Ref().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntRef);
- signals.EmitVoidSignalIntRef(r);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( r, 7, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- signals.SignalVoid1Value().Connect(&handlers, &TestSlotHandler::VoidSlotIntValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- signals.SignalVoid1Value().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntValue);
- signals.EmitVoidSignalIntValue(5);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- signals.SignalVoid2Value().Connect(&handlers, &TestSlotHandler::VoidSlotIntValueIntValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- signals.SignalVoid2Value().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntValueIntValue);
- signals.EmitVoidSignalIntValueIntValue(5, 10);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- signals.SignalBool1Value().Connect(&handlers, &TestSlotHandler::BoolSlotFloatValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mBoolReturn = true;
- signals.SignalBool1Value().Disconnect(&handlers, &TestSlotHandler::BoolSlotFloatValue);
- DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- signals.SignalBool2Value().Connect(&handlers, &TestSlotHandler::BoolSlotFloatValueIntValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mBoolReturn = true;
- signals.SignalBool2Value().Disconnect(&handlers, &TestSlotHandler::BoolSlotFloatValueIntValue);
- DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- signals.SignalInt2Value().Connect(&handlers, &TestSlotHandler::IntSlotFloatValueIntValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mIntReturn = 27;
- signals.SignalInt2Value().Disconnect(&handlers, &TestSlotHandler::IntSlotFloatValueIntValue);
- signals.EmitIntSignalFloatValueIntValue(5, 33.0f);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- signals.SignalFloat0().Connect(&handlers, &TestSlotHandler::FloatSlotVoid);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mFloatReturn = 27.0f;
- signals.SignalFloat0().Disconnect(&handlers, &TestSlotHandler::FloatSlotVoid);
- signals.EmitFloat0Signal();
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- signals.SignalFloat2Value().Connect(&handlers, &TestSlotHandler::FloatSlotFloatValueFloatValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mFloatReturn = 27.0f;
- signals.SignalFloat2Value().Disconnect(&handlers, &TestSlotHandler::FloatSlotFloatValueFloatValue);
- signals.EmitFloat2VSignal(5, 33.0f);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliSignalDisconnect2(void)
-{
- // Test that nothing happens when attempting to disconnect an unconnected slot
-
- TestSignals signals;
- {
- TestSlotHandler handlers;
- signals.SignalVoidNone().Disconnect(&handlers, &TestSlotHandler::VoidSlotVoid);
- signals.EmitVoidSignalVoid();
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- int r = 7;
- signals.SignalVoid1Ref().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntRef);
- signals.EmitVoidSignalIntRef(r);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( r, 7, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- signals.SignalVoid1Value().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntValue);
- signals.EmitVoidSignalIntValue(5);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- signals.SignalVoid2Value().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntValueIntValue);
- signals.EmitVoidSignalIntValueIntValue(5, 10);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- handlers.mBoolReturn = true;
- signals.SignalBool1Value().Disconnect(&handlers, &TestSlotHandler::BoolSlotFloatValue);
- DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- handlers.mBoolReturn = true;
- signals.SignalBool2Value().Disconnect(&handlers, &TestSlotHandler::BoolSlotFloatValueIntValue);
- DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- handlers.mIntReturn = 27;
- signals.SignalInt2Value().Disconnect(&handlers, &TestSlotHandler::IntSlotFloatValueIntValue);
- signals.EmitIntSignalFloatValueIntValue(5, 33.0f);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- handlers.mFloatReturn = 27.0f;
- signals.SignalFloat2Value().Disconnect(&handlers, &TestSlotHandler::FloatSlotFloatValueFloatValue);
- signals.EmitFloat2VSignal(5, 33.0f);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- handlers.mFloatReturn = 27.0f;
- signals.SignalFloat0().Disconnect(&handlers, &TestSlotHandler::FloatSlotVoid);
- signals.EmitFloat0Signal();
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliSignalDisconnect3(void)
-{
- // Test that callbacks stop after a signal is disconnected
-
- TestSignals signals;
-
- {
- TestSlotHandler handlers;
- signals.SignalVoidNone().Connect(&handlers, &TestSlotHandler::VoidSlotVoid);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
-
- // Emit first
- signals.EmitVoidSignalVoid();
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
-
- // Disconnect and emit again
- handlers.mHandled = false;
- signals.SignalVoidNone().Disconnect(&handlers, &TestSlotHandler::VoidSlotVoid);
- signals.EmitVoidSignalVoid();
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handlers;
- signals.SignalVoid1Ref().Connect(&handlers, &TestSlotHandler::VoidSlotIntRef);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- int r = 7;
-
- // Emit first
- signals.EmitVoidSignalIntRef(r);
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 7, TEST_LOCATION );
-
- // Disconnect and emit again
- handlers.mHandled = false;
- handlers.mIntParam1 = 0;
- signals.SignalVoid1Ref().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntRef);
- signals.EmitVoidSignalIntRef(r);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( r, 7, TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliSignalCustomConnectionTracker(void)
-{
- // Test slot destruction
- {
- TestSignals::VoidRetNoParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestBasicConnectionTrackerInterface customTracker;
- signal.Connect( &customTracker, &TestBasicConnectionTrackerInterface::VoidSlotVoid );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- signal.Emit();
- }
-
- TestBasicConnectionTrackerInterface customTracker2;
-
- // Test signal emission & destruction
- {
- TestSignals::VoidRetNoParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
- DALI_TEST_EQUALS( 0u, customTracker2.GetConnectionCount(), TEST_LOCATION );
-
- signal.Connect( &customTracker2, &TestBasicConnectionTrackerInterface::VoidSlotVoid );
- DALI_TEST_CHECK( ! signal.Empty() );
- DALI_TEST_EQUALS( 1u, customTracker2.GetConnectionCount(), TEST_LOCATION );
-
- DALI_TEST_EQUALS( customTracker2.mCallbackHandled, false, TEST_LOCATION );
- signal.Emit();
- DALI_TEST_EQUALS( customTracker2.mCallbackHandled, true, TEST_LOCATION );
- }
- DALI_TEST_EQUALS( 0u, customTracker2.GetConnectionCount(), TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliSignalMultipleConnections(void)
-{
- // Test that multiple callbacks can be connected to the same signal
-
- TestSignals signals;
-
- {
- TestSlotHandler handler1;
- signals.SignalVoidNone().Connect( &handler1, &TestSlotHandler::VoidSlotVoid );
- DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
-
- TestSlotHandler handler2;
- signals.SignalVoidNone().Connect( &handler2, &TestSlotHandler::VoidSlotVoid );
- DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
-
- signals.EmitVoidSignalVoid();
- DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION );
-
- // Remove first connection and repeat
- handler1.Reset();
- handler2.Reset();
- signals.SignalVoidNone().Disconnect( &handler1, &TestSlotHandler::VoidSlotVoid );
-
- signals.EmitVoidSignalVoid();
- DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handler1;
- signals.SignalVoid1Ref().Connect( &handler1, &TestSlotHandler::VoidSlotIntRef );
- DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
-
- TestSlotHandler handler2;
- signals.SignalVoid1Ref().Connect( &handler2, &TestSlotHandler::VoidSlotIntRef );
- DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
-
- int x = 7;
- signals.EmitVoidSignalIntRef(x);
- DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler1.mIntParam1, 7, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mIntParam1, 7, TEST_LOCATION );
-
- // Remove second connection and repeat
- handler1.Reset();
- handler2.Reset();
- x = 8;
- signals.SignalVoid1Ref().Disconnect( &handler2, &TestSlotHandler::VoidSlotIntRef );
-
- signals.EmitVoidSignalIntRef(x);
- DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler1.mIntParam1, 8, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mIntParam1, 0, TEST_LOCATION );
- }
-
- {
- TestSlotHandler handler1;
- signals.SignalVoid1Value().Connect( &handler1, &TestSlotHandler::VoidSlotIntValue );
- DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
-
- TestSlotHandler handler2;
- signals.SignalVoid1Value().Connect( &handler2, &TestSlotHandler::VoidSlotIntValue );
- DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
-
- TestSlotHandler handler3;
- signals.SignalVoid1Value().Connect( &handler3, &TestSlotHandler::VoidSlotIntValue );
- DALI_TEST_EQUALS( handler3.mHandled, false, TEST_LOCATION );
-
- signals.EmitVoidSignalIntValue( 5 );
- DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler1.mIntParam1, 5, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mIntParam1, 5, TEST_LOCATION );
- DALI_TEST_EQUALS( handler3.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler3.mIntParam1, 5, TEST_LOCATION );
-
- // Remove middle connection and repeat
- handler1.Reset();
- handler2.Reset();
- handler3.Reset();
- signals.SignalVoid1Value().Disconnect( &handler2, &TestSlotHandler::VoidSlotIntValue );
-
- signals.EmitVoidSignalIntValue( 6 );
- DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler1.mIntParam1, 6, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mIntParam1, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( handler3.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler3.mIntParam1, 6, TEST_LOCATION );
- }
-
- // Test that multiple callbacks are disconnected when a signal is destroyed
-
- TestSlotHandler handler4;
- TestSlotHandler handler5;
- TestSlotHandler handler6;
-
- {
- TestSignals::VoidRet1ValueParamSignal tempSignal;
-
- DALI_TEST_EQUALS( handler4.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( handler5.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( handler6.GetConnectionCount(), 0u, TEST_LOCATION );
-
- tempSignal.Connect( &handler4, &TestSlotHandler::VoidSlotIntValue );
- tempSignal.Connect( &handler5, &TestSlotHandler::VoidSlotIntValue );
- tempSignal.Connect( &handler6, &TestSlotHandler::VoidSlotIntValue );
-
- DALI_TEST_EQUALS( handler4.GetConnectionCount(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( handler5.GetConnectionCount(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( handler6.GetConnectionCount(), 1u, TEST_LOCATION );
- }
- // End of tempSignal lifetime
-
- DALI_TEST_EQUALS( handler4.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( handler5.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( handler6.GetConnectionCount(), 0u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliSignalMultipleConnections2(void)
-{
- TestSignals signals;
-
- // Test that connecting the same callback twice is a NOOP
- {
- TestSlotHandler handler1;
-
- // Note the double connection is intentional
- signals.SignalVoid1Value().Connect( &handler1, &TestSlotHandler::VoidSlotIntValue );
- signals.SignalVoid1Value().Connect( &handler1, &TestSlotHandler::VoidSlotIntValue );
- DALI_TEST_EQUALS( handler1.mHandledCount, 0, TEST_LOCATION );
-
- signals.EmitVoidSignalIntValue( 6 );
- DALI_TEST_EQUALS( handler1.mHandledCount, 1, TEST_LOCATION );
- DALI_TEST_EQUALS( handler1.mIntParam1, 6, TEST_LOCATION );
-
- // Calling Disconnect once should be enough
- signals.SignalVoid1Value().Disconnect( &handler1, &TestSlotHandler::VoidSlotIntValue );
- DALI_TEST_CHECK( signals.SignalVoid1Value().Empty() );
- handler1.mIntParam1 = 0;
-
- signals.EmitVoidSignalIntValue( 7 );
- DALI_TEST_EQUALS( handler1.mHandledCount, 1/*not incremented since last check*/, TEST_LOCATION );
- DALI_TEST_EQUALS( handler1.mIntParam1, 0, TEST_LOCATION );
- }
-
- // Test automatic disconnect after multiple Connect() calls
- {
- TestSlotHandler handler2;
- signals.SignalVoid1Value().Connect( &handler2, &TestSlotHandler::VoidSlotIntValue );
- signals.SignalVoid1Value().Connect( &handler2, &TestSlotHandler::VoidSlotIntValue );
-
- TestSlotHandler handler3;
- signals.SignalBool1Value().Connect( &handler3, &TestSlotHandler::BoolSlotFloatValue );
- signals.SignalBool1Value().Connect( &handler3, &TestSlotHandler::BoolSlotFloatValue );
-
- DALI_TEST_EQUALS( handler2.mHandledCount, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( handler3.mHandledCount, 0, TEST_LOCATION );
- DALI_TEST_CHECK( ! signals.SignalVoid1Value().Empty() );
- DALI_TEST_CHECK( ! signals.SignalBool1Value().Empty() );
- }
- DALI_TEST_CHECK( signals.SignalVoid1Value().Empty() );
- DALI_TEST_CHECK( signals.SignalBool1Value().Empty() );
-
- // Should be NOOP
- signals.EmitVoidSignalIntValue( 1 );
- signals.EmitBoolSignalFloatValue( 1.0f );
-
- // Test that connecting the same callback 10 times is a NOOP
- TestSlotHandler handler4;
- DALI_TEST_EQUALS( handler4.mHandledCount, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( handler4.mFloatParam1, 0.0f, TEST_LOCATION );
-
- signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
- signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
- signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
- signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
- signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
- signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
- signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
- signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
- signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
- signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
-
- signals.EmitBoolSignalFloatValue( 2.0f );
- DALI_TEST_EQUALS( handler4.mHandledCount, 1, TEST_LOCATION );
- DALI_TEST_EQUALS( handler4.mFloatParam1, 2.0f, TEST_LOCATION );
-
- // Calling Disconnect once should be enough
- signals.SignalBool1Value().Disconnect( &handler4, &TestSlotHandler::BoolSlotFloatValue );
- DALI_TEST_CHECK( signals.SignalBool1Value().Empty() );
-
- signals.EmitBoolSignalFloatValue( 3.0f );
- DALI_TEST_EQUALS( handler4.mHandledCount, 1/*not incremented since last check*/, TEST_LOCATION );
- DALI_TEST_EQUALS( handler4.mFloatParam1, 2.0f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliSignalMultipleConnections3(void)
-{
- TestSignals signals;
-
- // Test connecting two difference callbacks for the same ConnectionTracker
-
- TestSlotHandler handler1;
-
- {
- TestSignals::VoidRet1ValueParamSignal tempSignal;
-
- DALI_TEST_EQUALS( handler1.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( handler1.mHandledCount, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( handler1.mIntParam1, 0, TEST_LOCATION );
-
- // Note that the duplicate connection is deliberate
- tempSignal.Connect( &handler1, &TestSlotHandler::VoidSlotIntValue );
- tempSignal.Connect( &handler1, &TestSlotHandler::VoidDuplicateSlotIntValue );
-
- DALI_TEST_EQUALS( handler1.GetConnectionCount(), 2u, TEST_LOCATION );
- DALI_TEST_EQUALS( handler1.mHandledCount, 0, TEST_LOCATION );
-
- tempSignal.Emit( 10 );
-
- DALI_TEST_EQUALS( handler1.mHandledCount, 2, TEST_LOCATION );
- DALI_TEST_EQUALS( handler1.mIntParam1, 10, TEST_LOCATION );
- DALI_TEST_EQUALS( handler1.mIntParam2, 10, TEST_LOCATION );
- }
- // End of tempSignal lifetime
-
- DALI_TEST_EQUALS( handler1.GetConnectionCount(), 0u, TEST_LOCATION );
- END_TEST;
-}
-
-
-int UtcDaliSignalDisconnectStatic(void)
-{
- // void Func()
-
- {
- TestSignals::VoidRetNoParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
-
- signal.Connect( StaticVoidCallbackVoid );
- DALI_TEST_CHECK( ! signal.Empty() );
-
- wasStaticVoidCallbackVoidCalled = false;
- signal.Emit();
- DALI_TEST_EQUALS( wasStaticVoidCallbackVoidCalled, true, TEST_LOCATION );
-
- signal.Disconnect( StaticVoidCallbackVoid );
- DALI_TEST_CHECK( signal.Empty() );
-
- wasStaticVoidCallbackVoidCalled = false;
- signal.Emit();
- DALI_TEST_EQUALS( wasStaticVoidCallbackVoidCalled, false, TEST_LOCATION );
- }
-
- // float Func()
-
- {
- TestSignals::FloatRet0ParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
-
- signal.Connect( StaticFloatCallbackVoid );
- DALI_TEST_CHECK( ! signal.Empty() );
-
- wasStaticFloatCallbackVoidCalled = false;
- float result = signal.Emit();
- DALI_TEST_EQUALS( wasStaticFloatCallbackVoidCalled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( result, 7.0f, TEST_LOCATION );
-
- signal.Disconnect( StaticFloatCallbackVoid );
- DALI_TEST_CHECK( signal.Empty() );
-
- wasStaticFloatCallbackVoidCalled = false;
- result = signal.Emit();
- DALI_TEST_EQUALS( wasStaticFloatCallbackVoidCalled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( result, 0.0f, TEST_LOCATION );
- }
-
- // void Func( int )
-
- {
- TestSignals::VoidRet1ValueParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
-
- signal.Connect( StaticVoidCallbackIntValue );
- DALI_TEST_CHECK( ! signal.Empty() );
-
- wasStaticVoidCallbackIntValueCalled = false;
- staticIntValue = 0;
- signal.Emit( 10 );
- DALI_TEST_EQUALS( wasStaticVoidCallbackIntValueCalled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( staticIntValue, 10, TEST_LOCATION );
-
- signal.Disconnect( StaticVoidCallbackIntValue );
- DALI_TEST_CHECK( signal.Empty() );
-
- wasStaticVoidCallbackIntValueCalled = false;
- staticIntValue = 0;
- signal.Emit( 11 );
- DALI_TEST_EQUALS( wasStaticVoidCallbackIntValueCalled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( staticIntValue, 0, TEST_LOCATION );
- }
-
- // float Func( float, float )
-
- {
- TestSignals::FloatRet2ValueParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
-
- signal.Connect( StaticFloatCallbackFloatValueFloatValue );
- DALI_TEST_CHECK( ! signal.Empty() );
-
- wasStaticFloatCallbackFloatValueFloatValueCalled = false;
- staticFloatValue1 = 0.0f;
- staticFloatValue2 = 0.0f;
- float result = signal.Emit( 5.0f, 6.0f );
- DALI_TEST_EQUALS( wasStaticFloatCallbackFloatValueFloatValueCalled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( staticFloatValue1, 5.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( staticFloatValue2, 6.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( result, 5.0f+6.0f, TEST_LOCATION );
-
- signal.Disconnect( StaticFloatCallbackFloatValueFloatValue );
- DALI_TEST_CHECK( signal.Empty() );
-
- wasStaticFloatCallbackFloatValueFloatValueCalled = false;
- staticFloatValue1 = 0.0f;
- staticFloatValue2 = 0.0f;
- result = signal.Emit( 7.0f, 8.0f );
- DALI_TEST_EQUALS( wasStaticFloatCallbackFloatValueFloatValueCalled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( staticFloatValue1, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( staticFloatValue2, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( result, 0.0f, TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliSignalDisconnectDuringCallback(void)
-{
- // Test disconnection during each callback
-
- TestSignals::VoidRetNoParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
-
- TestSlotDisconnector handler1;
- handler1.VoidConnectVoid( signal );
- DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
- DALI_TEST_CHECK( ! signal.Empty() );
-
- signal.Emit();
- DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
- DALI_TEST_CHECK( signal.Empty() );
-
- // Repeat with 2 callbacks
-
- handler1.mHandled = false;
-
- TestSlotDisconnector handler2;
- handler1.VoidConnectVoid( signal );
- handler2.VoidConnectVoid( signal );
- DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
- DALI_TEST_CHECK( ! signal.Empty() );
-
- signal.Emit();
- DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION );
- DALI_TEST_CHECK( signal.Empty() );
-
- // Repeat with no callbacks
-
- handler1.mHandled = false;
- handler2.mHandled = false;
-
- signal.Emit();
- DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
-
- // Repeat with 3 callbacks
-
- TestSlotDisconnector handler3;
- handler1.VoidConnectVoid( signal );
- handler2.VoidConnectVoid( signal );
- handler3.VoidConnectVoid( signal );
- DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler3.mHandled, false, TEST_LOCATION );
- DALI_TEST_CHECK( ! signal.Empty() );
-
- signal.Emit();
- DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler3.mHandled, true, TEST_LOCATION );
- DALI_TEST_CHECK( signal.Empty() );
-
- // Repeat with no callbacks
-
- handler1.mHandled = false;
- handler2.mHandled = false;
- handler3.mHandled = false;
-
- signal.Emit();
- DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler3.mHandled, false, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliSignalDisconnectDuringCallback2(void)
-{
- // Test disconnection of some (but not all) callbacks during sigmal emission
-
- TestSignals::VoidRetNoParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
-
- TestSlotMultiDisconnector handler;
- handler.ConnectAll( signal );
- DALI_TEST_EQUALS( handler.mSlotHandled[0], false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[1], false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[2], false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[3], false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[4], false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[5], false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[6], false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[7], false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[8], false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[9], false, TEST_LOCATION );
- DALI_TEST_CHECK( ! signal.Empty() );
-
- signal.Emit();
-
- // Slots 5, 7, & 9 should be disconnected before being called
- DALI_TEST_EQUALS( handler.mSlotHandled[0], true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[1], true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[2], true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[3], true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[4], true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[5], false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[6], true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[7], false, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[8], true, TEST_LOCATION );
- DALI_TEST_EQUALS( handler.mSlotHandled[9], false, TEST_LOCATION );
- DALI_TEST_CHECK( ! signal.Empty() );
-
- // Odd slots are disconnected
- DALI_TEST_EQUALS( handler.GetConnectionCount(), 5u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliSignalEmitDuringCallback(void)
-{
- TestApplication app; // Create core for debug logging
-
- TestSignals::VoidRetNoParamSignal signal;
- DALI_TEST_CHECK( signal.Empty() );
-
- TestEmitDuringCallback handler1;
- handler1.VoidConnectVoid( signal );
-
- // Test that this does not result in an infinite loop!
- signal.Emit();
- END_TEST;
-}
-
-int UtcDaliSignalTestApp01(void)
-{
- // Test 1 signal connected to 1 Slot.
- // Signal dies first.
-
- TestButton* button = new TestButton(1);
- TestApp app;
- button->DownSignal().Connect(&app,&TestApp::OnButtonPress);
-
- // check we have both the button, and the app have 1 connection
- DALI_TEST_EQUALS( app.GetConnectionCount(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( button->DownSignal().GetConnectionCount(), 1u, TEST_LOCATION );
-
- delete button; // should automatically destroy the connection
-
- // check we have a 0 connections
- DALI_TEST_EQUALS( app.GetConnectionCount(), 0u, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliSignalTestApp02(void)
-{
- // Test 1 signal connected to 1 Slot.
- // Slot owning object dies first.
-
- TestButton button(1);
- TestApp *app = new TestApp;
- button.DownSignal().Connect( app, &TestApp::OnButtonPress);
-
- // check we have a 1 connection
- DALI_TEST_EQUALS( app->GetConnectionCount(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 1u, TEST_LOCATION );
-
- delete app; // should automatically destroy the connection
-
- // check we have a 0 connections
- DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 0u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliSignalTestApp03(void)
-{
- // Test 1 Signal connect to 2 slots
- // 1 of the slot owners dies. Then the second slot owner dies
-
- TestButton button(1);
- TestApp *app1 = new TestApp;
- TestApp *app2 = new TestApp;
-
- button.DownSignal().Connect( app1, &TestApp::OnButtonPress);
- button.DownSignal().Connect( app2, &TestApp::OnButtonPress);
-
- // check we have a 2 connections to the signal
- DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 2u, TEST_LOCATION );
-
- // kill the first slot
- delete app1; // should automatically destroy the connection
-
- // check we have 1 connection left
- DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 1u, TEST_LOCATION );
-
- button.Press(); // emit the signal (to ensure it doesn't seg fault)
-
- // kill the second slot
- delete app2; // should automatically destroy the connection
-
- // check we have 1 connection left
- DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 0u, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliSignalTestApp04(void)
-{
- // Test 1 Signal connected to 2 slots (with different owners)
- // The Signal dies, check the 2 slots disconnect automatically
-
- TestButton* button = new TestButton(1);
- TestApp app1;
- TestApp app2;
-
- button->DownSignal().Connect(&app1,&TestApp::OnButtonPress);
- button->DownSignal().Connect(&app2,&TestApp::OnButtonPress);
-
- // check the connection counts
- DALI_TEST_EQUALS( app1.GetConnectionCount(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( app2.GetConnectionCount(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( button->DownSignal().GetConnectionCount(), 2u, TEST_LOCATION );
-
- delete button; // should automatically destroy the connection
-
- // check both slot owners have zero connections
- DALI_TEST_EQUALS( app1.GetConnectionCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( app2.GetConnectionCount(), 0u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliSignalTestApp05(void)
-{
- // Test 2 Signals (with different owners) connected to 1 slots
- // 1 Signal dies, check that the remaining connection is valid
-
- TestButton* button1 = new TestButton(1); // use for signal 1
- TestButton* button2 = new TestButton(2); // use for signal 2
-
- TestApp app;
-
- button1->DownSignal().Connect(&app,&TestApp::OnButtonPress);
- button2->DownSignal().Connect(&app,&TestApp::OnButtonPress);
-
- // check the connection counts
- DALI_TEST_EQUALS( app.GetConnectionCount(), 2u, TEST_LOCATION );
- DALI_TEST_EQUALS( button1->DownSignal().GetConnectionCount(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( button2->DownSignal().GetConnectionCount(), 1u, TEST_LOCATION );
-
- // make sure both signals emit ok
- button2->Press();
- DALI_TEST_EQUALS( app.GetButtonPressedId() , 2 , TEST_LOCATION );
-
- button1->Press();
- DALI_TEST_EQUALS( app.GetButtonPressedId() , 1 , TEST_LOCATION );
-
- delete button1; // should automatically destroy 1 connection
-
- // check both slot owners have zero connections
- DALI_TEST_EQUALS( app.GetConnectionCount(), 1u, TEST_LOCATION );
-
- // check remaining connection still works
- button2->Press();
- DALI_TEST_EQUALS( app.GetButtonPressedId() , 2 , TEST_LOCATION );
-
- // kill the last signal
- delete button2;
- DALI_TEST_EQUALS( app.GetConnectionCount(), 0u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliSignalTestApp06(void)
-{
- SignalV2< bool () > boolSignal;
- TestApp app;
- bool result(false);
-
- // connect a slot which will return false
- boolSignal.Connect( &app, &TestApp::BoolReturnTestFalse);
- result = boolSignal.Emit();
- DALI_TEST_EQUALS( result, false, TEST_LOCATION );
-
- // disconnect last slot, and connect a slot which returns true
- boolSignal.Disconnect( &app, &TestApp::BoolReturnTestFalse);
- boolSignal.Connect( &app, &TestApp::BoolReturnTestTrue);
- result = boolSignal.Emit();
- DALI_TEST_EQUALS( result, true, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliSlotDelegateConnection(void)
-{
- TestSignals signals;
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalVoidNone().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotVoid );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- signals.EmitVoidSignalVoid();
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
-
- // Test double emission
- handlers.mHandled = false;
- signals.EmitVoidSignalVoid();
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalVoid1Ref().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntRef );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- int x = 7;
- signals.EmitVoidSignalIntRef(x);
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 7, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalVoid1Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValue );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- signals.EmitVoidSignalIntValue(5);
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 5, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalVoid2Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValueIntValue );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- signals.EmitVoidSignalIntValueIntValue(6, 7);
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 6, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam2, 7, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalBool1Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValue );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
-
- handlers.mBoolReturn = true;
- DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
-
- // repeat with opposite return value
- handlers.mBoolReturn = false;
- handlers.mHandled = false;
- DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(6.0f), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 6.0f, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalBool2Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValueIntValue );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mBoolReturn = true;
- DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam2, 10, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalInt2Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::IntSlotFloatValueIntValue );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mIntReturn = 27;
- int x = signals.EmitIntSignalFloatValueIntValue(33.5f, 5);
- DALI_TEST_EQUALS( x, 27, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 33.5f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam2, 5, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalFloat0().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotVoid );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mFloatReturn = 27.0f;
- float f = signals.EmitFloat0Signal();
- DALI_TEST_EQUALS( f, 27.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalFloat2Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValueFloatValue );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mFloatReturn = 27.0f;
- float f = signals.EmitFloat2VSignal(5, 33.0f);
- DALI_TEST_EQUALS( f, 27.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotDelegateHandler handlers;
- signals.VoidSignalFloatValue3().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotFloatValue3 );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- signals.EmitVoidSignalFloatValue3(5, 33.0f, 100.0f);
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam3, 100.0f, 0.001f, TEST_LOCATION );
- }
- signals.CheckNoConnections();
-
- {
- TestSlotDelegateHandler handlers;
- signals.FloatSignalFloatValue3().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValue3 );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mFloatReturn = 27.0f;
- float returnValue = signals.EmitFloatSignalFloatValue3(5, 33.0f, 100.0f);
- DALI_TEST_EQUALS( returnValue, 27.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam3, 100.0f, 0.001f, TEST_LOCATION );
- }
- signals.CheckNoConnections();
- END_TEST;
-}
-
-int UtcDaliSignalSlotDelegateDestruction(void)
-{
- // Test that signal disconnect works when slot-delegate is destroyed (goes out of scope)
-
- {
- TestSignals::VoidRetNoParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotDelegateHandler handler;
- signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotVoid );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- signal.Emit();
- }
-
- {
- TestSignals::VoidRet1ValueParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotDelegateHandler handler;
- signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- signal.Emit( 10 );
- }
-
- {
- TestSignals::VoidRet1RefParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotDelegateHandler handler;
- signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntRef );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- int temp( 5 );
- signal.Emit( temp );
- }
-
- {
- TestSignals::VoidRet2ValueParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotDelegateHandler handler;
- signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValueIntValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- signal.Emit( 1, 2 );
- }
-
- {
- TestSignals::BoolRet1ValueParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotDelegateHandler handler;
- signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- bool blah = signal.Emit( 1.0f );
- DALI_TEST_CHECK( ! blah );
- }
-
- {
- TestSignals::BoolRet2ValueParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotDelegateHandler handler;
- signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValueIntValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- bool blah = signal.Emit( 1.0f, 2 );
- DALI_TEST_CHECK( ! blah );
- }
-
- {
- TestSignals::IntRet2ValueParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotDelegateHandler handler;
- signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::IntSlotFloatValueIntValue );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- int blah = signal.Emit( 10.0f, 100 );
- DALI_TEST_CHECK( 0 == blah );
- }
-
- {
- TestSignals::FloatRet0ParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotDelegateHandler handler;
- signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotVoid );
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- float blah = signal.Emit();
- DALI_TEST_CHECK( 0.0f == blah );
- }
-
- {
- TestSignals::FloatRet2ValueParamSignal signal;
- {
- DALI_TEST_CHECK( signal.Empty() );
- TestSlotDelegateHandler handler;
- signal.Connect(handler.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValueFloatValue);
- DALI_TEST_CHECK( ! signal.Empty() );
- }
- // End of slot lifetime
- DALI_TEST_CHECK( signal.Empty() );
-
- // Signal emission should be a NOOP
- float blah = signal.Emit( 3.0f, 4.0f );
- DALI_TEST_CHECK( 0.0f == blah );
- }
- END_TEST;
-}
-
-int UtcDaliSlotHandlerDisconnect(void)
-{
- // Test that callbacks don't occur if a signal is disconnected before emission
-
- TestSignals signals;
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalVoidNone().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotVoid);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- signals.SignalVoidNone().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotVoid);
- signals.EmitVoidSignalVoid();
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- }
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalVoid1Ref().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntRef);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- int r = 7;
- handlers.mIntReturn = 5;
- signals.SignalVoid1Ref().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntRef);
- signals.EmitVoidSignalIntRef(r);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( r, 7, TEST_LOCATION );
- }
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalVoid1Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- signals.SignalVoid1Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValue);
- signals.EmitVoidSignalIntValue(5);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
- }
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalVoid2Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValueIntValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- signals.SignalVoid2Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValueIntValue);
- signals.EmitVoidSignalIntValueIntValue(5, 10);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION );
- }
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalBool1Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mBoolReturn = true;
- signals.SignalBool1Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValue);
- DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
- }
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalBool2Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValueIntValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mBoolReturn = true;
- signals.SignalBool2Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValueIntValue);
- DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION );
- }
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalInt2Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::IntSlotFloatValueIntValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mIntReturn = 27;
- signals.SignalInt2Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::IntSlotFloatValueIntValue);
- signals.EmitIntSignalFloatValueIntValue(5, 33.0f);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
- }
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalFloat0().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotVoid);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mFloatReturn = 27.0f;
- signals.SignalFloat0().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotVoid);
- signals.EmitFloat0Signal();
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
- }
-
- {
- TestSlotDelegateHandler handlers;
- signals.SignalFloat2Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValueFloatValue);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- handlers.mFloatReturn = 27.0f;
- signals.SignalFloat2Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValueFloatValue);
- signals.EmitFloat2VSignal(5, 33.0f);
- DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION );
- DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION );
- }
- END_TEST;
-}
// Emit signal for application developer
- if( !mSetSizeSignalV2.Empty() )
+ if( !mSetSizeSignal.Empty() )
{
Dali::Actor handle( this );
- mSetSizeSignalV2.Emit( handle, mSize );
+ mSetSizeSignal.Emit( handle, mSize );
}
}
}
bool Actor::GetTouchRequired() const
{
- return !mTouchedSignalV2.Empty() || mDerivedRequiresTouch;
+ return !mTouchedSignal.Empty() || mDerivedRequiresTouch;
}
bool Actor::GetHoverRequired() const
{
- return !mHoveredSignalV2.Empty() || mDerivedRequiresHover;
+ return !mHoveredSignal.Empty() || mDerivedRequiresHover;
}
bool Actor::GetMouseWheelEventRequired() const
{
- return !mMouseWheelEventSignalV2.Empty() || mDerivedRequiresMouseWheelEvent;
+ return !mMouseWheelEventSignal.Empty() || mDerivedRequiresMouseWheelEvent;
}
bool Actor::IsHittable() const
{
bool consumed = false;
- if ( !mTouchedSignalV2.Empty() )
+ if ( !mTouchedSignal.Empty() )
{
Dali::Actor handle( this );
- consumed = mTouchedSignalV2.Emit( handle, event );
+ consumed = mTouchedSignal.Emit( handle, event );
}
if (!consumed)
{
bool consumed = false;
- if ( !mHoveredSignalV2.Empty() )
+ if ( !mHoveredSignal.Empty() )
{
Dali::Actor handle( this );
- consumed = mHoveredSignalV2.Emit( handle, event );
+ consumed = mHoveredSignal.Emit( handle, event );
}
if (!consumed)
{
bool consumed = false;
- if ( !mMouseWheelEventSignalV2.Empty() )
+ if ( !mMouseWheelEventSignal.Empty() )
{
Dali::Actor handle( this );
- consumed = mMouseWheelEventSignalV2.Emit( handle, event );
+ consumed = mMouseWheelEventSignal.Emit( handle, event );
}
if (!consumed)
return consumed;
}
-Dali::Actor::TouchSignalV2& Actor::TouchedSignal()
+Dali::Actor::TouchSignalType& Actor::TouchedSignal()
{
- return mTouchedSignalV2;
+ return mTouchedSignal;
}
-Dali::Actor::HoverSignalV2& Actor::HoveredSignal()
+Dali::Actor::HoverSignalType& Actor::HoveredSignal()
{
- return mHoveredSignalV2;
+ return mHoveredSignal;
}
-Dali::Actor::MouseWheelEventSignalV2& Actor::MouseWheelEventSignal()
+Dali::Actor::MouseWheelEventSignalType& Actor::MouseWheelEventSignal()
{
- return mMouseWheelEventSignalV2;
+ return mMouseWheelEventSignal;
}
-Dali::Actor::SetSizeSignalV2& Actor::SetSizeSignal()
+Dali::Actor::SetSizeSignalType& Actor::SetSizeSignal()
{
- return mSetSizeSignalV2;
+ return mSetSizeSignal;
}
-Dali::Actor::OnStageSignalV2& Actor::OnStageSignal()
+Dali::Actor::OnStageSignalType& Actor::OnStageSignal()
{
- return mOnStageSignalV2;
+ return mOnStageSignal;
}
-Dali::Actor::OffStageSignalV2& Actor::OffStageSignal()
+Dali::Actor::OffStageSignalType& Actor::OffStageSignal()
{
- return mOffStageSignalV2;
+ return mOffStageSignal;
}
bool Actor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
// Notification for external (CustomActor) derived classes
OnStageConnectionExternal();
- if ( !mOnStageSignalV2.Empty() )
+ if ( !mOnStageSignal.Empty() )
{
Dali::Actor handle( this );
- mOnStageSignalV2.Emit( handle );
+ mOnStageSignal.Emit( handle );
}
// Guard against Remove during callbacks
// Notification for external (CustomeActor) derived classes
OnStageDisconnectionExternal();
- if( !mOffStageSignalV2.Empty() )
+ if( !mOffStageSignal.Empty() )
{
Dali::Actor handle( this );
- mOffStageSignalV2.Emit( handle );
+ mOffStageSignal.Emit( handle );
}
// Guard against Add during callbacks
/**
* @copydoc Dali::Actor::TouchedSignal()
*/
- Dali::Actor::TouchSignalV2& TouchedSignal();
+ Dali::Actor::TouchSignalType& TouchedSignal();
/**
* @copydoc Dali::Actor::HoveredSignal()
*/
- Dali::Actor::HoverSignalV2& HoveredSignal();
+ Dali::Actor::HoverSignalType& HoveredSignal();
/**
* @copydoc Dali::Actor::MouseWheelEventSignal()
*/
- Dali::Actor::MouseWheelEventSignalV2& MouseWheelEventSignal();
+ Dali::Actor::MouseWheelEventSignalType& MouseWheelEventSignal();
/**
* @copydoc Dali::Actor::SetSizeSignal()
*/
- Dali::Actor::SetSizeSignalV2& SetSizeSignal();
+ Dali::Actor::SetSizeSignalType& SetSizeSignal();
/**
* @copydoc Dali::Actor::OnStageSignal()
*/
- Dali::Actor::OnStageSignalV2& OnStageSignal();
+ Dali::Actor::OnStageSignalType& OnStageSignal();
/**
* @copydoc Dali::Actor::OffStageSignal()
*/
- Dali::Actor::OffStageSignalV2& OffStageSignal();
+ Dali::Actor::OffStageSignalType& OffStageSignal();
/**
* Connects a callback function with the object's signals.
ActorAttachmentPtr mAttachment; ///< Optional referenced attachment
// Signals
- Dali::Actor::TouchSignalV2 mTouchedSignalV2;
- Dali::Actor::HoverSignalV2 mHoveredSignalV2;
- Dali::Actor::MouseWheelEventSignalV2 mMouseWheelEventSignalV2;
- Dali::Actor::SetSizeSignalV2 mSetSizeSignalV2;
- Dali::Actor::OnStageSignalV2 mOnStageSignalV2;
- Dali::Actor::OffStageSignalV2 mOffStageSignalV2;
+ Dali::Actor::TouchSignalType mTouchedSignal;
+ Dali::Actor::HoverSignalType mHoveredSignal;
+ Dali::Actor::MouseWheelEventSignalType mMouseWheelEventSignal;
+ Dali::Actor::SetSizeSignalType mSetSizeSignal;
+ Dali::Actor::OnStageSignalType mOnStageSignal;
+ Dali::Actor::OffStageSignalType mOffStageSignal;
Vector3 mSize; ///< Event-side storage for size (not a pointer as most actors will have a size)
// emit text available signal
- mLoadingFinishedV2.Emit( Dali::TextActor( this ) );
+ mLoadingFinished.Emit( Dali::TextActor( this ) );
return true;
}
/**
* @copydoc Dali::TextActor::TextAvailableSignal()
*/
- Dali::TextActor::TextSignalV2& TextAvailableSignal() { return mLoadingFinishedV2; }
+ Dali::TextActor::TextSignalType& TextAvailableSignal() { return mLoadingFinished; }
/**
* Connects a callback function with the text actors signals.
private:
- Dali::TextActor::TextSignalV2 mLoadingFinishedV2;
+ Dali::TextActor::TextSignalType mLoadingFinished;
bool mUsingNaturalSize:1; ///< whether the actor is using natural size
bool mInternalSetSize:1; ///< to determine when we are internally setting size
bool mFontDetection:1; ///< tells whether TextActor should query platform abstraction after SetText
return currentWeight;
}
-ActiveConstraintSignalV2& ActiveConstraintBase::AppliedSignal()
+ActiveConstraintSignalType& ActiveConstraintBase::AppliedSignal()
{
return mAppliedSignal;
}
/**
* @copydoc Dali::ActiveConstraint::AppliedSignal()
*/
- ActiveConstraintSignalV2& AppliedSignal();
+ ActiveConstraintSignalType& AppliedSignal();
/**
* @copydoc Dali::Constraint::SetAlphaFunction()
private:
- ActiveConstraintSignalV2 mAppliedSignal;
+ ActiveConstraintSignalType mAppliedSignal;
Dali::Animation mApplyAnimation; ///< Used to automatically animate weight from 0.0f -> 1.0f
return hasFinished;
}
-Dali::Animation::AnimationSignalV2& Animation::FinishedSignal()
+Dali::Animation::AnimationSignalType& Animation::FinishedSignal()
{
return mFinishedSignal;
}
/**
* @copydoc Dali::Animation::FinishedSignal()
*/
- Dali::Animation::AnimationSignalV2& FinishedSignal();
+ Dali::Animation::AnimationSignalType& FinishedSignal();
/**
* Emit the Finished signal
int mNotificationCount; ///< Keep track of how many Finished signals have been emitted.
- Dali::Animation::AnimationSignalV2 mFinishedSignal;
+ Dali::Animation::AnimationSignalType mFinishedSignal;
FinishedCallback mFinishedCallback;
Object* mFinishedCallbackObject;
void ObjectRegistry::RegisterObject( Dali::BaseObject* object )
{
- if ( !mObjectCreatedSignalV2.Empty() )
+ if ( !mObjectCreatedSignal.Empty() )
{
Dali::BaseHandle handle( object );
- mObjectCreatedSignalV2.Emit( handle );
+ mObjectCreatedSignal.Emit( handle );
}
}
void ObjectRegistry::UnregisterObject( Dali::BaseObject* object )
{
- mObjectDestroyedSignalV2.Emit( object );
+ mObjectDestroyedSignal.Emit( object );
}
bool ObjectRegistry::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
/**
* @copydoc Dali::ObjectRegistry::ObjectCreatedSignal()
*/
- Dali::ObjectRegistry::ObjectCreatedSignalV2& ObjectCreatedSignal()
+ Dali::ObjectRegistry::ObjectCreatedSignalType& ObjectCreatedSignal()
{
- return mObjectCreatedSignalV2;
+ return mObjectCreatedSignal;
}
/**
* @copydoc Dali::ObjectRegistry::ObjectDestroyedSignal()
*/
- Dali::ObjectRegistry::ObjectDestroyedSignalV2& ObjectDestroyedSignal()
+ Dali::ObjectRegistry::ObjectDestroyedSignalType& ObjectDestroyedSignal()
{
- return mObjectDestroyedSignalV2;
+ return mObjectDestroyedSignal;
}
/**
private:
- Dali::ObjectRegistry::ObjectCreatedSignalV2 mObjectCreatedSignalV2;
- Dali::ObjectRegistry::ObjectDestroyedSignalV2 mObjectDestroyedSignalV2;
+ Dali::ObjectRegistry::ObjectCreatedSignalType mObjectCreatedSignal;
+ Dali::ObjectRegistry::ObjectDestroyedSignalType mObjectDestroyedSignal;
};
}
}
-Dali::PropertyNotifySignalV2& PropertyNotification::NotifySignal()
+Dali::PropertyNotifySignalType& PropertyNotification::NotifySignal()
{
return mNotifySignal;
}
/**
* @copydoc Dali::PropertyNotification::NotifySignal()
*/
- Dali::PropertyNotifySignalV2& NotifySignal();
+ Dali::PropertyNotifySignalType& NotifySignal();
/**
* Emit the Notify signal
SceneGraph::UpdateManager& mUpdateManager;
const SceneGraph::PropertyNotification* mPropertyNotification;
- Dali::PropertyNotifySignalV2 mNotifySignal;
+ Dali::PropertyNotifySignalType mNotifySignal;
private:
{
// Emit the key event signal when no actor in the stage has gained the key input focus
- mKeyEventSignalV2.Emit( event );
+ mKeyEventSignal.Emit( event );
}
void Stage::EmitEventProcessingFinishedSignal()
{
- mEventProcessingFinishedSignalV2.Emit();
+ mEventProcessingFinishedSignal.Emit();
}
void Stage::EmitTouchedSignal( const TouchEvent& touch )
{
- mTouchedSignalV2.Emit( touch );
+ mTouchedSignal.Emit( touch );
}
mSceneCreatedSignal.Emit();
}
-Dali::Stage::KeyEventSignalV2& Stage::KeyEventSignal()
+Dali::Stage::KeyEventSignalType& Stage::KeyEventSignal()
{
- return mKeyEventSignalV2;
+ return mKeyEventSignal;
}
-Dali::Stage::EventProcessingFinishedSignalV2& Stage::EventProcessingFinishedSignal()
+Dali::Stage::EventProcessingFinishedSignalType& Stage::EventProcessingFinishedSignal()
{
- return mEventProcessingFinishedSignalV2;
+ return mEventProcessingFinishedSignal;
}
-Dali::Stage::TouchedSignalV2& Stage::TouchedSignal()
+Dali::Stage::TouchedSignalType& Stage::TouchedSignal()
{
- return mTouchedSignalV2;
+ return mTouchedSignal;
}
Dali::Stage::ContextStatusSignal& Stage::ContextLostSignal()
return mContextRegainedSignal;
}
-Dali::Stage::SceneCreatedSignalV2& Stage::SceneCreatedSignal()
+Dali::Stage::SceneCreatedSignalType& Stage::SceneCreatedSignal()
{
return mSceneCreatedSignal;
}
/**
* @copydoc Dali::Stage::KeyEventSignal()
*/
- Dali::Stage::KeyEventSignalV2& KeyEventSignal();
+ Dali::Stage::KeyEventSignalType& KeyEventSignal();
/**
* @copydoc Dali::Stage::SignalEventProcessingFinished()
*/
- Dali::Stage::EventProcessingFinishedSignalV2& EventProcessingFinishedSignal();
+ Dali::Stage::EventProcessingFinishedSignalType& EventProcessingFinishedSignal();
/**
* @copydoc Dali::Stage::TouchedSignal()
*/
- Dali::Stage::TouchedSignalV2& TouchedSignal();
+ Dali::Stage::TouchedSignalType& TouchedSignal();
/**
* @copydoc Dali::Stage::ContextLostSignal()
/**
* @copydoc Dali::Stage::SceneCreatedSignal()
*/
- Dali::Stage::SceneCreatedSignalV2& SceneCreatedSignal();
+ Dali::Stage::SceneCreatedSignalType& SceneCreatedSignal();
private: // Implementation of ContextNotificationInterface:
Integration::SystemOverlay* mSystemOverlay; ///< SystemOverlay stage access
// The key event signal
- Dali::Stage::KeyEventSignalV2 mKeyEventSignalV2;
+ Dali::Stage::KeyEventSignalType mKeyEventSignal;
// The event processing finished signal
- Dali::Stage::EventProcessingFinishedSignalV2 mEventProcessingFinishedSignalV2;
+ Dali::Stage::EventProcessingFinishedSignalType mEventProcessingFinishedSignal;
// The touched signal
- Dali::Stage::TouchedSignalV2 mTouchedSignalV2;
+ Dali::Stage::TouchedSignalType mTouchedSignal;
Dali::Stage::ContextStatusSignal mContextLostSignal;
Dali::Stage::ContextStatusSignal mContextRegainedSignal;
- Dali::Stage::SceneCreatedSignalV2 mSceneCreatedSignal;
+ Dali::Stage::SceneCreatedSignalType mSceneCreatedSignal;
};
} // namespace Internal
{
bool connected( false );
- ConnectorContainerV2::iterator iter = find_if( mSignalConnectors.begin(), mSignalConnectors.end(),
- PairFinder<std::string, ConnectionPairV2>(signalName) );
+ ConnectorContainer::iterator iter = find_if( mSignalConnectors.begin(), mSignalConnectors.end(),
+ PairFinder<std::string, ConnectionPair>(signalName) );
if( iter != mSignalConnectors.end() )
{
void TypeInfo::GetSignals(Dali::TypeInfo::NameContainer& ret) const
{
- for(ConnectorContainerV2::const_iterator iter = mSignalConnectors.begin(); iter != mSignalConnectors.end(); ++iter)
+ for(ConnectorContainer::const_iterator iter = mSignalConnectors.begin(); iter != mSignalConnectors.end(); ++iter)
{
ret.push_back(iter->first);
}
Dali::TypeInfo base = Dali::TypeRegistry::Get().GetTypeInfo( mBaseTypeName );
while( base )
{
- for(ConnectorContainerV2::const_iterator iter = GetImplementation(base).mSignalConnectors.begin();
+ for(ConnectorContainer::const_iterator iter = GetImplementation(base).mSignalConnectors.begin();
iter != GetImplementation(base).mSignalConnectors.end(); ++iter)
{
ret.push_back(iter->first);
}
}
-void TypeInfo::AddConnectorFunction( const std::string& signalName, Dali::TypeInfo::SignalConnectorFunctionV2 function )
+void TypeInfo::AddConnectorFunction( const std::string& signalName, Dali::TypeInfo::SignalConnectorFunction function )
{
if( NULL == function)
{
}
else
{
- ConnectorContainerV2::iterator iter = find_if( mSignalConnectors.begin(), mSignalConnectors.end(),
- PairFinder<std::string, ConnectionPairV2>(signalName) );
+ ConnectorContainer::iterator iter = find_if( mSignalConnectors.begin(), mSignalConnectors.end(),
+ PairFinder<std::string, ConnectionPair>(signalName) );
if( iter == mSignalConnectors.end() )
{
- mSignalConnectors.push_back( ConnectionPairV2( signalName, function ) );
+ mSignalConnectors.push_back( ConnectionPair( signalName, function ) );
}
else
{
* @param[in] signalName The name of the signal.
* @param[in] function The function used for connecting to the signal.
*/
- void AddConnectorFunction( const std::string& signalName, Dali::TypeInfo::SignalConnectorFunctionV2 function );
+ void AddConnectorFunction( const std::string& signalName, Dali::TypeInfo::SignalConnectorFunction function );
/**
* Adds an event-thread only property to the type.
std::string name;
};
- typedef std::pair<std::string, Dali::TypeInfo::SignalConnectorFunctionV2 > ConnectionPairV2;
+ typedef std::pair<std::string, Dali::TypeInfo::SignalConnectorFunction > ConnectionPair;
typedef std::pair<std::string, Dali::TypeInfo::ActionFunction > ActionPair;
typedef std::pair<Property::Index, RegisteredProperty> RegisteredPropertyPair;
typedef std::vector< ActionPair > ActionContainer;
- typedef std::vector< ConnectionPairV2 > ConnectorContainerV2;
+ typedef std::vector< ConnectionPair > ConnectorContainer;
typedef std::vector< RegisteredPropertyPair > RegisteredPropertyContainer;
std::string mTypeName;
std::string mBaseTypeName;
Dali::TypeInfo::CreateFunction mCreate;
ActionContainer mActions;
- ConnectorContainerV2 mSignalConnectors;
+ ConnectorContainer mSignalConnectors;
RegisteredPropertyContainer mRegisteredProperties;
};
return DemangleClassName( registerType.name() );
}
-void TypeRegistry::RegisterSignal( TypeRegistration& typeRegistration, const std::string& name, Dali::TypeInfo::SignalConnectorFunctionV2 func )
+void TypeRegistry::RegisterSignal( TypeRegistration& typeRegistration, const std::string& name, Dali::TypeInfo::SignalConnectorFunction func )
{
RegistryMap::iterator iter = mRegistryLut.find( typeRegistration.RegisteredName() );
* @param [in] name Signal name
* @param [in] func Signal connector function
*/
- void RegisterSignal( TypeRegistration& typeRegistration, const std::string& name, Dali::TypeInfo::SignalConnectorFunctionV2 func );
+ void RegisterSignal( TypeRegistration& typeRegistration, const std::string& name, Dali::TypeInfo::SignalConnectorFunction func );
/*
* Register an action function to a type
SetRootActorMessage( Stage::GetCurrent()->GetUpdateInterface(), *mDynamicsWorld, static_cast<const SceneGraph::Node*>(NULL) );
}
-Dali::DynamicsWorld::CollisionSignalV2& DynamicsWorld::CollisionSignal()
+Dali::DynamicsWorld::CollisionSignalType& DynamicsWorld::CollisionSignal()
{
- return mCollisionSignalV2;
+ return mCollisionSignal;
}
void DynamicsWorld::CollisionImpact( Integration::DynamicsCollisionData* collisionData )
DALI_ASSERT_DEBUG(collisionData->mBodyA);
DALI_ASSERT_DEBUG(collisionData->mBodyB);
- if ( !mCollisionSignalV2.Empty() )
+ if ( !mCollisionSignal.Empty() )
{
BodyContainer::iterator it = mBodies.begin();
BodyContainer::iterator endIt = mBodies.end();
Dali::DynamicsCollision collisionHandle( collision.Get() );
Dali::DynamicsWorld worldHandle( this );
- mCollisionSignalV2.Emit( worldHandle, collisionHandle );
+ mCollisionSignal.Emit( worldHandle, collisionHandle );
break;
}
DALI_ASSERT_DEBUG(collisionData->mBodyA);
DALI_ASSERT_DEBUG(collisionData->mBodyB);
- if ( !mCollisionSignalV2.Empty() )
+ if ( !mCollisionSignal.Empty() )
{
BodyContainer::iterator it = mBodies.begin();
BodyContainer::iterator endIt = mBodies.end();
Dali::DynamicsCollision collisionHandle( collision.Get() );
Dali::DynamicsWorld worldHandle( this );
- mCollisionSignalV2.Emit( worldHandle, collisionHandle );
+ mCollisionSignal.Emit( worldHandle, collisionHandle );
break;
}
const Vector3& GetGravity() const;
/// @copydoc Dali::DynamicsWorld::CollisionSignal
- Dali::DynamicsWorld::CollisionSignalV2& CollisionSignal();
+ Dali::DynamicsWorld::CollisionSignalType& CollisionSignal();
/// @copydoc Dali::DynamicsWorld::GetDebugDrawMode
int GetDebugDrawMode() const;
BodyContainer mBodies;
ActorPtr mRootActor;
- Dali::DynamicsWorld::CollisionSignalV2 mCollisionSignalV2;
+ Dali::DynamicsWorld::CollisionSignalType mCollisionSignal;
SlotDelegate< DynamicsWorld > mSlotDelegate;
};
// Guard against destruction during signal emission
Dali::LongPressGestureDetector handle( this );
- mDetectedSignalV2.Emit( pressedActor, longPress );
+ mDetectedSignal.Emit( pressedActor, longPress );
}
bool LongPressGestureDetector::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
/**
* @copydoc Dali::LongPressGestureDetector::DetectedSignal()
*/
- Dali::LongPressGestureDetector::DetectedSignalV2& DetectedSignal()
+ Dali::LongPressGestureDetector::DetectedSignalType& DetectedSignal()
{
- return mDetectedSignalV2;
+ return mDetectedSignal;
}
/**
private:
- Dali::LongPressGestureDetector::DetectedSignalV2 mDetectedSignalV2;
+ Dali::LongPressGestureDetector::DetectedSignalType mDetectedSignal;
unsigned int mMinimumTouchesRequired;
unsigned int mMaximumTouchesRequired;
void PanGestureDetector::EmitPanGestureSignal(Dali::Actor actor, const PanGesture& pan)
{
- if ( !mDetectedSignalV2.Empty() )
+ if ( !mDetectedSignal.Empty() )
{
// Guard against destruction during signal emission
Dali::PanGestureDetector handle( this );
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Emitting Signal (%p)\n", this );
- mDetectedSignalV2.Emit( actor, pan );
+ mDetectedSignal.Emit( actor, pan );
}
}
/**
* @copydoc Dali::PanGestureDetector::DetectedSignal()
*/
- Dali::PanGestureDetector::DetectedSignalV2& DetectedSignal()
+ Dali::PanGestureDetector::DetectedSignalType& DetectedSignal()
{
- return mDetectedSignalV2;
+ return mDetectedSignal;
}
/**
private:
- Dali::PanGestureDetector::DetectedSignalV2 mDetectedSignalV2;
+ Dali::PanGestureDetector::DetectedSignalType mDetectedSignal;
unsigned int mMinimumTouches; ///< The minimum number of fingers required to be touching for pan.
unsigned int mMaximumTouches; ///< The maximum number of fingers required to be touching for pan.
// Guard against destruction during signal emission
Dali::PinchGestureDetector handle( this );
- mDetectedSignalV2.Emit( actor, pinch );
+ mDetectedSignal.Emit( actor, pinch );
}
bool PinchGestureDetector::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
/**
* @copydoc Dali::PinchGestureDetector::DetectedSignal()
*/
- Dali::PinchGestureDetector::DetectedSignalV2& DetectedSignal()
+ Dali::PinchGestureDetector::DetectedSignalType& DetectedSignal()
{
- return mDetectedSignalV2;
+ return mDetectedSignal;
}
/**
private:
- Dali::PinchGestureDetector::DetectedSignalV2 mDetectedSignalV2;
+ Dali::PinchGestureDetector::DetectedSignalType mDetectedSignal;
};
} // namespace Internal
// Guard against destruction during signal emission
Dali::TapGestureDetector handle( this );
- mDetectedSignalV2.Emit( tappedActor, tap );
+ mDetectedSignal.Emit( tappedActor, tap );
}
bool TapGestureDetector::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
/**
* @copydoc Dali::TapGestureDetector::DetectedSignal()
*/
- Dali::TapGestureDetector::DetectedSignalV2& DetectedSignal()
+ Dali::TapGestureDetector::DetectedSignalType& DetectedSignal()
{
- return mDetectedSignalV2;
+ return mDetectedSignal;
}
/**
private:
- Dali::TapGestureDetector::DetectedSignalV2 mDetectedSignalV2;
+ Dali::TapGestureDetector::DetectedSignalType mDetectedSignal;
unsigned int mTapsRequired;
unsigned int mTouchesRequired;
void Image::ResourceLoadingFailed(const ResourceTicket& ticket)
{
- mLoadingFinishedV2.Emit( Dali::Image( this ) );
+ mLoadingFinished.Emit( Dali::Image( this ) );
}
void Image::ResourceLoadingSucceeded(const ResourceTicket& ticket)
{
- mLoadingFinishedV2.Emit( Dali::Image( this ) );
+ mLoadingFinished.Emit( Dali::Image( this ) );
}
void Image::ResourceUploaded(const ResourceTicket& ticket)
{
- mUploadedV2.Emit( Dali::Image( this ) );
+ mUploaded.Emit( Dali::Image( this ) );
}
void Image::ResourceSavingSucceeded( const ResourceTicket& ticket )
/**
* @copydoc Dali::Image::LoadingFinishedSignal()
*/
- Dali::Image::ImageSignalV2& LoadingFinishedSignal() { return mLoadingFinishedV2; }
+ Dali::Image::ImageSignalType& LoadingFinishedSignal() { return mLoadingFinished; }
/**
* @copydoc Dali::Image::UploadedSignal()
*/
- Dali::Image::ImageSignalV2& UploadedSignal() { return mUploadedV2; }
+ Dali::Image::ImageSignalType& UploadedSignal() { return mUploaded; }
/**
* Connects a callback function with the object's signals.
private:
- Dali::Image::ImageSignalV2 mLoadingFinishedV2;
- Dali::Image::ImageSignalV2 mUploadedV2;
+ Dali::Image::ImageSignalType mLoadingFinished;
+ Dali::Image::ImageSignalType mUploaded;
// Changes scope, should be at end of class
DALI_LOG_OBJECT_STRING_DECLARATION;
{
DALI_LOG_TRACE_METHOD(Debug::Filter::gModel);
- mLoadingFinishedV2.Emit( Dali::Model( this ) );
+ mLoadingFinished.Emit( Dali::Model( this ) );
}
void Model::ResourceLoadingSucceeded(const ResourceTicket& ticket)
ModelDataPtr modelData = resourceManager.GetModelData( GetResourceId() );
modelData->Unpack( *mResourceClient );
- mLoadingFinishedV2.Emit( Dali::Model( this ) );
+ mLoadingFinished.Emit( Dali::Model( this ) );
}
void Model::ResourceUploaded(const ResourceTicket& ticket)
{
DALI_LOG_TRACE_METHOD(Debug::Filter::gModel);
- mSavingFinishedV2.Emit( Dali::Model( this ), false );
+ mSavingFinished.Emit( Dali::Model( this ), false );
}
void Model::ResourceSavingSucceeded(const ResourceTicket& ticket)
{
DALI_LOG_TRACE_METHOD(Debug::Filter::gModel);
- mSavingFinishedV2.Emit( Dali::Model( this ), true );
+ mSavingFinished.Emit( Dali::Model( this ), true );
}
ResourceId Model::GetResourceId() const
/**
* @copydoc Dali::Model::LoadingFinishedSignal()
*/
- Dali::Model::ModelSignalV2& LoadingFinishedSignal()
+ Dali::Model::ModelSignalType& LoadingFinishedSignal()
{
- return mLoadingFinishedV2;
+ return mLoadingFinished;
};
/**
* @copydoc Dali::Model::SavingFinishedSignal()
*/
- Dali::Model::ModelSaveSignalV2& SavingFinishedSignal()
+ Dali::Model::ModelSaveSignalType& SavingFinishedSignal()
{
- return mSavingFinishedV2;
+ return mSavingFinished;
};
/**
ResourceTicketPtr mTicket;
- Dali::Model::ModelSignalV2 mLoadingFinishedV2;
- Dali::Model::ModelSaveSignalV2 mSavingFinishedV2;
+ Dali::Model::ModelSignalType mLoadingFinished;
+ Dali::Model::ModelSaveSignalType mSavingFinished;
ResourceClient* mResourceClient;
};
{
DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::EmitSignalFinish(this:%p)\n", this);
- if( !mSignalFinishedV2.Empty() )
+ if( !mSignalFinished.Empty() )
{
Dali::RenderTask handle( this );
- mSignalFinishedV2.Emit(handle );
+ mSignalFinished.Emit(handle );
}
}
-Dali::RenderTask::RenderTaskSignalV2& RenderTask::FinishedSignal()
+Dali::RenderTask::RenderTaskSignalType& RenderTask::FinishedSignal()
{
- return mSignalFinishedV2;
+ return mSignalFinished;
}
bool RenderTask::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
/**
* @copydoc Dali::RenderTask::FinishedSignal()
*/
- Dali::RenderTask::RenderTaskSignalV2& FinishedSignal();
+ Dali::RenderTask::RenderTaskSignalType& FinishedSignal();
/**
* Connects a callback function with the object's signals.
bool mIsSystemLevel : 1; ///< True if the render-task is on the system level task list.
//Signals
- Dali::RenderTask::RenderTaskSignalV2 mSignalFinishedV2; ///< Signal emmited when the render task has been processed.
+ Dali::RenderTask::RenderTaskSignalType mSignalFinished; ///< Signal emmited when the render task has been processed.
};
} // namespace Internal
return GetImplementation(*this).IsKeyboardFocusable();
}
-Actor::TouchSignalV2& Actor::TouchedSignal()
+Actor::TouchSignalType& Actor::TouchedSignal()
{
return GetImplementation(*this).TouchedSignal();
}
-Actor::HoverSignalV2& Actor::HoveredSignal()
+Actor::HoverSignalType& Actor::HoveredSignal()
{
return GetImplementation(*this).HoveredSignal();
}
-Actor::MouseWheelEventSignalV2& Actor::MouseWheelEventSignal()
+Actor::MouseWheelEventSignalType& Actor::MouseWheelEventSignal()
{
return GetImplementation(*this).MouseWheelEventSignal();
}
-Actor::SetSizeSignalV2& Actor::SetSizeSignal()
+Actor::SetSizeSignalType& Actor::SetSizeSignal()
{
return GetImplementation(*this).SetSizeSignal();
}
-Actor::OnStageSignalV2& Actor::OnStageSignal()
+Actor::OnStageSignalType& Actor::OnStageSignal()
{
return GetImplementation(*this).OnStageSignal();
}
-Actor::OffStageSignalV2& Actor::OffStageSignal()
+Actor::OffStageSignalType& Actor::OffStageSignal()
{
return GetImplementation(*this).OffStageSignal();
}
#include <dali/public-api/actors/actor-enumerations.h>
#include <dali/public-api/actors/draw-mode.h>
#include <dali/public-api/object/constrainable.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
// Typedefs
- typedef SignalV2< bool (Actor, const TouchEvent&)> TouchSignalV2; ///< Touch signal type
- typedef SignalV2< bool (Actor, const HoverEvent&)> HoverSignalV2; ///< Hover signal type
- typedef SignalV2< bool (Actor, const MouseWheelEvent&) > MouseWheelEventSignalV2;///< Mousewheel signal type
- typedef SignalV2< void (Actor, const Vector3&) > SetSizeSignalV2; ///< SetSize signal type
- typedef SignalV2< void (Actor) > OnStageSignalV2; ///< Stage connection signal type
- typedef SignalV2< void (Actor) > OffStageSignalV2; ///< Stage disconnection signal type
+ typedef Signal< bool (Actor, const TouchEvent&)> TouchSignalType; ///< Touch signal type
+ typedef Signal< bool (Actor, const HoverEvent&)> HoverSignalType; ///< Hover signal type
+ typedef Signal< bool (Actor, const MouseWheelEvent&) > MouseWheelEventSignalType;///< Mousewheel signal type
+ typedef Signal< void (Actor, const Vector3&) > SetSizeSignalType; ///< SetSize signal type
+ typedef Signal< void (Actor) > OnStageSignalType; ///< Stage connection signal type
+ typedef Signal< void (Actor) > OffStageSignalType; ///< Stage disconnection signal type
/// @name Properties
/** @{ */
* @pre The Actor has been initialized.
* @return The signal to connect to.
*/
- TouchSignalV2& TouchedSignal();
+ TouchSignalType& TouchedSignal();
/**
* @brief This signal is emitted when hover input is received.
* @pre The Actor has been initialized.
* @return The signal to connect to.
*/
- HoverSignalV2& HoveredSignal();
+ HoverSignalType& HoveredSignal();
/**
* @brief This signal is emitted when mouse wheel event is received.
* @pre The Actor has been initialized.
* @return The signal to connect to.
*/
- MouseWheelEventSignalV2& MouseWheelEventSignal();
+ MouseWheelEventSignalType& MouseWheelEventSignal();
/**
* @brief Signal to indicate when the actor's size is set by application code.
* @pre The Actor has been initialized.
* @return The signal to connect to.
*/
- SetSizeSignalV2& SetSizeSignal();
+ SetSizeSignalType& SetSizeSignal();
/**
* @brief This signal is emitted after the actor has been connected to the stage.
*
* @return The signal
*/
- OnStageSignalV2& OnStageSignal();
+ OnStageSignalType& OnStageSignal();
/**
* @brief This signal is emitted after the actor has been disconnected from the stage.
*
* @return The signal
*/
- OffStageSignalV2& OffStageSignal();
+ OffStageSignalType& OffStageSignal();
public: // Dynamics
{
public:
- typedef SignalV2< void (TextActor) > TextSignalV2; ///< Text available signal type
+ typedef Signal< void (TextActor) > TextSignalType; ///< Text available signal type
//Signal Names
static const char* const SIGNAL_TEXT_LOADING_FINISHED; ///< name "text-loading-finished"
*
* @return A signal object to Connect() with.
*/
- TextSignalV2& TextAvailableSignal();
+ TextSignalType& TextAvailableSignal();
public: // Not intended for use by Application developers
// INTERNAL INCLUDES
#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
class ActiveConstraint;
-typedef SignalV2< void (ActiveConstraint& constraint) > ActiveConstraintSignalV2;
+typedef Signal< void (ActiveConstraint& constraint) > ActiveConstraintSignalType;
typedef boost::function<void (ActiveConstraint& constraint)> ActiveConstraintCallbackType;
return GetImplementation(*this).GetCurrentWeight();
}
-ActiveConstraintSignalV2& ActiveConstraint::AppliedSignal()
+ActiveConstraintSignalType& ActiveConstraint::AppliedSignal()
{
return GetImplementation(*this).AppliedSignal();
}
* @note A non-zero apply-time must have been set using Constraint::SetApplyTime().
* @return A signal object to Connect() with.
*/
- ActiveConstraintSignalV2& AppliedSignal();
+ ActiveConstraintSignalType& AppliedSignal();
public: // Not intended for use by Application developers
GetImplementation(*this).Clear();
}
-Animation::AnimationSignalV2& Animation::FinishedSignal()
+Animation::AnimationSignalType& Animation::FinishedSignal()
{
return GetImplementation(*this).FinishedSignal();
}
#include <dali/public-api/object/any.h>
#include <dali/public-api/object/handle.h>
#include <dali/public-api/object/property.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
{
public:
- typedef SignalV2< void (Animation&) > AnimationSignalV2; ///< Animation finished signal type
+ typedef Signal< void (Animation&) > AnimationSignalType; ///< Animation finished signal type
typedef Any AnyFunction; ///< Interpolation function
*
* @return A signal object to Connect() with.
*/
- AnimationSignalV2& FinishedSignal();
+ AnimationSignalType& FinishedSignal();
/**
* @brief Animate a property value by a relative amount.
GetImplementation(*this).KeepRendering( durationSeconds );
}
-Stage::KeyEventSignalV2& Stage::KeyEventSignal()
+Stage::KeyEventSignalType& Stage::KeyEventSignal()
{
return GetImplementation(*this).KeyEventSignal();
}
-Stage::EventProcessingFinishedSignalV2& Stage::EventProcessingFinishedSignal()
+Stage::EventProcessingFinishedSignalType& Stage::EventProcessingFinishedSignal()
{
return GetImplementation(*this).EventProcessingFinishedSignal();
}
-Stage::TouchedSignalV2& Stage::TouchedSignal()
+Stage::TouchedSignalType& Stage::TouchedSignal()
{
return GetImplementation(*this).TouchedSignal();
}
return GetImplementation(*this).ContextRegainedSignal();
}
-Stage::SceneCreatedSignalV2& Stage::SceneCreatedSignal()
+Stage::SceneCreatedSignalType& Stage::SceneCreatedSignal()
{
return GetImplementation(*this).SceneCreatedSignal();
}
// INTERNAL INCLUDES
#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
{
public:
- typedef SignalV2< void (const KeyEvent&)> KeyEventSignalV2; ///< Key event signal type
- typedef SignalV2< void () > EventProcessingFinishedSignalV2; ///< Event Processing finished signal type
- typedef SignalV2< void (const TouchEvent&)> TouchedSignalV2; ///< Touched signal type
- typedef SignalV2< void () > ContextStatusSignal; ///< Context status signal type
- typedef SignalV2< void () > SceneCreatedSignalV2; ///< Scene created signal type
+ typedef Signal< void (const KeyEvent&)> KeyEventSignalType; ///< Key event signal type
+ typedef Signal< void () > EventProcessingFinishedSignalType; ///< Event Processing finished signal type
+ typedef Signal< void (const TouchEvent&)> TouchedSignalType; ///< Touched signal type
+ typedef Signal< void () > ContextStatusSignal; ///< Context status signal type
+ typedef Signal< void () > SceneCreatedSignalType; ///< Scene created signal type
static const Vector4 DEFAULT_BACKGROUND_COLOR; ///< Default black background.
static const Vector4 DEBUG_BACKGROUND_COLOR; ///< Green background, useful when debugging.
* @endcode
* @return The signal to connect to.
*/
- KeyEventSignalV2& KeyEventSignal();
+ KeyEventSignalType& KeyEventSignal();
/**
* @brief This signal is emitted just after the event processing is finished.
*
* @return The signal to connect to.
*/
- EventProcessingFinishedSignalV2& EventProcessingFinishedSignal();
+ EventProcessingFinishedSignalType& EventProcessingFinishedSignal();
/**
* @brief This signal is emitted when the screen is touched and when the touch ends
* @note Motion events are not emitted.
* @return The touch signal to connect to.
*/
- TouchedSignalV2& TouchedSignal();
+ TouchedSignalType& TouchedSignal();
/**
* @brief This signal is emitted when the GL context is lost (Platform specific behaviour).
* @endcode
* @return The signal to connect to.
*/
- SceneCreatedSignalV2& SceneCreatedSignal();
+ SceneCreatedSignalType& SceneCreatedSignal();
public: // Not intended for application developers
#include <dali/public-api/signals/callback.h>
#include <dali/public-api/signals/connection-tracker-interface.h>
#include <dali/public-api/signals/connection-tracker.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
#include <dali/public-api/signals/functor-delegate.h>
#include <dali/public-api/signals/signal-slot-connections.h>
#include <dali/public-api/signals/signal-slot-observers.h>
{
#ifndef DYNAMICS_SUPPORT
-DynamicsWorld::CollisionSignalV2 STUB_COLLISION_SIGNAL;
+DynamicsWorld::CollisionSignalType STUB_COLLISION_SIGNAL;
#endif
const char* const DynamicsWorld::SIGNAL_COLLISION = "collision";
#endif
}
-DynamicsWorld::CollisionSignalV2& DynamicsWorld::CollisionSignal()
+DynamicsWorld::CollisionSignalType& DynamicsWorld::CollisionSignal()
{
#ifdef DYNAMICS_SUPPORT
return GetImplementation(*this).CollisionSignal();
#include <dali/public-api/object/base-handle.h>
// INTERNAL INCLUDES
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
static const char* const SIGNAL_COLLISION; ///< name "collision"
// signals
- typedef SignalV2< void (DynamicsWorld, const DynamicsCollision) > CollisionSignalV2; ///< Type of collision signal
+ typedef Signal< void (DynamicsWorld, const DynamicsCollision) > CollisionSignalType; ///< Type of collision signal
public:
/**
*
* @return The signal to connect to.
*/
- CollisionSignalV2& CollisionSignal();
+ CollisionSignalType& CollisionSignal();
public: // Not intended for application developers
return GetImplementation(*this).GetMaximumTouchesRequired();
}
-LongPressGestureDetector::DetectedSignalV2& LongPressGestureDetector::DetectedSignal()
+LongPressGestureDetector::DetectedSignalType& LongPressGestureDetector::DetectedSignal()
{
return GetImplementation(*this).DetectedSignal();
}
// INTERNAL INCLUDES
#include <dali/public-api/events/gesture-detector.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
{
public: // Typedefs
- typedef SignalV2< void ( Actor, const LongPressGesture& ) > DetectedSignalV2; ///< Gesture detected signal type
+ typedef Signal< void ( Actor, const LongPressGesture& ) > DetectedSignalType; ///< Gesture detected signal type
//Signal Names
static const char* const SIGNAL_LONG_PRESS_DETECTED; ///< name "long-press-detected"
* @pre The gesture detector has been initialized.
* @return The signal to connect to.
*/
- DetectedSignalV2& DetectedSignal();
+ DetectedSignalType& DetectedSignal();
public: // Not intended for Application developers
GetImplementation(*this).RemoveDirection( direction );
}
-PanGestureDetector::DetectedSignalV2& PanGestureDetector::DetectedSignal()
+PanGestureDetector::DetectedSignalType& PanGestureDetector::DetectedSignal()
{
return GetImplementation(*this).DetectedSignal();
}
// INTERNAL INCLUDES
#include <dali/public-api/events/gesture-detector.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
public:
// Typedefs
- typedef SignalV2< void ( Actor, const PanGesture& ) > DetectedSignalV2; ///< Pan gesture detected signal type
+ typedef Signal< void ( Actor, const PanGesture& ) > DetectedSignalType; ///< Pan gesture detected signal type
// Directional Pan
typedef std::pair< Radian, Radian > AngleThresholdPair; ///< Range of angles for a direction
* @pre The gesture detector has been initialized.
* @return The signal to connect to.
*/
- DetectedSignalV2& DetectedSignal();
+ DetectedSignalType& DetectedSignal();
public: // Pan Properties Setters
return *this;
}
-PinchGestureDetector::DetectedSignalV2& PinchGestureDetector::DetectedSignal()
+PinchGestureDetector::DetectedSignalType& PinchGestureDetector::DetectedSignal()
{
return GetImplementation(*this).DetectedSignal();
}
// INTERNAL INCLUDES
#include <dali/public-api/events/gesture-detector.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
/**
* @brief Signal type.
*/
- typedef SignalV2< void ( Actor, const PinchGesture& ) > DetectedSignalV2;
+ typedef Signal< void ( Actor, const PinchGesture& ) > DetectedSignalType;
//Signal Names
static const char* const SIGNAL_PINCH_DETECTED; ///< name "pinch-detected"
* @pre The gesture detector has been initialized.
* @return The signal to connect to.
*/
- DetectedSignalV2& DetectedSignal();
+ DetectedSignalType& DetectedSignal();
public: // Not intended for Application developers
return GetImplementation(*this).GetTouchesRequired();
}
-TapGestureDetector::DetectedSignalV2& TapGestureDetector::DetectedSignal()
+TapGestureDetector::DetectedSignalType& TapGestureDetector::DetectedSignal()
{
return GetImplementation(*this).DetectedSignal();
}
// INTERNAL INCLUDES
#include <dali/public-api/events/gesture-detector.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
/**
* @brief Signal type for detected signal.
*/
- typedef SignalV2< void ( Actor, const TapGesture& ) > DetectedSignalV2;
+ typedef Signal< void ( Actor, const TapGesture& ) > DetectedSignalType;
//Signal Names
static const char* const SIGNAL_TAP_DETECTED; ///< name "tap-detected"
* @pre The gesture detector has been initialized.
* @return The signal to connect to.
*/
- DetectedSignalV2& DetectedSignal();
+ DetectedSignalType& DetectedSignal();
public: // Not intended for Application developers
$(public_api_src_dir)/signals/callback.h \
$(public_api_src_dir)/signals/connection-tracker-interface.h \
$(public_api_src_dir)/signals/connection-tracker.h \
- $(public_api_src_dir)/signals/dali-signal-v2.h \
+ $(public_api_src_dir)/signals/dali-signal.h \
$(public_api_src_dir)/signals/functor-delegate.h \
$(public_api_src_dir)/signals/signal-slot-connections.h \
$(public_api_src_dir)/signals/signal-slot-observers.h \
GetImplementation(*this).Reload();
}
-Image::ImageSignalV2& Image::LoadingFinishedSignal()
+Image::ImageSignalType& Image::LoadingFinishedSignal()
{
return GetImplementation(*this).LoadingFinishedSignal();
}
-Image::ImageSignalV2& Image::UploadedSignal()
+Image::ImageSignalType& Image::UploadedSignal()
{
return GetImplementation(*this).UploadedSignal();
}
#include <dali/public-api/common/loading-state.h>
#include <dali/public-api/images/pixel.h>
#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
/**
* @brief Type of signal for LoadingFinished and Uploaded.
*/
- typedef SignalV2< void (Image) > ImageSignalV2;
+ typedef Signal< void (Image) > ImageSignalType;
// Signal Names
static const char* const SIGNAL_IMAGE_LOADING_FINISHED; ///< Name of LoadingFinished signal
*
* @return A signal object to Connect() with.
*/
- ImageSignalV2& LoadingFinishedSignal();
+ ImageSignalType& LoadingFinishedSignal();
/**
* @brief This signal is emitted when the image data gets uploaded to GL.
* BitmapImage calls Update().
* @return A signal object to Connect() with.
*/
- ImageSignalV2& UploadedSignal();
+ ImageSignalType& UploadedSignal();
public: // Not intended for application developers
return GetImplementation(*this).GetLoadingState();
}
-Model::ModelSignalV2& Model::LoadingFinishedSignal()
+Model::ModelSignalType& Model::LoadingFinishedSignal()
{
return GetImplementation(*this).LoadingFinishedSignal();
}
-Model::ModelSaveSignalV2& Model::SavingFinishedSignal()
+Model::ModelSaveSignalType& Model::SavingFinishedSignal()
{
return GetImplementation(*this).SavingFinishedSignal();
}
// INTERNAL INCLUDES
#include <dali/public-api/common/loading-state.h>
#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
{
public:
- typedef SignalV2<void (Model)> ModelSignalV2; ///< Signal type
- typedef SignalV2<void (Model,bool)> ModelSaveSignalV2; ///< Signal type for saving models
+ typedef Signal<void (Model)> ModelSignalType; ///< Signal type
+ typedef Signal<void (Model,bool)> ModelSaveSignalType; ///< Signal type for saving models
//Signal Names
static const char* const SIGNAL_MODEL_LOADING_FINISHED; ///< name "model-loading-finished"
*
* @return A signal object to Connect() with.
*/
- ModelSignalV2& LoadingFinishedSignal();
+ ModelSignalType& LoadingFinishedSignal();
/**
* @brief Emitted when the model data save request completes.
*
* @return A signal object to Connect() with.
*/
- ModelSaveSignalV2& SavingFinishedSignal();
+ ModelSaveSignalType& SavingFinishedSignal();
/**
* @brief Get number of animations in the model.
return *this;
}
-ObjectRegistry::ObjectCreatedSignalV2& ObjectRegistry::ObjectCreatedSignal()
+ObjectRegistry::ObjectCreatedSignalType& ObjectRegistry::ObjectCreatedSignal()
{
return GetImplementation(*this).ObjectCreatedSignal();
}
-ObjectRegistry::ObjectDestroyedSignalV2& ObjectRegistry::ObjectDestroyedSignal()
+ObjectRegistry::ObjectDestroyedSignalType& ObjectRegistry::ObjectDestroyedSignal()
{
return GetImplementation(*this).ObjectDestroyedSignal();
}
// INTERNAL INCLUDES
#include <dali/public-api/object/handle.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
/**
* @brief Object created signal
*/
- typedef SignalV2< void (BaseHandle) > ObjectCreatedSignalV2;
+ typedef Signal< void (BaseHandle) > ObjectCreatedSignalType;
/**
* @brief Object destroyed signal
*/
- typedef SignalV2< void (const Dali::RefObject*) > ObjectDestroyedSignalV2;
+ typedef Signal< void (const Dali::RefObject*) > ObjectDestroyedSignalType;
/**
* @brief Allows the creation of an empty objectRegistry handle.
* @pre The Object has been initialized.
* @return The signal to connect to.
*/
- ObjectCreatedSignalV2& ObjectCreatedSignal();
+ ObjectCreatedSignalType& ObjectCreatedSignal();
/**
* @brief This signal is emitted when an object is destroyed.
* @pre The Object has been initialized.
* @return The signal to connect to.
*/
- ObjectDestroyedSignalV2& ObjectDestroyedSignal();
+ ObjectDestroyedSignalType& ObjectDestroyedSignal();
public: // Not intended for application developers
// INTERNAL INCLUDES
#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
/**
* @brief Signal type for Dali::PropertyNotification::NotifySignal().
*/
-typedef SignalV2< void (PropertyNotification& source) > PropertyNotifySignalV2;
+typedef Signal< void (PropertyNotification& source) > PropertyNotifySignalType;
/**
* @brief Function signature for Dali::PropertyNotification::NotifySignal() signal callbacks.
return GetImplementation(*this).GetNotifyResult();
}
-PropertyNotifySignalV2& PropertyNotification::NotifySignal()
+PropertyNotifySignalType& PropertyNotification::NotifySignal()
{
return GetImplementation(*this).NotifySignal();
}
*
* @return A signal object to Connect() with.
*/
- PropertyNotifySignalV2& NotifySignal();
+ PropertyNotifySignalType& NotifySignal();
public: // Not intended for use by Application developers
* @return True if the signal was connected.
* @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
*/
- typedef bool (*SignalConnectorFunctionV2)(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
+ typedef bool (*SignalConnectorFunction)(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
/**
* @brief Callback to set an event-thread only property.
return mName;
}
-SignalConnectorType::SignalConnectorType( TypeRegistration& typeRegistration, const std::string& name, TypeInfo::SignalConnectorFunctionV2 func )
+SignalConnectorType::SignalConnectorType( TypeRegistration& typeRegistration, const std::string& name, TypeInfo::SignalConnectorFunction func )
{
Internal::TypeRegistry::Get()->RegisterSignal( typeRegistration, name, func );
}
* @param [in] name The signal name
* @param [in] func The signal connector function
*/
- SignalConnectorType( TypeRegistration& typeRegistration, const std::string& name, TypeInfo::SignalConnectorFunctionV2 func );
+ SignalConnectorType( TypeRegistration& typeRegistration, const std::string& name, TypeInfo::SignalConnectorFunction func );
};
/**
return GetImplementation(*this).GetRefreshRate();
}
-RenderTask::RenderTaskSignalV2& RenderTask::FinishedSignal()
+RenderTask::RenderTaskSignalType& RenderTask::FinishedSignal()
{
return GetImplementation(*this).FinishedSignal();
}
// INTERNAL INCLUDES
#include <dali/public-api/math/viewport.h>
#include <dali/public-api/object/constrainable.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
{
/**
* @brief Typedef for signals sent by this class.
*/
- typedef SignalV2< void (RenderTask& source) > RenderTaskSignalV2;
+ typedef Signal< void (RenderTask& source) > RenderTaskSignalType;
// Default Properties
static const Property::Index VIEWPORT_POSITION; ///< Property 0, name "viewport-position", type VECTOR2
/**
* @brief If the refresh rate is REFRESH_ONCE, connect to this signal to be notified when a RenderTask has finished.
*/
- RenderTaskSignalV2& FinishedSignal();
+ RenderTaskSignalType& FinishedSignal();
public: // Not intended for application developers
{
/**
- * @brief Implementation class for Dali::SignalV2%s.
+ * @brief Implementation class for Dali::Signal.
*
* A slot can be connected to many signals
* A signal can be connected to many slots
+++ /dev/null
-#ifndef __DALI_SIGNAL_V2_H__
-#define __DALI_SIGNAL_V2_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * The class should implement Dali::ConnectionTrackerInterface, or inherit from Dali::ConnectionTracker.
- * This enforces automatic disconnection when an object is destroyed, so you don't have
- * to manually disconnect from signals.
- *
- * Alternatively, you can use a Dali::SlotDelegate if you don't want to inherit.
- *
- * E.g:
- * @code
- * class MyClass : public ConnectionTracker
- * {
- *
- * void Callback( Actor actor, const TouchEvent& event )
- * {
- * ...
- * }
- *
- * void Init()
- * {
- * Actor actor = Actor::New();
- *
- * actor.TouchedSignal().Connect( this, &MyClass::Callback );
- * }
- *
- * ~MyClass()
- * {
- * // ConnectionTracker base class automatically disconnects
- * }
- * }
- * @endcode
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/signals/callback.h>
-#include <dali/public-api/signals/signal-slot-connections.h>
-#include <dali/public-api/signals/slot-delegate.h>
-#include <dali/public-api/signals/base-signal.h>
-
-namespace Dali
-{
-
-/**
- * @brief Base Template class to provide signals.
- */
-template< typename _Signature >
-class SignalV2
-{
-};
-
-/**
- * @brief A template for Signals with no parameters or return value.
- */
-template <>
-class SignalV2< void () >
-{
-public:
-
- /**
- * @brief Default constructor.
- */
- SignalV2()
- {
- }
-
- /**
- * @brief Non-virtual destructor.
- */
- ~SignalV2()
- {
- }
-
- /**
- * @brief Query whether there are any connected slots.
- *
- * @return True if there are any slots connected to the signal.
- */
- bool Empty() const
- {
- return mImpl.Empty();
- }
-
- /**
- * @brief Query the number of slots.
- *
- * @return The number of slots connected to this signal.
- */
- std::size_t GetConnectionCount() const
- {
- return mImpl.GetConnectionCount();
- }
-
- /**
- * @brief Connect a function.
- *
- * @param[in] func The function to connect.
- */
- void Connect( void (*func)() )
- {
- mImpl.OnConnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Disconnect a function.
- *
- * @param[in] func The function to disconnect.
- */
- void Disconnect( void (*func)() )
- {
- mImpl.OnDisconnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( X* obj, void (X::*func)() )
- {
- mImpl.OnConnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( X* obj, void (X::*func)() )
- {
- mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( SlotDelegate<X>& delegate, void (X::*func)() )
- {
- mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( SlotDelegate<X>& delegate, void (X::*func)() )
- {
- mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Connect a function object.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] func The function object to copy.
- */
- template<class X>
- void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctor0< X >( func ) );
- }
-
- /**
- * @brief Connect a function object using FunctorDelegate.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
- */
- void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate0( delegate ) );
- }
-
- /**
- * @brief Emit the signal.
- */
- void Emit()
- {
- mImpl.Emit();
- }
-
-private:
-
- SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
- SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
-
-private:
-
- // Use composition instead of inheritance (virtual methods don't mix well with templates)
- BaseSignal mImpl; ///< The base signal implementation
-};
-
-/**
- * @brief A template for Signals with no parameters and a return value.
- */
-template < typename Ret >
-class SignalV2< Ret() >
-{
-public:
-
- /**
- * @brief Default constructor.
- */
- SignalV2()
- {
- }
-
- /**
- * @brief Non-virtual destructor.
- */
- ~SignalV2()
- {
- }
-
- /**
- * @brief Query whether there are any connected slots.
- *
- * @return True if there are any slots connected to the signal.
- */
- bool Empty() const
- {
- return mImpl.Empty();
- }
-
- /**
- * @brief Query the number of slots.
- *
- * @return The number of slots connected to this signal.
- */
- std::size_t GetConnectionCount() const
- {
- return mImpl.GetConnectionCount();
- }
- /**
- * @brief Connect a function.
- *
- * @param[in] func The function to connect.
- */
- void Connect( Ret (*func)() )
- {
- mImpl.OnConnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Disconnect a function.
- *
- * @param[in] func The function to disconnect.
- */
- void Disconnect( Ret (*func)() )
- {
- mImpl.OnDisconnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( X* obj, Ret (X::*func)() )
- {
- mImpl.OnConnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( X* obj, Ret (X::*func)() )
- {
- mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( SlotDelegate<X>& delegate, Ret (X::*func)() )
- {
- mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)() )
- {
- mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Connect a function object.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] func The function object to copy.
- */
- template<class X>
- void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn0< X, Ret >( func ) );
- }
-
- /**
- * @brief Connect a function object using FunctorDelegate.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
- */
- void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn0< Ret >( delegate ) );
- }
-
- /**
- * @brief Emit the signal.
- *
- * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
- */
- Ret Emit()
- {
- return mImpl.EmitReturn< Ret >();
- }
-
-private:
-
- SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
- SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
-
-private:
-
- // Use composition instead of inheritance (virtual methods don't mix well with templates)
- BaseSignal mImpl; ///< Implementation
-};
-
-/**
- * @brief A template for Signals with 1 parameter.
- */
-template < typename Arg0 >
-class SignalV2< void ( Arg0 ) >
-{
-public:
-
- /**
- * @brief Default constructor.
- */
- SignalV2()
- {
- }
-
- /**
- * @brief Non-virtual destructor.
- */
- ~SignalV2()
- {
- }
-
- /**
- * @brief Query whether there are any connected slots.
- *
- * @return True if there are any slots connected to the signal.
- */
- bool Empty() const
- {
- return mImpl.Empty();
- }
-
- /**
- * @brief Query the number of slots.
- *
- * @return The number of slots connected to this signal.
- */
- std::size_t GetConnectionCount() const
- {
- return mImpl.GetConnectionCount();
- }
- /**
- * @brief Connect a function.
- *
- * @param[in] func The function to connect.
- */
- void Connect( void (*func)( Arg0 arg0 ) )
- {
- mImpl.OnConnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Disconnect a function.
- *
- * @param[in] func The function to disconnect.
- */
- void Disconnect( void (*func)( Arg0 arg0 ) )
- {
- mImpl.OnDisconnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( X* obj, void (X::*func)( Arg0 arg0 ) )
- {
- mImpl.OnConnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( X* obj, void (X::*func)( Arg0 arg0 ) )
- {
- mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0 ) )
- {
- mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0 ) )
- {
- mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Connect a function object.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] func The function object to copy.
- */
- template<class X>
- void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctor1< X, Arg0 >( func ) );
- }
-
- /**
- * @brief Connect a function object using FunctorDelegate.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
- */
- void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate1< Arg0 >( delegate ) );
- }
-
- /**
- * @brief Emit the signal.
- *
- * @param[in] arg0 The first value to pass to callbacks.
- */
- void Emit( Arg0 arg0 )
- {
- mImpl.Emit< Arg0 >( arg0 );
- }
-
-private:
-
- SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
- SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
-
-private:
-
- // Use composition instead of inheritance (virtual methods don't mix well with templates)
- BaseSignal mImpl; ///< Implementation
-};
-
-/**
- * @brief A template for Signals with 1 parameter and a return value.
- */
-template < typename Ret, typename Arg0 >
-class SignalV2< Ret( Arg0 ) >
-{
-public:
-
- /**
- * @brief Default constructor.
- */
- SignalV2()
- {
- }
-
- /**
- * @brief Non-virtual destructor.
- */
- ~SignalV2()
- {
- }
-
- /**
- * @brief Query whether there are any connected slots.
- *
- * @return True if there are any slots connected to the signal.
- */
- bool Empty() const
- {
- return mImpl.Empty();
- }
-
- /**
- * @brief Query the number of slots.
- *
- * @return The number of slots connected to this signal.
- */
- std::size_t GetConnectionCount() const
- {
- return mImpl.GetConnectionCount();
- }
- /**
- * @brief Connect a function.
- *
- * @param[in] func The function to connect.
- */
- void Connect( Ret (*func)( Arg0 arg0 ) )
- {
- mImpl.OnConnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Disconnect a function.
- *
- * @param[in] func The function to disconnect.
- */
- void Disconnect( Ret (*func)( Arg0 arg0 ) )
- {
- mImpl.OnDisconnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( X* obj, Ret (X::*func)( Arg0 arg0 ) )
- {
- mImpl.OnConnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0 ) )
- {
- mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0 ) )
- {
- mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0 ) )
- {
- mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Connect a function object.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] func The function object to copy.
- */
- template<class X>
- void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn1< X, Arg0, Ret >( func ) );
- }
-
- /**
- * @brief Connect a function object using FunctorDelegate.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
- */
- void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn1< Arg0, Ret >( delegate ) );
- }
-
- /**
- * @brief Emit the signal.
- *
- * @param[in] arg0 The first value to pass to callbacks.
- * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
- */
- Ret Emit( Arg0 arg0 )
- {
- return mImpl.EmitReturn< Ret,Arg0 >(arg0);
- }
-
-private:
-
- SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
- SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
-
-private:
-
- // Use composition instead of inheritance (virtual methods don't mix well with templates)
- BaseSignal mImpl; ///< Implementation
-};
-
-/**
- * @brief A template for Signals with 2 parameters.
- *
- */
-template < typename Arg0, typename Arg1 >
-class SignalV2< void ( Arg0, Arg1 ) >
-{
-public:
-
- /**
- * @brief Default constructor.
- *
- */
- SignalV2()
- {
- }
-
- /**
- * @brief Non-virtual destructor.
- *
- */
- ~SignalV2()
- {
- }
-
- /**
- * @brief Query whether there are any connected slots.
- *
- * @return True if there are any slots connected to the signal.
- */
- bool Empty() const
- {
- return mImpl.Empty();
- }
-
- /**
- * @brief Query the number of slots.
- *
- * @return The number of slots connected to this signal.
- */
- std::size_t GetConnectionCount() const
- {
- return mImpl.GetConnectionCount();
- }
- /**
- * @brief Connect a function.
- *
- * @param[in] func The function to connect.
- */
- void Connect( void (*func)( Arg0 arg0, Arg1 arg1 ) )
- {
- mImpl.OnConnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Disconnect a function.
- *
- * @param[in] func The function to disconnect.
- */
- void Disconnect( void (*func)( Arg0 arg0, Arg1 arg1 ) )
- {
- mImpl.OnDisconnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
- {
- mImpl.OnConnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
- {
- mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
- {
- mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
- {
- mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Connect a function object.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] func The function object to copy.
- */
- template<class X>
- void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctor2< X, Arg0, Arg1 >( func ) );
- }
-
- /**
- * @brief Connect a function object using FunctorDelegate.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
- */
- void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate2< Arg0, Arg1 >( delegate ) );
- }
-
- /**
- * @brief Emit the signal.
- *
- * @param[in] arg0 The first value to pass to callbacks.
- * @param[in] arg1 The second value to pass to callbacks.
- */
- void Emit( Arg0 arg0, Arg1 arg1 )
- {
- mImpl.Emit< Arg0,Arg1 >( arg0, arg1 );
- }
-
-private:
-
- SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
- SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
-
-private:
-
- // Use composition instead of inheritance (virtual methods don't mix well with templates)
- BaseSignal mImpl; ///< Implementation
-};
-
-/**
- * @brief A template for Signals with 2 parameters and a return value.
- */
-template < typename Ret, typename Arg0, typename Arg1 >
-class SignalV2< Ret( Arg0, Arg1 ) >
-{
-public:
-
- /**
- * @brief Default constructor.
- */
- SignalV2()
- {
- }
-
- /**
- * @brief Non-virtual destructor.
- */
- ~SignalV2()
- {
- }
-
- /**
- * @brief Query whether there are any connected slots.
- *
- * @return True if there are any slots connected to the signal.
- */
- bool Empty() const
- {
- return mImpl.Empty();
- }
-
- /**
- * @brief Query the number of slots.
- *
- * @return The number of slots connected to this signal.
- */
- std::size_t GetConnectionCount() const
- {
- return mImpl.GetConnectionCount();
- }
- /**
- * @brief Connect a function.
- * @param[in] func The function to connect.
- */
- void Connect( Ret (*func)( Arg0 arg0, Arg1 arg1 ) )
- {
- mImpl.OnConnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Disconnect a function.
- *
- * @param[in] func The function to disconnect.
- */
- void Disconnect( Ret (*func)( Arg0 arg0, Arg1 arg1 ) )
- {
- mImpl.OnDisconnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
- {
- mImpl.OnConnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
- {
- mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
- {
- mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
- {
- mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Connect a function object.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] func The function object to copy.
- */
- template<class X>
- void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn2< X, Arg0, Arg1, Ret >( func ) );
- }
-
- /**
- * @brief Connect a function object using FunctorDelegate.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
- */
- void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn2< Arg0, Arg1, Ret >( delegate ) );
- }
-
- /**
- * @brief Emit the signal.
- *
- * @param[in] arg0 The first value to pass to callbacks.
- * @param[in] arg1 The second value to pass to callbacks.
- * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
- */
- Ret Emit( Arg0 arg0, Arg1 arg1 )
- {
- return mImpl.EmitReturn< Ret,Arg0,Arg1 >( arg0, arg1 );
- }
-
-private:
-
- SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
- SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
-
-private:
-
- // Use composition instead of inheritance (virtual methods don't mix well with templates)
- BaseSignal mImpl; ///< Implementation
-};
-
-/**
- * @brief A template for Signals with 3 parameters.
- */
-template < typename Arg0, typename Arg1, typename Arg2 >
-class SignalV2< void ( Arg0, Arg1, Arg2 ) >
-{
-public:
-
- /**
- * @brief Default constructor.
- */
- SignalV2()
- {
- }
-
- /**
- * @brief Non-virtual destructor.
- */
- ~SignalV2()
- {
- }
-
- /**
- * @brief Query whether there are any connected slots.
- *
- * @return True if there are any slots connected to the signal.
- */
- bool Empty() const
- {
- return mImpl.Empty();
- }
-
- /**
- * @brief Query the number of slots.
- *
- * @return The number of slots connected to this signal.
- */
- std::size_t GetConnectionCount() const
- {
- return mImpl.GetConnectionCount();
- }
- /**
- * @brief Connect a function.
- *
- * @param[in] func The function to connect.
- */
- void Connect( void (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
- {
- mImpl.OnConnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Disconnect a function.
- *
- * @param[in] func The function to disconnect.
- */
- void Disconnect( void (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
- {
- mImpl.OnDisconnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
- {
- mImpl.OnConnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
- {
- mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
- {
- mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
- {
- mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Connect a function object.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] func The function object to copy.
- */
- template<class X>
- void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctor3< X, Arg0, Arg1, Arg2 >( func ) );
- }
-
- /**
- * @brief Connect a function object using FunctorDelegate.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
- */
- void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate3< Arg0, Arg1, Arg2 >( delegate ) );
- }
-
- /**
- * @brief Emit the signal.
- *
- * @param[in] arg0 The first value to pass to callbacks.
- * @param[in] arg1 The second value to pass to callbacks.
- * @param[in] arg2 The third value to pass to callbacks.
- */
- void Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 )
- {
- mImpl.Emit< Arg0,Arg1,Arg2 >( arg0, arg1, arg2 );
- }
-
-private:
-
- SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
- SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
-
-private:
-
- // Use composition instead of inheritance (virtual methods don't mix well with templates)
- BaseSignal mImpl; ///< Implementation
-};
-
-/**
- * @brief A template for Signals with 2 parameters and a return value.
- */
-template < typename Ret, typename Arg0, typename Arg1, typename Arg2 >
-class SignalV2< Ret( Arg0, Arg1, Arg2 ) >
-{
-public:
-
- /**
- * @brief Default constructor.
- */
- SignalV2()
- {
- }
-
- /**
- * @brief Non-virtual destructor.
- */
- ~SignalV2()
- {
- }
-
- /**
- * @brief Query whether there are any connected slots.
- *
- * @return True if there are any slots connected to the signal.
- */
- bool Empty() const
- {
- return mImpl.Empty();
- }
-
- /**
- * @brief Query the number of slots.
- *
- * @return The number of slots connected to this signal.
- */
- std::size_t GetConnectionCount() const
- {
- return mImpl.GetConnectionCount();
- }
-
- /**
- * @brief Connect a function.
- *
- * @param[in] func The function to connect.
- */
- void Connect( Ret (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
- {
- mImpl.OnConnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Disconnect a function.
- *
- * @param[in] func The function to disconnect.
- */
- void Disconnect( Ret (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
- {
- mImpl.OnDisconnect( MakeCallback( func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
- {
- mImpl.OnConnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] obj An object which must implement the ConnectionTrackerInterface.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
- {
- mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
- }
-
- /**
- * @brief Connect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to connect.
- */
- template<class X>
- void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
- {
- mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Disconnect a member function.
- *
- * @param[in] delegate A slot delegate.
- * @param[in] func The member function to disconnect.
- */
- template<class X>
- void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
- {
- mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
- }
-
- /**
- * @brief Connect a function object.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] func The function object to copy.
- */
- template<class X>
- void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn3< X, Arg0, Arg1, Arg2, Ret >( func ) );
- }
-
- /**
- * @brief Connect a function object using FunctorDelegate.
- *
- * @param[in] connectionTracker A connection tracker which can be used to disconnect.
- * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
- */
- void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
- {
- mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn3< Arg0, Arg1, Arg2, Ret >( delegate ) );
- }
-
- /**
- * @brief Emit the signal.
- *
- * @param[in] arg0 The first value to pass to callbacks.
- * @param[in] arg1 The second value to pass to callbacks.
- * @param[in] arg2 The third value to pass to callbacks.
- * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
- */
- Ret Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 )
- {
- return mImpl.EmitReturn< Ret,Arg0,Arg1,Arg2 >( arg0, arg1, arg2 );
- }
-
-private:
-
- SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
- SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
-
-private:
-
- // Use composition instead of inheritance (virtual methods don't mix well with templates)
- BaseSignal mImpl; ///< Implementation
-};
-
-} // namespace Dali
-
-#endif // __DALI_SIGNAL_V2_H__
--- /dev/null
+#ifndef __DALI_SIGNAL_H__
+#define __DALI_SIGNAL_H__
+
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * The class should implement Dali::ConnectionTrackerInterface, or inherit from Dali::ConnectionTracker.
+ * This enforces automatic disconnection when an object is destroyed, so you don't have
+ * to manually disconnect from signals.
+ *
+ * Alternatively, you can use a Dali::SlotDelegate if you don't want to inherit.
+ *
+ * E.g:
+ * @code
+ * class MyClass : public ConnectionTracker
+ * {
+ *
+ * void Callback( Actor actor, const TouchEvent& event )
+ * {
+ * ...
+ * }
+ *
+ * void Init()
+ * {
+ * Actor actor = Actor::New();
+ *
+ * actor.TouchedSignal().Connect( this, &MyClass::Callback );
+ * }
+ *
+ * ~MyClass()
+ * {
+ * // ConnectionTracker base class automatically disconnects
+ * }
+ * }
+ * @endcode
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/signals/callback.h>
+#include <dali/public-api/signals/signal-slot-connections.h>
+#include <dali/public-api/signals/slot-delegate.h>
+#include <dali/public-api/signals/base-signal.h>
+
+namespace Dali
+{
+
+/**
+ * @brief Base Template class to provide signals.
+ */
+template< typename _Signature >
+class Signal
+{
+};
+
+/**
+ * @brief A template for Signals with no parameters or return value.
+ */
+template <>
+class Signal< void () >
+{
+public:
+
+ /**
+ * @brief Default constructor.
+ */
+ Signal()
+ {
+ }
+
+ /**
+ * @brief Non-virtual destructor.
+ */
+ ~Signal()
+ {
+ }
+
+ /**
+ * @brief Query whether there are any connected slots.
+ *
+ * @return True if there are any slots connected to the signal.
+ */
+ bool Empty() const
+ {
+ return mImpl.Empty();
+ }
+
+ /**
+ * @brief Query the number of slots.
+ *
+ * @return The number of slots connected to this signal.
+ */
+ std::size_t GetConnectionCount() const
+ {
+ return mImpl.GetConnectionCount();
+ }
+
+ /**
+ * @brief Connect a function.
+ *
+ * @param[in] func The function to connect.
+ */
+ void Connect( void (*func)() )
+ {
+ mImpl.OnConnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Disconnect a function.
+ *
+ * @param[in] func The function to disconnect.
+ */
+ void Disconnect( void (*func)() )
+ {
+ mImpl.OnDisconnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( X* obj, void (X::*func)() )
+ {
+ mImpl.OnConnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( X* obj, void (X::*func)() )
+ {
+ mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( SlotDelegate<X>& delegate, void (X::*func)() )
+ {
+ mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( SlotDelegate<X>& delegate, void (X::*func)() )
+ {
+ mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Connect a function object.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] func The function object to copy.
+ */
+ template<class X>
+ void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctor0< X >( func ) );
+ }
+
+ /**
+ * @brief Connect a function object using FunctorDelegate.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
+ */
+ void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate0( delegate ) );
+ }
+
+ /**
+ * @brief Emit the signal.
+ */
+ void Emit()
+ {
+ mImpl.Emit();
+ }
+
+private:
+
+ Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying.
+ Signal& operator=( const Signal& ); ///< undefined assignment operator
+
+private:
+
+ // Use composition instead of inheritance (virtual methods don't mix well with templates)
+ BaseSignal mImpl; ///< The base signal implementation
+};
+
+/**
+ * @brief A template for Signals with no parameters and a return value.
+ */
+template < typename Ret >
+class Signal< Ret() >
+{
+public:
+
+ /**
+ * @brief Default constructor.
+ */
+ Signal()
+ {
+ }
+
+ /**
+ * @brief Non-virtual destructor.
+ */
+ ~Signal()
+ {
+ }
+
+ /**
+ * @brief Query whether there are any connected slots.
+ *
+ * @return True if there are any slots connected to the signal.
+ */
+ bool Empty() const
+ {
+ return mImpl.Empty();
+ }
+
+ /**
+ * @brief Query the number of slots.
+ *
+ * @return The number of slots connected to this signal.
+ */
+ std::size_t GetConnectionCount() const
+ {
+ return mImpl.GetConnectionCount();
+ }
+ /**
+ * @brief Connect a function.
+ *
+ * @param[in] func The function to connect.
+ */
+ void Connect( Ret (*func)() )
+ {
+ mImpl.OnConnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Disconnect a function.
+ *
+ * @param[in] func The function to disconnect.
+ */
+ void Disconnect( Ret (*func)() )
+ {
+ mImpl.OnDisconnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( X* obj, Ret (X::*func)() )
+ {
+ mImpl.OnConnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( X* obj, Ret (X::*func)() )
+ {
+ mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( SlotDelegate<X>& delegate, Ret (X::*func)() )
+ {
+ mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)() )
+ {
+ mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Connect a function object.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] func The function object to copy.
+ */
+ template<class X>
+ void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn0< X, Ret >( func ) );
+ }
+
+ /**
+ * @brief Connect a function object using FunctorDelegate.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
+ */
+ void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn0< Ret >( delegate ) );
+ }
+
+ /**
+ * @brief Emit the signal.
+ *
+ * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
+ */
+ Ret Emit()
+ {
+ return mImpl.EmitReturn< Ret >();
+ }
+
+private:
+
+ Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying.
+ Signal& operator=( const Signal& ); ///< undefined assignment operator
+
+private:
+
+ // Use composition instead of inheritance (virtual methods don't mix well with templates)
+ BaseSignal mImpl; ///< Implementation
+};
+
+/**
+ * @brief A template for Signals with 1 parameter.
+ */
+template < typename Arg0 >
+class Signal< void ( Arg0 ) >
+{
+public:
+
+ /**
+ * @brief Default constructor.
+ */
+ Signal()
+ {
+ }
+
+ /**
+ * @brief Non-virtual destructor.
+ */
+ ~Signal()
+ {
+ }
+
+ /**
+ * @brief Query whether there are any connected slots.
+ *
+ * @return True if there are any slots connected to the signal.
+ */
+ bool Empty() const
+ {
+ return mImpl.Empty();
+ }
+
+ /**
+ * @brief Query the number of slots.
+ *
+ * @return The number of slots connected to this signal.
+ */
+ std::size_t GetConnectionCount() const
+ {
+ return mImpl.GetConnectionCount();
+ }
+ /**
+ * @brief Connect a function.
+ *
+ * @param[in] func The function to connect.
+ */
+ void Connect( void (*func)( Arg0 arg0 ) )
+ {
+ mImpl.OnConnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Disconnect a function.
+ *
+ * @param[in] func The function to disconnect.
+ */
+ void Disconnect( void (*func)( Arg0 arg0 ) )
+ {
+ mImpl.OnDisconnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( X* obj, void (X::*func)( Arg0 arg0 ) )
+ {
+ mImpl.OnConnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( X* obj, void (X::*func)( Arg0 arg0 ) )
+ {
+ mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0 ) )
+ {
+ mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0 ) )
+ {
+ mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Connect a function object.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] func The function object to copy.
+ */
+ template<class X>
+ void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctor1< X, Arg0 >( func ) );
+ }
+
+ /**
+ * @brief Connect a function object using FunctorDelegate.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
+ */
+ void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate1< Arg0 >( delegate ) );
+ }
+
+ /**
+ * @brief Emit the signal.
+ *
+ * @param[in] arg0 The first value to pass to callbacks.
+ */
+ void Emit( Arg0 arg0 )
+ {
+ mImpl.Emit< Arg0 >( arg0 );
+ }
+
+private:
+
+ Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying.
+ Signal& operator=( const Signal& ); ///< undefined assignment operator
+
+private:
+
+ // Use composition instead of inheritance (virtual methods don't mix well with templates)
+ BaseSignal mImpl; ///< Implementation
+};
+
+/**
+ * @brief A template for Signals with 1 parameter and a return value.
+ */
+template < typename Ret, typename Arg0 >
+class Signal< Ret( Arg0 ) >
+{
+public:
+
+ /**
+ * @brief Default constructor.
+ */
+ Signal()
+ {
+ }
+
+ /**
+ * @brief Non-virtual destructor.
+ */
+ ~Signal()
+ {
+ }
+
+ /**
+ * @brief Query whether there are any connected slots.
+ *
+ * @return True if there are any slots connected to the signal.
+ */
+ bool Empty() const
+ {
+ return mImpl.Empty();
+ }
+
+ /**
+ * @brief Query the number of slots.
+ *
+ * @return The number of slots connected to this signal.
+ */
+ std::size_t GetConnectionCount() const
+ {
+ return mImpl.GetConnectionCount();
+ }
+ /**
+ * @brief Connect a function.
+ *
+ * @param[in] func The function to connect.
+ */
+ void Connect( Ret (*func)( Arg0 arg0 ) )
+ {
+ mImpl.OnConnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Disconnect a function.
+ *
+ * @param[in] func The function to disconnect.
+ */
+ void Disconnect( Ret (*func)( Arg0 arg0 ) )
+ {
+ mImpl.OnDisconnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( X* obj, Ret (X::*func)( Arg0 arg0 ) )
+ {
+ mImpl.OnConnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0 ) )
+ {
+ mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0 ) )
+ {
+ mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0 ) )
+ {
+ mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Connect a function object.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] func The function object to copy.
+ */
+ template<class X>
+ void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn1< X, Arg0, Ret >( func ) );
+ }
+
+ /**
+ * @brief Connect a function object using FunctorDelegate.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
+ */
+ void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn1< Arg0, Ret >( delegate ) );
+ }
+
+ /**
+ * @brief Emit the signal.
+ *
+ * @param[in] arg0 The first value to pass to callbacks.
+ * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
+ */
+ Ret Emit( Arg0 arg0 )
+ {
+ return mImpl.EmitReturn< Ret,Arg0 >(arg0);
+ }
+
+private:
+
+ Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying.
+ Signal& operator=( const Signal& ); ///< undefined assignment operator
+
+private:
+
+ // Use composition instead of inheritance (virtual methods don't mix well with templates)
+ BaseSignal mImpl; ///< Implementation
+};
+
+/**
+ * @brief A template for Signals with 2 parameters.
+ *
+ */
+template < typename Arg0, typename Arg1 >
+class Signal< void ( Arg0, Arg1 ) >
+{
+public:
+
+ /**
+ * @brief Default constructor.
+ *
+ */
+ Signal()
+ {
+ }
+
+ /**
+ * @brief Non-virtual destructor.
+ *
+ */
+ ~Signal()
+ {
+ }
+
+ /**
+ * @brief Query whether there are any connected slots.
+ *
+ * @return True if there are any slots connected to the signal.
+ */
+ bool Empty() const
+ {
+ return mImpl.Empty();
+ }
+
+ /**
+ * @brief Query the number of slots.
+ *
+ * @return The number of slots connected to this signal.
+ */
+ std::size_t GetConnectionCount() const
+ {
+ return mImpl.GetConnectionCount();
+ }
+ /**
+ * @brief Connect a function.
+ *
+ * @param[in] func The function to connect.
+ */
+ void Connect( void (*func)( Arg0 arg0, Arg1 arg1 ) )
+ {
+ mImpl.OnConnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Disconnect a function.
+ *
+ * @param[in] func The function to disconnect.
+ */
+ void Disconnect( void (*func)( Arg0 arg0, Arg1 arg1 ) )
+ {
+ mImpl.OnDisconnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
+ {
+ mImpl.OnConnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
+ {
+ mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
+ {
+ mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
+ {
+ mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Connect a function object.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] func The function object to copy.
+ */
+ template<class X>
+ void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctor2< X, Arg0, Arg1 >( func ) );
+ }
+
+ /**
+ * @brief Connect a function object using FunctorDelegate.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
+ */
+ void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate2< Arg0, Arg1 >( delegate ) );
+ }
+
+ /**
+ * @brief Emit the signal.
+ *
+ * @param[in] arg0 The first value to pass to callbacks.
+ * @param[in] arg1 The second value to pass to callbacks.
+ */
+ void Emit( Arg0 arg0, Arg1 arg1 )
+ {
+ mImpl.Emit< Arg0,Arg1 >( arg0, arg1 );
+ }
+
+private:
+
+ Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying.
+ Signal& operator=( const Signal& ); ///< undefined assignment operator
+
+private:
+
+ // Use composition instead of inheritance (virtual methods don't mix well with templates)
+ BaseSignal mImpl; ///< Implementation
+};
+
+/**
+ * @brief A template for Signals with 2 parameters and a return value.
+ */
+template < typename Ret, typename Arg0, typename Arg1 >
+class Signal< Ret( Arg0, Arg1 ) >
+{
+public:
+
+ /**
+ * @brief Default constructor.
+ */
+ Signal()
+ {
+ }
+
+ /**
+ * @brief Non-virtual destructor.
+ */
+ ~Signal()
+ {
+ }
+
+ /**
+ * @brief Query whether there are any connected slots.
+ *
+ * @return True if there are any slots connected to the signal.
+ */
+ bool Empty() const
+ {
+ return mImpl.Empty();
+ }
+
+ /**
+ * @brief Query the number of slots.
+ *
+ * @return The number of slots connected to this signal.
+ */
+ std::size_t GetConnectionCount() const
+ {
+ return mImpl.GetConnectionCount();
+ }
+ /**
+ * @brief Connect a function.
+ * @param[in] func The function to connect.
+ */
+ void Connect( Ret (*func)( Arg0 arg0, Arg1 arg1 ) )
+ {
+ mImpl.OnConnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Disconnect a function.
+ *
+ * @param[in] func The function to disconnect.
+ */
+ void Disconnect( Ret (*func)( Arg0 arg0, Arg1 arg1 ) )
+ {
+ mImpl.OnDisconnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
+ {
+ mImpl.OnConnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
+ {
+ mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
+ {
+ mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
+ {
+ mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Connect a function object.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] func The function object to copy.
+ */
+ template<class X>
+ void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn2< X, Arg0, Arg1, Ret >( func ) );
+ }
+
+ /**
+ * @brief Connect a function object using FunctorDelegate.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
+ */
+ void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn2< Arg0, Arg1, Ret >( delegate ) );
+ }
+
+ /**
+ * @brief Emit the signal.
+ *
+ * @param[in] arg0 The first value to pass to callbacks.
+ * @param[in] arg1 The second value to pass to callbacks.
+ * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
+ */
+ Ret Emit( Arg0 arg0, Arg1 arg1 )
+ {
+ return mImpl.EmitReturn< Ret,Arg0,Arg1 >( arg0, arg1 );
+ }
+
+private:
+
+ Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying.
+ Signal& operator=( const Signal& ); ///< undefined assignment operator
+
+private:
+
+ // Use composition instead of inheritance (virtual methods don't mix well with templates)
+ BaseSignal mImpl; ///< Implementation
+};
+
+/**
+ * @brief A template for Signals with 3 parameters.
+ */
+template < typename Arg0, typename Arg1, typename Arg2 >
+class Signal< void ( Arg0, Arg1, Arg2 ) >
+{
+public:
+
+ /**
+ * @brief Default constructor.
+ */
+ Signal()
+ {
+ }
+
+ /**
+ * @brief Non-virtual destructor.
+ */
+ ~Signal()
+ {
+ }
+
+ /**
+ * @brief Query whether there are any connected slots.
+ *
+ * @return True if there are any slots connected to the signal.
+ */
+ bool Empty() const
+ {
+ return mImpl.Empty();
+ }
+
+ /**
+ * @brief Query the number of slots.
+ *
+ * @return The number of slots connected to this signal.
+ */
+ std::size_t GetConnectionCount() const
+ {
+ return mImpl.GetConnectionCount();
+ }
+ /**
+ * @brief Connect a function.
+ *
+ * @param[in] func The function to connect.
+ */
+ void Connect( void (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
+ {
+ mImpl.OnConnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Disconnect a function.
+ *
+ * @param[in] func The function to disconnect.
+ */
+ void Disconnect( void (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
+ {
+ mImpl.OnDisconnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
+ {
+ mImpl.OnConnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
+ {
+ mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
+ {
+ mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
+ {
+ mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Connect a function object.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] func The function object to copy.
+ */
+ template<class X>
+ void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctor3< X, Arg0, Arg1, Arg2 >( func ) );
+ }
+
+ /**
+ * @brief Connect a function object using FunctorDelegate.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
+ */
+ void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate3< Arg0, Arg1, Arg2 >( delegate ) );
+ }
+
+ /**
+ * @brief Emit the signal.
+ *
+ * @param[in] arg0 The first value to pass to callbacks.
+ * @param[in] arg1 The second value to pass to callbacks.
+ * @param[in] arg2 The third value to pass to callbacks.
+ */
+ void Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 )
+ {
+ mImpl.Emit< Arg0,Arg1,Arg2 >( arg0, arg1, arg2 );
+ }
+
+private:
+
+ Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying.
+ Signal& operator=( const Signal& ); ///< undefined assignment operator
+
+private:
+
+ // Use composition instead of inheritance (virtual methods don't mix well with templates)
+ BaseSignal mImpl; ///< Implementation
+};
+
+/**
+ * @brief A template for Signals with 2 parameters and a return value.
+ */
+template < typename Ret, typename Arg0, typename Arg1, typename Arg2 >
+class Signal< Ret( Arg0, Arg1, Arg2 ) >
+{
+public:
+
+ /**
+ * @brief Default constructor.
+ */
+ Signal()
+ {
+ }
+
+ /**
+ * @brief Non-virtual destructor.
+ */
+ ~Signal()
+ {
+ }
+
+ /**
+ * @brief Query whether there are any connected slots.
+ *
+ * @return True if there are any slots connected to the signal.
+ */
+ bool Empty() const
+ {
+ return mImpl.Empty();
+ }
+
+ /**
+ * @brief Query the number of slots.
+ *
+ * @return The number of slots connected to this signal.
+ */
+ std::size_t GetConnectionCount() const
+ {
+ return mImpl.GetConnectionCount();
+ }
+
+ /**
+ * @brief Connect a function.
+ *
+ * @param[in] func The function to connect.
+ */
+ void Connect( Ret (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
+ {
+ mImpl.OnConnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Disconnect a function.
+ *
+ * @param[in] func The function to disconnect.
+ */
+ void Disconnect( Ret (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
+ {
+ mImpl.OnDisconnect( MakeCallback( func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
+ {
+ mImpl.OnConnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] obj An object which must implement the ConnectionTrackerInterface.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
+ {
+ mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
+ }
+
+ /**
+ * @brief Connect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to connect.
+ */
+ template<class X>
+ void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
+ {
+ mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Disconnect a member function.
+ *
+ * @param[in] delegate A slot delegate.
+ * @param[in] func The member function to disconnect.
+ */
+ template<class X>
+ void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
+ {
+ mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
+ }
+
+ /**
+ * @brief Connect a function object.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] func The function object to copy.
+ */
+ template<class X>
+ void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn3< X, Arg0, Arg1, Arg2, Ret >( func ) );
+ }
+
+ /**
+ * @brief Connect a function object using FunctorDelegate.
+ *
+ * @param[in] connectionTracker A connection tracker which can be used to disconnect.
+ * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
+ */
+ void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
+ {
+ mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn3< Arg0, Arg1, Arg2, Ret >( delegate ) );
+ }
+
+ /**
+ * @brief Emit the signal.
+ *
+ * @param[in] arg0 The first value to pass to callbacks.
+ * @param[in] arg1 The second value to pass to callbacks.
+ * @param[in] arg2 The third value to pass to callbacks.
+ * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
+ */
+ Ret Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 )
+ {
+ return mImpl.EmitReturn< Ret,Arg0,Arg1,Arg2 >( arg0, arg1, arg2 );
+ }
+
+private:
+
+ Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying.
+ Signal& operator=( const Signal& ); ///< undefined assignment operator
+
+private:
+
+ // Use composition instead of inheritance (virtual methods don't mix well with templates)
+ BaseSignal mImpl; ///< Implementation
+};
+
+} // namespace Dali
+
+#endif // __DALI_SIGNAL_H__