|
1 /* |
|
2 * Copyright (c) 2006 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: Implements the buffer timeout logic specific to the speech item |
|
15 * trainer. Is notified about the speech item trainer action requests, |
|
16 * and decides when to actually fire the buffered actions |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef NSSVASCTRAININGACTIONTRACKER_H |
|
22 #define NSSVASCTRAININGACTIONTRACKER_H |
|
23 |
|
24 #include <e32base.h> |
|
25 |
|
26 /** |
|
27 * An interface for the objects to be notifiable by the CNssTrainingActionTracker |
|
28 */ |
|
29 class MDelayedNotifiable |
|
30 { |
|
31 public: |
|
32 virtual void RunBufferedActionsL() = 0; |
|
33 }; |
|
34 |
|
35 /** |
|
36 * Implements the buffer timeout logic specific to the speech item |
|
37 * trainer. Is notified about the speech item trainer action requests, |
|
38 * and decides when to actually fire the buffered actions |
|
39 */ |
|
40 NONSHARABLE_CLASS( CNssTrainingActionTracker ) : public CTimer |
|
41 { |
|
42 public: |
|
43 static CNssTrainingActionTracker* NewL( MDelayedNotifiable& aNotifiable ); |
|
44 |
|
45 /** |
|
46 * Is called by the client to notify tracker about the request to |
|
47 * perform a potentially bufferable action. It is up to tracker |
|
48 * when to stop recording the action requests and fire the |
|
49 * delayed actions via MDelayedNotifiable::DoBufferedActionsL |
|
50 * |
|
51 * DoBufferedActionsL is always called asynchronously. Even if tracker |
|
52 * decides to fire the delayable actions immediately |
|
53 */ |
|
54 void ActionRequestedL(); |
|
55 |
|
56 ~CNssTrainingActionTracker(); |
|
57 |
|
58 protected: |
|
59 |
|
60 // Fired when timer is expired |
|
61 void RunL(); |
|
62 |
|
63 private: |
|
64 CNssTrainingActionTracker( MDelayedNotifiable& aNotifiable ); |
|
65 |
|
66 void ConstructL(); |
|
67 |
|
68 /** |
|
69 * static callback required by CAsyncCallBack* iAsyncCallback |
|
70 * @param pX A pointer to this object |
|
71 */ |
|
72 static TInt FireActionsImmediately( TAny* pX ); |
|
73 |
|
74 /** |
|
75 * Call back the host |
|
76 */ |
|
77 void DoFireActionsL(); |
|
78 |
|
79 /** |
|
80 * Another action requested. Start waiting [again] |
|
81 */ |
|
82 void RestartTimer(); |
|
83 |
|
84 private: |
|
85 // Observer |
|
86 MDelayedNotifiable& iHost; |
|
87 |
|
88 // Utility for firing the action immediately, but asynchronously |
|
89 CAsyncCallBack* iAsyncCallback; |
|
90 |
|
91 // ETrue when tracker has some actions to fire in the queue |
|
92 TBool iUnfiredActions; |
|
93 }; |
|
94 |
|
95 #endif // NSSVASCTRAININGACTIONTRACKER_H |
|
96 |
|
97 // End of file |