examples/ForumNokia/Symbian_OS_Basics_Lab_Exercises_v3_1/Lab_04309.cb1/solution/src/ActiveTimer.cpp

00001 // Copyright (c) 2006 Nokia Corporation.
00002 
00003 #include "ActiveTimer.h"
00004 #include "ActiveTimerNotify.h"
00005 
00006 
00007 // Constructs a CActiveTimer object
00008 CActiveTimer* CActiveTimer::NewL(MActiveTimerNotify& aNotifier)
00009     {
00010     CActiveTimer* self = new (ELeave) CActiveTimer(aNotifier);
00011     CleanupStack::PushL(self);
00012     self->ConstructL();
00013     CleanupStack::Pop();
00014     return self;
00015     }
00016 
00017 
00018 // C++ Destructor
00019 CActiveTimer::~CActiveTimer()
00020     {
00021         Cancel();
00022     iTimer.Close();
00023     }
00024 
00025 
00026 // Initiates the asynchronous timer request and sets the active object
00027 // ready to handle its completion
00028 void CActiveTimer::After(TTimeIntervalMicroSeconds32 anInterval)
00029     {
00030     iTimer.After(iStatus, anInterval);
00031     SetActive();
00032     }
00033 
00034 
00035 // Handles the completion of the asynchronous timer request
00036 void CActiveTimer::RunL()
00037     {
00038     iNotifier.TimerComplete(iStatus.Int());
00039     }
00040 
00041 
00042 // Handles the cleanup necessary if the 
00043 // asynchronous timer request is cancelled
00044 void CActiveTimer::DoCancel()
00045     {
00046     iTimer.Cancel();
00047     }
00048 
00049 
00050 // C++ constructor
00051 CActiveTimer::CActiveTimer(MActiveTimerNotify& aNotifier) : 
00052     CActive(EPriorityStandard),
00053     iNotifier(aNotifier)
00054     {
00055     CActiveScheduler::Add(this);
00056     }
00057 
00058 
00059 // Second-phase constructor
00060 void CActiveTimer::ConstructL()
00061     {
00062     User::LeaveIfError(iTimer.CreateLocal());
00063     }
00064 
00065 // End of file

Generated by  doxygen 1.6.2