Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_TimedTask Class Reference

A class to call a user slot at specified time intervals. More...

Inheritance diagram for CP_TimedTask:

CP_SigSlot::CP_SlotObject CP_Object CP_NoCopy List of all members.

Public Member Functions

void Start ()
void Stop ()
virtual void HandleTask ()
bool IsRunning ()
void disconnect_all ()
void signal_connect (CP_Signal *inSender)
void signal_disconnect (CP_Signal *inSender)
void SetID (FourCharCode inIdentifier)
FourCharCode GetID ()
void RegisterSignal (const CP_SignalHolder &inSignal)
CP_DataValueSignalFindSignal (const CP_String &inSignalName)
UInt32 GetNumberSignals ()
CP_String GetNthSignalName (UInt32 inSignalIndex)
void RegisterSlot (const CP_SlotHolder &inSlot)
CP_DataValueSlot FindSlot (const CP_String &inSlotName)
UInt32 GetNumberSlots ()
CP_String GetNthSlotName (UInt32 inSlotIndex)
template<class R, class P1, class P2>
CP_CommandHandlerSignalConnect (CPLAT::CP_CommandNo cmd, void(R::*handler)(P1, P2), SInt32 mode)
template<class R, class P1, class P2>
void Connect (CP_Object *control, const CPLAT::CP_String &signalName, void(R::*handler)(P1, P2))
Constructor / Destructor
 CP_TimedTask (double inMilliSecFrequency, UInt32 inUserData=0)
 Constructor.
virtual ~CP_TimedTask () throw ()
 Destructor.

Static Public Member Functions

static void Connect (CP_Object *sender, const CP_String &signalName, CP_Object *receiver, const CP_String &slotName, const bool reciprocal=false)
static void Connect (CP_Object *sender, CP_Object *receiver, const bool reciprocal=false, const CP_String &signalName=kCP_Signal_ValueChanged, const CP_String &slotName=kCP_Slot_SetValue)

Protected Member Functions

EventLoopTimerUPP GetTimerUPP ()

Protected Attributes

bool fIsRunning
UInt32 fUserData
CP_DataValueSignal fTimerTaskSignal
double fMilliSecFrequency
EventLoopTimerRef fTimer
CP_WindowfTimerWindow
UINT fWinTimer
sender_set fSenders
CP_Signals_ArrayfSignals
CP_Slots_ArrayfSlots
FourCharCode fObjectID

Static Protected Attributes

static FourCharCode fObjectIDCount = 0

Private Member Functions

void CreateDummyTimerWindow ()
void HandlerWMTimer (CPLAT::CP_Event_Base &inEvent)

Static Private Member Functions

static pascal void CP_TimedTask_timerCallback (EventLoopTimerRef inTimer, void *userData)

Detailed Description

This classs is used to call a user defined slot at a specified time interval, measured in milliseconds.

Example usage:

                CPLAT::CP_TimedTask             *timer = CP_new CPLAT::CP_TimedTask( kEventDurationSecond * 5, dataValue );
    
                timer->FindSignal( kCP_Signal_TimedTask )->connect( CP_SigSlot::slot(this, &Timer_Application::TimerTask) );
    
                timer->Start();

In this above example, the slot TimerTask will be called every 5 seconds. The dataValue passed to the CP_TimedTask constructor will be passed to the timer slot you have defined. You can use this data member anyway you want.


Constructor & Destructor Documentation

CPLAT_Begin_Namespace_CPLAT CP_TimedTask::CP_TimedTask double  inMilliSecFrequency,
UInt32  inUserData = 0
 

Constructor.

Exceptions:
none 

CP_TimedTask::~CP_TimedTask  )  throw () [virtual]
 

Destructor.

Exceptions:
none 


Member Function Documentation

void CP_TimedTask::Start  ) 
 

Starts the timer.

Exceptions:
none 
Returns:
void

void CP_TimedTask::Stop  ) 
 

Stops the timer.

Exceptions:
none 
Returns:
void

void CP_TimedTask::HandleTask  )  [virtual]
 

Called when the timer fires. this will call the timer task signal to handle the user defined function that gets called when the timer fires.

Exceptions:
none 
Returns:
void

bool CP_TimedTask::IsRunning  ) 
 

Returns the flag that indicates if this timer is currently running.

Exceptions:
none 
Returns:
bool True if the timer is currently running.

EventLoopTimerUPP CP_TimedTask::GetTimerUPP  )  [protected]
 

Returns the EventLoopTimerUPP for our timer.

Exceptions:
none 
Returns:
EventLoopTimerUPP The Carbon event loop timer.

pascal void CP_TimedTask::CP_TimedTask_timerCallback EventLoopTimerRef  inTimer,
void *  inUserData
[static, private]
 

The Carbon event timer callback that is registered with the Carbon event timer. This calls the HandleTask() method of this class.

Parameters:
inTimer Not used.
inUserData Pointer to this object.
Exceptions:
none 
Returns:
void

void CP_TimedTask::CreateDummyTimerWindow  )  [private]
 

Creates a small window that receives the WM_TIMER calls. This window is created out of view, and hidden. Its only purpose is to handle WM_TIMER events.

Exceptions:
none 
Returns:
void

void CP_TimedTask::HandlerWMTimer CPLAT::CP_Event_Base &  inEvent  )  [private]
 

Handles the WM_TIMER events. This calls the HandleTask method to perform the timed task.

Parameters:
inEvent Not used.
Exceptions:
none 
Returns:
void

void CP_SigSlot::CP_SlotObject::disconnect_all  )  [inherited]
 

void CP_SigSlot::CP_SlotObject::signal_connect CP_Signal inSender  )  [inherited]
 

void CP_SigSlot::CP_SlotObject::signal_disconnect CP_Signal inSender  )  [inherited]
 

void CP_Object::SetID FourCharCode  inIdentifier  )  [inherited]
 

Sets the identifier for this object. If a specific identifier is not set with this function, then a default id is used, which is simply a running count of the number of objects created.

Parameters:
inIdentifier The objects identifier.
Returns:
void

FourCharCode CP_Object::GetID  )  [inherited]
 

Returns the objects identifier.

Returns:
FourCharCode The identifier of this object.

void CP_Object::RegisterSignal const CP_SignalHolder inSignal  )  [inherited]
 

Registers the signal / signal name contained in the passed in inSignal object.

Parameters:
inSignal CP_SignalHolder that holds a signal and string identifier.
Returns:
void

CP_DataValueSignal * CP_Object::FindSignal const CP_String inSignalName  )  [inherited]
 

Finds the CP_DataValueSignal object that matches the passed in inSignalName.

Parameters:
inSignalName CP_String containing the identifier of the signal to return.
Returns:
CP_DataValueSignal * Returns a pointer to a CP_DataValueSignal object.

UInt32 CP_Object::GetNumberSignals  )  [inherited]
 

Returns the number of signals for this object.

Returns:
UInt32 The number of signals.

CP_String CP_Object::GetNthSignalName UInt32  inSignalIndex  )  [inherited]
 

Returns the signal name of the passed in signal index.

Parameters:
inSignalIndex Index of the name of the signal to return.
Returns:
CP_String The name of the nth signal being returned.

void CP_Object::RegisterSlot const CP_SlotHolder inSlot  )  [inherited]
 

Registers the slot / slot name contained in the passed in inSlot object.

Parameters:
inSlot CP_SignalHolder that holds a slot and string identifier.
Returns:
void

CP_DataValueSlot CP_Object::FindSlot const CP_String inSlotName  )  [inherited]
 

Finds the CP_Slot1 object that matches the passed in inSlotName.

Parameters:
inSlotName CP_String containing the identifier of the slot to return.
Returns:
CP_DataValueSlot Returns a pointer to a CP_DataValueSlot object.

UInt32 CP_Object::GetNumberSlots  )  [inherited]
 

Returns the number of slots for this object.

Returns:
UInt32 The number of slots.

CP_String CP_Object::GetNthSlotName UInt32  inSlotIndex  )  [inherited]
 

Returns the slot name of the passed in signal index.

Parameters:
inSlotIndex Index of the name of the slot to return.
Returns:
CP_String The name of the nth slot being returned.

template<class R, class P1, class P2>
CP_CommandHandlerSignal* CP_Object::Connect CPLAT::CP_CommandNo  cmd,
void(R::*)(P1, P2)  handler,
SInt32  mode
[inherited]
 

template<class R, class P1, class P2>
void CP_Object::Connect CP_Object control,
const CPLAT::CP_String &  signalName,
void(R::*)(P1, P2)  handler
[inherited]
 

void CP_Object::Connect CP_Object sender,
const CP_String signalName,
CP_Object receiver,
const CP_String slotName,
const bool  reciprocal = false
[static, inherited]
 

void CP_Object::Connect CP_Object sender,
CP_Object receiver,
const bool  reciprocal = false,
const CP_String signalName = kCP_Signal_ValueChanged,
const CP_String slotName = kCP_Slot_SetValue
[static, inherited]
 


Member Data Documentation

bool CP_TimedTask::fIsRunning [protected]
 

UInt32 CP_TimedTask::fUserData [protected]
 

CP_DataValueSignal CP_TimedTask::fTimerTaskSignal [protected]
 

double CP_TimedTask::fMilliSecFrequency [protected]
 

EventLoopTimerRef CP_TimedTask::fTimer [protected]
 

CP_Window* CP_TimedTask::fTimerWindow [protected]
 

UINT CP_TimedTask::fWinTimer [protected]
 

sender_set CP_SigSlot::CP_SlotObject::fSenders [protected, inherited]
 

CP_Signals_Array* CP_Object::fSignals [protected, inherited]
 

CP_Slots_Array* CP_Object::fSlots [protected, inherited]
 

List of registered signals for this object.

FourCharCode CP_Object::fObjectID [protected, inherited]
 

List of registered slots for this object.

CPLAT_Begin_Namespace_CPLAT FourCharCode CP_Object::fObjectIDCount = 0 [static, protected, inherited]
 

Object identifier.


The documentation for this class was generated from the following files:
Generated on Sat Sep 17 20:02:21 2005 for CPLAT by  doxygen 1.4.0