Update contrib.
1 #ifndef __BASIC_WATCHER_H
2 #define __BASIC_WATCHER_H
5 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
7 * This component and the accompanying materials are made available
8 * under the terms of the License "Eclipse Public License v1.0"
9 * which accompanies this distribution, and is available
10 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
12 * Initial Contributors:
13 * Nokia Corporation - initial contribution.
18 * @file BasicWatcher.h
28 #include "testdebug.h"
30 namespace NUnitTesting_USBDI
35 This class watches for asynchronous completions and calls back
37 class CBasicWatcher : public CActive
40 CBasicWatcher(const TCallBack& aCallBack,TInt aPriority=EPriorityStandard);
41 virtual ~CBasicWatcher();
43 void CompleteNow(TInt aCompletionCode = KErrNone);
46 protected: // From CActive
49 TInt RunError(TInt aError);
61 This class describes a watcher for resumptions of interfaces
63 class CInterfaceWatcher : public CActive
68 @param aInterface the usb interface to suspend
69 @param aCallBack the call back object to call once a resumption signal has happened
71 CInterfaceWatcher(RUsbInterface& aInterface,const TCallBack& aCallBack)
72 : CActive(EPriorityUserInput),
73 iUsbInterface(aInterface),
74 iResumeCallBack(aCallBack),
75 iCompletionCode(KErrNone)
77 CActiveScheduler::Add(this);
89 Suspend the interface and watch for resumtions
91 void SuspendAndWatch()
93 iUsbInterface.PermitSuspendAndWaitForResume(iStatus);
98 Obtains the most recent completion code for the interface resumption
100 @return the completion error code
102 TInt CompletionCode() const
104 return iCompletionCode;
107 protected: // From CActive
114 iUsbInterface.CancelPermitSuspend();
123 iCompletionCode = iStatus.Int();
124 User::LeaveIfError(iResumeCallBack.CallBack());
139 The USB interface resource
141 RUsbInterface& iUsbInterface;
145 TCallBack iResumeCallBack;
149 TInt iCompletionCode;