realtimenetprots/sipfw/SIP/LightWeightTimer/src/timerrequest.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Name          : timerrequest.h
       
    16 * Part of       : LightWeightTimer
       
    17 * Private header file for the Lightweight timer subsystem.
       
    18 * Version       : SIP/4.0
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 /**
       
    26  @internalComponent
       
    27 */
       
    28 
       
    29 #ifndef C_TIMERREQUEST_H
       
    30 #define C_TIMERREQUEST_H
       
    31 
       
    32 // INCLUDES
       
    33 #include <e32base.h>
       
    34 #include "Lwtimer.h"
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 
       
    38 // CLASS DECLARATION
       
    39 /*
       
    40  * This class stores information of a single timer request.
       
    41  */
       
    42 class CTimerRequest : public CBase
       
    43 	{
       
    44 public: // Constructors and destructor
       
    45 
       
    46 	/**
       
    47 	 * Creates a new CTimerRequest object with empty values.
       
    48 	 * This version is used for searching through the stored timer requests.
       
    49 	 *
       
    50 	 * @return New CTimerRequest object, ownership is transferred.
       
    51 	 */
       
    52 	static CTimerRequest* NewL();
       
    53 
       
    54 	/**
       
    55 	 * Creates new CTimerRequest object.
       
    56 	 *
       
    57 	 * @pre	aObserver != NULL
       
    58 	 *
       
    59 	 * @param aTimerId TimerId of the timer request
       
    60 	 * @param aExpirationTime Time when the timer will expire
       
    61 	 * @param aObserver When the timer expires, this object is used to inform
       
    62 	 *	about it. Ownership isn't transferred.
       
    63 	 * @param aTimerParam User specified value which is passed to expiration
       
    64 	 *	handler when the timer expires. Ownership isn't transferred.
       
    65 	 * @return New CTimerRequest object, ownership is transferred.
       
    66 	 */
       
    67 	static CTimerRequest* NewL(TTimerId aTimerId,
       
    68 							   TTime aExpirationTime,
       
    69 							   MExpirationHandler* aObserver,
       
    70 							   TAny* aTimerParam);
       
    71 
       
    72 	~CTimerRequest();
       
    73 	
       
    74 public: // New functions
       
    75 
       
    76 	/**
       
    77 	 * Compares the expiration times of two timer requests.
       
    78 	 *
       
    79 	 * @param aItem Timer request whose expiration time is compared with aItem2
       
    80 	 * @param aItem2 Another timer request
       
    81 	 * @return value
       
    82 	 *	0  = expiration times are equal
       
    83 	 *  1  = expiration time of aItem2 occurs before expiration time of aItem
       
    84 	 *  -1 = expiration time of aItem occurs before expiration time of aItem2
       
    85 	 */
       
    86 	static TInt Compare(const CTimerRequest& aItem,
       
    87 						const CTimerRequest& aItem2);
       
    88 
       
    89 	/**
       
    90 	 * Compares the TimerIds of two timer requests.
       
    91 	 *
       
    92 	 * @param aItem Timer request whose TimerId is compared with aItem2
       
    93 	 * @param aItem2 Another timer request
       
    94 	 * @return value ETrue if TimerIds are same, EFalse otherwise	 
       
    95 	 */
       
    96 	static TBool CompareId(const CTimerRequest& aItem,
       
    97 						   const CTimerRequest& aItem2);
       
    98 
       
    99 	/**
       
   100 	 * Retrieves the TimerId of the timer request.
       
   101 	 *	 
       
   102 	 * @return value TimerId
       
   103 	 */
       
   104 	TTimerId TimerId() const;
       
   105 
       
   106 	/**
       
   107 	 * Set the TimerId value of the timer request.
       
   108 	 *
       
   109 	 * @param aTimerId Value for TimerId
       
   110 	 */
       
   111 	void SetTimerId(TTimerId aTimerId);
       
   112 
       
   113 	/**
       
   114 	 * Retrieves the expiration time of the timer request.	 
       
   115 	 *	 
       
   116 	 * @return value Time when the timer will expire
       
   117 	 */
       
   118 	TTime ExpirationTime() const;
       
   119 
       
   120 	/**
       
   121 	 * Retrieve the observer callback.
       
   122 	 *
       
   123 	 * @return value Expiration observer. Ownership is not transferred.
       
   124 	 */
       
   125 	MExpirationHandler* Observer();
       
   126 
       
   127 	/**
       
   128 	 * Retrieves the user specified value, given when the timer was created.
       
   129 	 *
       
   130 	 * @return value User specified timer parameter. Ownership isn't
       
   131      *  transferred.
       
   132 	 */
       
   133 	TAny* TimerParam();
       
   134 
       
   135 private: // Constructors
       
   136 
       
   137 	CTimerRequest();
       
   138 
       
   139 	CTimerRequest(TTimerId aTimerId,
       
   140 				  TTime aExpirationTime,
       
   141 				  MExpirationHandler* aObserver,
       
   142 				  TAny* aTimerParam);
       
   143 
       
   144 private: // Data
       
   145 
       
   146 	//Default key offset is zero. iTimerId is the search key.
       
   147 	//TimerId is used for identifying the logical timer.
       
   148 	TTimerId iTimerId;
       
   149 
       
   150 	//Expiration time of the timer
       
   151 	TTime iExpirationTime;
       
   152 
       
   153 	//Callback to use when the timer expires. Not owned.
       
   154 	MExpirationHandler* iObserver;
       
   155 
       
   156 	//Optional parameter specified by the user when the timer was set.
       
   157 	//If not specified, the value is NULL.
       
   158 	//The interpretation of this pointer is left to the application.
       
   159 	//CTimerRequest doesn't own the resource pointed by iTimerParam.
       
   160 	TAny* iTimerParam;
       
   161 
       
   162 private: // For testing purposes
       
   163 
       
   164 #ifdef CPPUNIT_TEST	
       
   165 	friend class CTimerManager_test;
       
   166 	friend class CTimerStore_test;
       
   167 	friend class CTimerRequest_test;
       
   168 #endif
       
   169 	};
       
   170 
       
   171 #endif // C_TIMERREQUEST_H
       
   172 
       
   173 // End of File