1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/posixrealtimeextensions/inc/timermessage.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,81 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// timer message header file
1.18 +//
1.19 +//
1.20 +
1.21 +
1.22 +#ifndef __TIMERMESSAGE__H
1.23 +#define __TIMERMESSAGE__H
1.24 +
1.25 +#include <e32des8.h>
1.26 +const TInt KTimerMsgMaxLen = 12;
1.27 +
1.28 +//encapsulates the timer request message.
1.29 +class TRtTimerMsg
1.30 +{
1.31 +public:
1.32 + TRtTimerMsg(const TInt& aTimerId, const TInt& aAction = 0): iTimerId(aTimerId), iRqstAct(aAction){}
1.33 + TRtTimerMsg(){}
1.34 + inline TInt Serialize(TDes8& aTo) const;
1.35 + inline TInt DeSerialize(const TDes8& aFrom);
1.36 +
1.37 + enum
1.38 + {
1.39 + EDELETETIMER = 2,
1.40 + }TRqstAction;
1.41 +
1.42 + TInt iTimerId; // timer id
1.43 + TInt iRqstAct;
1.44 +};
1.45 +
1.46 +//serialize the timer request.
1.47 +TInt TRtTimerMsg::Serialize(TDes8& aTo) const
1.48 + {
1.49 + TInt lRet = KErrNone;
1.50 + if(aTo.MaxSize() != KTimerMsgMaxLen)
1.51 + lRet = KErrArgument;
1.52 + else
1.53 + {
1.54 + TUint8 lBuf[KTimerMsgMaxLen];
1.55 + Mem::FillZ(&lBuf[0], KTimerMsgMaxLen);
1.56 +
1.57 + Mem::Copy(&lBuf[0], &iTimerId, sizeof(TInt));
1.58 + Mem::Copy(&lBuf[sizeof (TInt)], &iRqstAct, sizeof(TInt));
1.59 +
1.60 + aTo.Zero();
1.61 + aTo.Append(lBuf,KTimerMsgMaxLen);
1.62 + }
1.63 +
1.64 + return lRet;
1.65 + }
1.66 +
1.67 +//deserialize the timer request.
1.68 +TInt TRtTimerMsg::DeSerialize(const TDes8& aFrom)
1.69 + {
1.70 + TInt lRet = KErrNone;
1.71 + if(aFrom.MaxSize() != KTimerMsgMaxLen)
1.72 + lRet = KErrArgument;
1.73 + else
1.74 + {
1.75 + const TUint8* lBuf = aFrom.Ptr();
1.76 + Mem::Copy(&iTimerId, &lBuf[0], sizeof(TInt));
1.77 + Mem::Copy(&iRqstAct, &lBuf[sizeof (TInt)], sizeof(TInt));
1.78 + }
1.79 +
1.80 + return lRet;
1.81 + }
1.82 +
1.83 +#endif // __TIMERMESSAGE__H
1.84 +