|
1 /* |
|
2 * Copyright (c) 2002-2009 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: |
|
15 * Name : DeleteMgr.h |
|
16 * Part of : SIPCommon |
|
17 * Version : SIP/2.0 |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 @internalComponent |
|
26 */ |
|
27 |
|
28 |
|
29 #ifndef DELETEMGR_H |
|
30 #define DELETEMGR_H |
|
31 |
|
32 #include <e32base.h> |
|
33 #include <e32std.h> |
|
34 |
|
35 |
|
36 //Panic reasons |
|
37 enum TDeleteMgrPanic |
|
38 { |
|
39 EDeleteMgrFncPrecondNotMet |
|
40 }; |
|
41 |
|
42 |
|
43 /* |
|
44 * CDeleteMgr is an active object handling the deletion of CBase-derived |
|
45 * objects asyncronously, avoiding the need to use constructs like |
|
46 * "delete this". |
|
47 * Using CDeleteMgr for freeing the memory guarantees that the call stack |
|
48 * won't include any code from the object that is to be deleted. |
|
49 */ |
|
50 class CDeleteMgr : public CActive |
|
51 { |
|
52 public: |
|
53 /** |
|
54 * Creates a new object. |
|
55 * |
|
56 * @pre |
|
57 * @post |
|
58 * |
|
59 * @see |
|
60 * |
|
61 * @return value New CDeleteMgr object. Ownership is transferred. |
|
62 */ |
|
63 static CDeleteMgr* NewL(); |
|
64 |
|
65 |
|
66 /** |
|
67 * Frees the resources of CDeleteMgr. Any delete requests which have been |
|
68 * issued, but not yet executed, are also done. |
|
69 * |
|
70 * @pre |
|
71 * @post |
|
72 * |
|
73 * @see |
|
74 * |
|
75 * @return value - |
|
76 */ |
|
77 ~CDeleteMgr(); |
|
78 |
|
79 |
|
80 /** |
|
81 * Request an asynchronous deletion of memory. The memory will be freed |
|
82 * when the CDeleteMgr::RunL() will be called by the Active Scheduler. |
|
83 * |
|
84 * @pre aItemToDelete != NULL, aItemToDelete != this CDeleteMgr instance |
|
85 * itself, pointer to an object can't be added more than once |
|
86 * |
|
87 * @param aItemToDelete CBase derived object to be deleted. Ownership is |
|
88 * transferred. |
|
89 * @return value KErrNone if successful, otherwise a system wide error code |
|
90 */ |
|
91 TInt AddDeleteRequest(const CBase* aItemToDelete); |
|
92 |
|
93 |
|
94 //from CActive: |
|
95 void DoCancel(); |
|
96 void RunL(); |
|
97 TInt RunError(TInt aError); |
|
98 |
|
99 private: |
|
100 CDeleteMgr(); |
|
101 |
|
102 |
|
103 /** |
|
104 * Starts waiting for AddDeleteRequest() events. |
|
105 * |
|
106 * @pre |
|
107 * |
|
108 * @return value - |
|
109 */ |
|
110 void WaitForRequests(); |
|
111 |
|
112 |
|
113 //Pointers which have not yet been deleted are stored here |
|
114 RPointerArray<CBase> iDeleteRequests; |
|
115 |
|
116 |
|
117 #ifdef CPPUNIT_TEST |
|
118 friend class CDeleteMgrTest; |
|
119 friend class CUserAgentClient_Test; |
|
120 friend class CNormalUAC_ResolveAddress_Test; |
|
121 friend class CNormalUAC_WaitResponse_Test; |
|
122 friend class CNormalUAS_Start_Test; |
|
123 #endif |
|
124 }; |
|
125 |
|
126 #endif // end of DELETEMGR_H |
|
127 |
|
128 // End of File |