X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftoolkit-timer.cpp;h=4ab6a57090c6633ee3311701025eb9984025b069;hp=f2a3d58e777a025d09353654f88c028791020d6b;hb=d5e3ed5f5b1c8fdba3ae97ead8729620f54b3836;hpb=fa6279fb2830427d5ab569ca14e6ade1557ef2fa diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-timer.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-timer.cpp index f2a3d58..4ab6a57 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-timer.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-timer.cpp @@ -1,55 +1,210 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.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://floralicense.org/license/ -// -// 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. -// +/* + * 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. + * + */ #include "toolkit-timer.h" -#include - // INTERNAL INCLUDES #include #include #include +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ +class Timer; + +typedef IntrusivePtr TimerPtr; + +/** + * Implementation of the timer + */ +class Timer : public BaseObject +{ +public: + static TimerPtr New( unsigned int milliSec ); + Timer( unsigned int milliSec ); + virtual ~Timer(); + + void Start(); + void Stop(); + void SetInterval( unsigned int interval ); + unsigned int GetInterval() const; + bool IsRunning() const; + bool Tick(); + +public: // Signals + + Dali::Timer::TimerSignalV2& TickSignal(); + +private: // Implementation + + // not implemented + Timer( const Timer& ); + Timer& operator=( const Timer& ); + +private: // Data + + Dali::Timer::TimerSignalV2 mTickSignal; + unsigned int mInterval; +}; + +inline Timer& GetImplementation(Dali::Timer& timer) +{ + DALI_ASSERT_ALWAYS(timer && "Timer handle is empty"); + + BaseObject& handle = timer.GetBaseObject(); + + return static_cast(handle); +} + +inline const Timer& GetImplementation(const Dali::Timer& timer) +{ + DALI_ASSERT_ALWAYS(timer && "Timer handle is empty"); + + const BaseObject& handle = timer.GetBaseObject(); + + return static_cast(handle); +} + +TimerPtr Timer::New( unsigned int milliSec ) +{ + TimerPtr timerImpl = new Timer(10); + return timerImpl; +} + +Timer::Timer( unsigned int milliSec ) +: mInterval( milliSec ) +{ +} + +Timer::~Timer() +{ +} -namespace +void Timer::Start() { -bool ecore_timer_running = false; -Ecore_Task_Cb timer_callback_func=NULL; -const void* timer_callback_data=NULL; -int timerId = 0; -}// anon namespace +} -extern "C" +void Timer::Stop() { -Ecore_Timer* ecore_timer_add(double in, - Ecore_Task_Cb func, - const void *data) +} + +void Timer::SetInterval( unsigned int interval ) { - ecore_timer_running = true; - timer_callback_func = func; - timer_callback_data = data; - timerId += sizeof(Ecore_Timer*); - return (Ecore_Timer*)timerId; + mInterval = interval; } -void* ecore_timer_del(Ecore_Timer *timer) +unsigned int Timer::GetInterval() const { - ecore_timer_running = false; - timer_callback_func = NULL; - return NULL; + return mInterval; } +bool Timer::IsRunning() const +{ + return true; } + +bool Timer::Tick() +{ + return false; +} + +Dali::Timer::TimerSignalV2& Timer::TickSignal() +{ + return mTickSignal; +} + +} // namespace Adaptor + +} // namespace Internal + +/********************************************************************************/ +/********************************* PUBLIC CLASS *******************************/ +/********************************************************************************/ + +Timer::Timer() +{ + +} + +Timer Timer::New( unsigned int milliSec ) +{ + Internal::Adaptor::TimerPtr internal = Internal::Adaptor::Timer::New( milliSec ); + return Timer(internal.Get()); +} + +Timer::Timer( const Timer& timer ) +:BaseHandle( timer ) +{ +} + +Timer& Timer::operator=( const Timer& timer ) +{ + // check self assignment + if( *this != timer ) + { + BaseHandle::operator=(timer); + } + return *this; +} + +Timer::~Timer() +{ +} + +void Timer::Start() +{ + Internal::Adaptor::GetImplementation( *this ).Start(); +} + +void Timer::Stop() +{ + Internal::Adaptor::GetImplementation( *this ).Stop(); +} + +void Timer::SetInterval( unsigned int milliSec ) +{ + Internal::Adaptor::GetImplementation( *this ).SetInterval( milliSec ); +} + +unsigned int Timer::GetInterval() const +{ + return Internal::Adaptor::GetImplementation( *this ).GetInterval(); +} + +bool Timer::IsRunning() const +{ + return true; +} + +Timer::TimerSignalV2& Timer::TickSignal() +{ + return Internal::Adaptor::GetImplementation( *this ).TickSignal(); +} + +Timer::Timer(Internal::Adaptor::Timer* timer) +: BaseHandle(timer) +{ +} + +} // namespace Dali +