os/ossrv/genericopenlibs/posixrealtimeextensions/inc/timer.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// timer header file
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
sl@0
    19
#ifndef __TIMER__H
sl@0
    20
#define __TIMER__H
sl@0
    21
sl@0
    22
#include <e32base.h>
sl@0
    23
#include <time.h>
sl@0
    24
#include <signal.h>
sl@0
    25
sl@0
    26
#define MAXTIMERLIMIT 512
sl@0
    27
#define DELAYTIMER_MAX 32
sl@0
    28
sl@0
    29
class CTimerReqHandler;	
sl@0
    30
class CRtTimer;
sl@0
    31
class CTimerServer;
sl@0
    32
NONSHARABLE_CLASS(CLibRtTimer): public CTimer
sl@0
    33
	{
sl@0
    34
	public:
sl@0
    35
	CLibRtTimer():CTimer(EPriorityHigh)
sl@0
    36
		{
sl@0
    37
		}
sl@0
    38
	void ConstructL()
sl@0
    39
		{
sl@0
    40
		CTimer::ConstructL();
sl@0
    41
		}
sl@0
    42
	void At(TTime aSetTime)
sl@0
    43
		{
sl@0
    44
		CTimer::At(aSetTime);
sl@0
    45
		}
sl@0
    46
	inline void Set(CRtTimer* CRtPtr)
sl@0
    47
		{
sl@0
    48
		ptr = CRtPtr;
sl@0
    49
		}
sl@0
    50
	inline CRtTimer* GetRtPtr()
sl@0
    51
	{
sl@0
    52
		return ptr;
sl@0
    53
	}
sl@0
    54
	void AddToAS();
sl@0
    55
	private:
sl@0
    56
		void RunL();
sl@0
    57
		CRtTimer* ptr;
sl@0
    58
	};
sl@0
    59
sl@0
    60
class CRtTimer:public CBase
sl@0
    61
{
sl@0
    62
public: 
sl@0
    63
	friend class CTimerReqHandler;	
sl@0
    64
	friend class CTimerServer;
sl@0
    65
	friend class CLibRtTimer;
sl@0
    66
	static CRtTimer* New(struct sigevent *aSig);	
sl@0
    67
	TInt SetTime(TInt aFlag, const struct itimerspec *aIpTime,
sl@0
    68
				 struct itimerspec *aOpTime);			 
sl@0
    69
	TInt Time(struct itimerspec *aTime) const;
sl@0
    70
	TInt OverrunCount(TInt& aOverrunCount) const;	
sl@0
    71
	virtual ~CRtTimer();
sl@0
    72
protected: 
sl@0
    73
sl@0
    74
	CRtTimer(struct sigevent *aSig);
sl@0
    75
private:
sl@0
    76
	CLibRtTimer iTimer;
sl@0
    77
	
sl@0
    78
	TInt iTimerId;
sl@0
    79
	TBool iIsArmed;
sl@0
    80
	TBool iIsTimerReset;
sl@0
    81
sl@0
    82
	struct sigevent iSigEvent;
sl@0
    83
	struct itimerspec iStartTime;
sl@0
    84
	struct timespec iEndTime;
sl@0
    85
};
sl@0
    86
#endif //__TIMER__H
sl@0
    87