changed Timer API (I'm still not happy with this interface, I need to redesign it!)

SVN revision: 57537
This commit is contained in:
Andreas Volz 2011-03-06 08:32:46 +00:00
parent 3144e6ccfb
commit 7779b257d1
4 changed files with 12 additions and 21 deletions

View File

@ -63,10 +63,6 @@ public:
static void processOneEvent();
static void quit();
/* Timer */
void startTimer( double seconds );
virtual void timerEvent( Timer* ) {};
/* Font */
/*EvasFont font();
EvasFont fixedFont();

View File

@ -9,11 +9,13 @@
namespace Ecorexx {
// TODO: maybe change signal architecture back to callback architecture. Think about it!
class Timer
{
typedef sigc::signal <void,Timer*> Signal;
typedef sigc::signal <void,Timer*> Loop;
typedef sigc::slot1 <void,Timer*> Slot;
typedef sigc::signal <void> Signal;
typedef sigc::signal <void> Loop;
//typedef sigc::slot1 <void, void> Slot;
public:
Timer( double seconds, bool singleshot = false );
@ -21,7 +23,7 @@ public:
//virtual void tick();
static Timer* singleShot( double seconds, const Timer::Slot& ); // TODO: CountedPtr
// static Timer* singleShot( double seconds, const Timer::Slot& ); // TODO: CountedPtr
void del ();

View File

@ -104,13 +104,6 @@ void Application::quit()
ecore_main_loop_quit();
}
void Application::startTimer( double seconds )
{
// FIXME: why is this needed? Who deletes this Timer object?
Timer* ecoretimer = new Timer( seconds );
ecoretimer->timeout.connect( sigc::mem_fun( this, &Application::timerEvent ) );
}
/*EvasFont Application::font()
{
assert( _font );

View File

@ -24,12 +24,11 @@ Timer::~Timer()
ecore_timer_del( _et );
}
Timer* Timer::singleShot( double seconds, const Timer::Slot& slot )
/*Timer* Timer::singleShot( double seconds, const Timer::Slot& slot )
{
Timer* ecoretimer = new Timer( seconds, true );
ecoretimer->timeout.connect( slot );
return ecoretimer;
}
}*/
void Timer::del ()
{
@ -85,11 +84,12 @@ Eina_Bool Timer::__dispatcher( void* data )
{
Timer* object = reinterpret_cast<Timer*>( data );
assert( object );
object->timeout.emit( object );
object->timeout.emit( );
//object->tick();
bool singleshot = object->_ss;
/*bool singleshot = object->_ss;
if ( singleshot ) delete object;
return singleshot? 0:1;
return singleshot? 0:1;*/
return ECORE_CALLBACK_RENEW;
}
} // end namespace Ecorexx