PrevNextUpHome BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1
SFXTimer
Class that implements a timer.
#include <SFXTimer.h.hpp>
class SFXTimer;
SFMTYPEDEFCLASS(SFXTimer)

Collaboration diagram

 Collaboration diagram of SFXTimerClass

Description

TheSFXTimer class is used to execute a callback function after the specified time elapses.

class MyClass {
private:
    SFXTimer _timer; 
public:
    Void Function(Void);
    CALLBACK_DECLARE_SFXTIMER(TimerCallback)
};

Void MyClass::Function(Void)
{

    ...
    
    // TimerCallback is called after 4000 milli-seconds
    _timer.Set(CALLBACK_FUNCTION(TimerCallback));
    _timer.Schedule(4000);
}

/// callback function
CALLBACK_IMPLEMENT_SFXTIMER(MyClass, TimerCallback) {
    ...
}

Reference

SFXCallback | SFXTask

Member

Constructor/Destructor
SFXTimer( Void )
Constructor of SFXTimer class.
~SFXTimer( Void )
Destructor of SFXTimer class.
Public Functions
Void Cancel( Void )
Cancel the registered timers.
static
SFXTimerConstRef
EmptyInstance( Void )
Get an empty timer.
SFXCallback::CallbackSPP GetProcedure( Void )
Get the callback function set to the timer.
VoidPtr GetReference( Void )
Get user's data set to the timer.
Bool IsValid( Void )
Check whether the timer is registered or not.
SFCError Schedule( UInt32 msec )
Register a timer.
Void Set( SFXCallback::CallbackSPP spp , VoidPtr reference )
Set information necessary to register a timer.

SFXTimer::SFXTimer
Constructor of SFXTimer class.
[ public, explicit ]
SFXTimer(Void);

SFXTimer::~SFXTimer
Destructor of SFXTimer class.
[ public ]
~SFXTimer(Void);

Description

In the destructor, cancel the registered tasks by using the SFXTimer::Cancel function.

Reference

SFXTimer::Cancel


SFXTimer::Cancel
Cancel the registered timers.
[ public ]
Void Cancel(Void);

Description

Cancel the registered timers. If no timer is registered, nothing will happen.

Reference

SFXTimer::Set | SFXTimer::Schedule


SFXTimer::EmptyInstance
Get an empty timer.
[ public, static ]
SFXTimerConstRef EmptyInstance(Void);

Description

Get an instance that represents an empty timer.


SFXTimer::GetProcedure
Get the callback function set to the timer.
[ public, const ]
SFXCallback::CallbackSPP GetProcedure(Void);

Return value

Return the callback function set to the task.

Reference

SFXTimer::GetReference | SFXTimer::Set


SFXTimer::GetReference
Get user's data set to the timer.
[ public, const ]
VoidPtr GetReference(Void);

Return value

Return user's data set to the timer.

Reference

SFXTimer::GetProcedure | SFXTimer::Set


SFXTimer::IsValid
Check whether the timer is registered or not.
[ public, const ]
Bool IsValid(Void);

Return value

  • If registered : true
  • Otherwise : false

Reference

SFXTimer::Schedule


SFXTimer::Schedule
Register a timer.
[ public ]
SFCError Schedule(
    UInt32 msec   // time until the callback function is called ( milli-second )
);

Return value

  • If registered : SFERR_NO_ERROR
  • If argument is invalid or necessary information is not set with the SFXTimer::Set function : SFERR_INVALID_PARAM
  • If failed : SFERR_FAILED

Description

If the timer has already been registered, it will be canceled and registered again.

Reference

SFXTimer::IsValid | SFXTimer::Cancel | SFXTimer::Set


SFXTimer::Set
Set information necessary to register a timer.
[ public ]
Void Set(
    SFXCallback::CallbackSPP spp   // callback function called by the timer
    VoidPtr reference              // user's data passed to the callback function
);

Reference

SFXTimer::GetProcedure | SFXTimer::GetReference | SFXTimer::Schedule