33
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-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: Provides way to notify events and register observers
|
|
15 |
* for events
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#ifndef TSATEVENTMEDIATOR_H
|
|
22 |
#define TSATEVENTMEDIATOR_H
|
|
23 |
|
|
24 |
// INCLUDES
|
|
25 |
#include <e32base.h>
|
|
26 |
|
|
27 |
// FORWARD DECLARATIONS
|
|
28 |
class MSatEventObserver;
|
|
29 |
class TSatEventsObserver;
|
|
30 |
|
|
31 |
// CLASS DECLARATION
|
|
32 |
|
|
33 |
/**
|
|
34 |
* Provides way to notify events and register observers for events.
|
|
35 |
* Observers are not owned by this class and therefore observers are
|
|
36 |
* not deleted when TSatEventMediator instance is destroyed.
|
|
37 |
*
|
|
38 |
* @lib SatEngine.dll
|
|
39 |
* @since Series 60 3.0
|
|
40 |
*/
|
|
41 |
class TSatEventMediator
|
|
42 |
{
|
|
43 |
public: // Constructors and destructor
|
|
44 |
|
|
45 |
/**
|
|
46 |
* C++ default constructor.
|
|
47 |
*/
|
|
48 |
TSatEventMediator();
|
|
49 |
|
|
50 |
public: // New functions
|
|
51 |
|
|
52 |
/**
|
|
53 |
* Notifies possible observers who are observing the event.
|
|
54 |
* @param aEvent Integer identifying the event.
|
|
55 |
* @return None
|
|
56 |
*/
|
|
57 |
void Notify( TInt aEvent );
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Registers observer for event. Same observer will not be added
|
|
61 |
* more than once for one event.
|
|
62 |
* @param aObserver Pointer of observer instance. Panic will occur if
|
|
63 |
* aObserver is NULL.
|
|
64 |
* @param aEvent Event, which will cause the notification of observer.
|
|
65 |
* @return None
|
|
66 |
*/
|
|
67 |
void RegisterL( MSatEventObserver* aObserver, TInt aEvent );
|
|
68 |
|
|
69 |
/**
|
|
70 |
* Unregisters the notification of single event.
|
|
71 |
* @param aObserver Observer, whom event registeration will be
|
|
72 |
* unregistered.
|
|
73 |
* @param aEvent Event, which will be unregistered.
|
|
74 |
* @return None
|
|
75 |
*/
|
|
76 |
void Unregister( const MSatEventObserver* aObserver, TInt aEvent );
|
|
77 |
|
|
78 |
/**
|
|
79 |
* Unregisters the event observer.
|
|
80 |
* @param aObserver Observer, whom event registeration will be
|
|
81 |
* unregistered.
|
|
82 |
*/
|
|
83 |
void Unregister( const MSatEventObserver* aObserver );
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Resets the list of event observers. Used instead of destructor
|
|
87 |
*/
|
|
88 |
void Reset();
|
|
89 |
|
|
90 |
private: // New functions
|
|
91 |
|
|
92 |
/**
|
|
93 |
* Checks if aObserver is already in the list of observers.
|
|
94 |
* @param aObserver Observer that is checked from the list.
|
|
95 |
* @return Pointer of the observer, where aObserver is registered.
|
|
96 |
* Contains NULL pointer if aObserver is not already registered.
|
|
97 |
*/
|
|
98 |
TSatEventsObserver* HasObserverInstance(
|
|
99 |
const MSatEventObserver* aObserver ) const;
|
|
100 |
|
|
101 |
/**
|
|
102 |
* Deletes all observers marked as deleted during notify loop
|
|
103 |
*/
|
|
104 |
void DeleteMarkedObservers();
|
|
105 |
|
|
106 |
private:
|
|
107 |
|
|
108 |
// Prohibit copy constructor if not deriving from CBase.
|
|
109 |
TSatEventMediator( const TSatEventMediator& );
|
|
110 |
|
|
111 |
// Prohibit assigment operator if not deriving from CBase.
|
|
112 |
TSatEventMediator& operator=( const TSatEventMediator& );
|
|
113 |
|
|
114 |
private: // Data
|
|
115 |
|
|
116 |
// event observers.
|
|
117 |
RPointerArray<TSatEventsObserver> iEventsObservers;
|
|
118 |
|
|
119 |
// Indicates are we notifying observers. If this flag is on,
|
|
120 |
// observers cannot be removed from iEventsObservers. After
|
|
121 |
// notify loop is done, observers can be replaced again
|
|
122 |
TBool iIsNotifying;
|
|
123 |
|
|
124 |
// Indicates are there any observers marked as deleted during
|
|
125 |
// Notify loop
|
|
126 |
TBool iDeletionsMarked;
|
|
127 |
};
|
|
128 |
|
|
129 |
#endif // TSATEVENTMEDIATOR_H
|
|
130 |
|
|
131 |
// End of File
|