integersummationthread.h

来自「基于Symbian平台下随心所欲控制屏幕的灯亮熄.在观看视频和发短信时这一点非常」· C头文件 代码 · 共 113 行

H
113
字号
// CLASS DECLARATION
/**
*
* CIntegerSummationThread IntegerSummationThread.h
* This is a class to that adds the first n integers 
* It uses the idea of Active Objects to split up what would be a long task.
*
* Copyright (c) 2004 Nokia Corporation
* version 2.0
*/

#ifndef __INTEGERSUMMATIONTHREAD_H__
#define __INTEGERSUMMATIONTHREAD_H__

// INCLUDES

// System includes
#include <e32base.h>
#include "SummationObserver.h"



class CIntegerSummationThread : public CActive
	{

enum TPanicCode
	{
	EUnableToCreateThread	// engine was unable to create the thread 
	};

public:	// Construction and destruction.
    /**
     * Function:    NewL
     * Description: Creates instance of CIntegerSummationThread object
	 * Params: aObserver. Observer to be notified when summation is complete 
     */
	static CIntegerSummationThread* NewL(MSummationObserver& aObserver);

    /**
     * Function:    ~CIntegerSummationThread
     * Description: Destroys CIntegerSummationThread object
     */
	~CIntegerSummationThread();

public:	// Methods.
    /**
     * Function:    StartSum
     * Description: This function is called to initiate the calculation
     */
	void StartSum();

    /**
     * Function:    StartSum
     * Description: This function is called to carry out the whole calculation
     */
	void DoSum();

private:	// Construction.
    /**
     * Function:    CIntegerSummationThread
     * Description: Constructor
	 * Params: aObserver. Observer to be notified when summation is complete 
     */
	CIntegerSummationThread(MSummationObserver& aObserver);

    /**
     * Function:    ConstructL
     * Description: 2nd Phase Constructor
     */
	void ConstructL();

private:	// From CActive.
    /**
     * Function:    RunL
     * Description: This will be called once the thread has completed
	 *              The appropriate cleanup will be done and the obderver notified
     */
	void RunL();

    /**
     * Function:    DoCancel
     * Description: // Cancel outstanding request - called by Cancel()
     */
	void DoCancel();

private:
    /**
     * Function:    Completed
     * Description: Called when the task is complete
	 *              Notifies the observer of the result
     *
     */
	void Completed();

    /**
     * Function:    Panic
     * Description: Panics the application when an unrecoverable
	 *              error has occurred
	 * Params:      aReason. The panic code.
     */
	void Panic(TPanicCode aReason) const;

	
private:	// Data.
	RThread	iThread;
	TInt	iTotal;
	MSummationObserver& iObserver;
	};

#endif	// __INTEGERSUMMATIONTHREAD_H__

// End of File

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?