equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Contains CCatalogsRefString |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CATALOGSREFERENCEBASE_H |
|
20 #define C_CATALOGSREFERENCEBASE_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 template<class CBaseClass> |
|
25 class CCatalogsReferenceBase : public CBaseClass |
|
26 { |
|
27 public: |
|
28 |
|
29 TInt AddRef() const |
|
30 { |
|
31 return ++iRefCount; |
|
32 } |
|
33 |
|
34 TInt Release() const |
|
35 { |
|
36 TInt result = --iRefCount; |
|
37 if( result == 0 ) |
|
38 { |
|
39 delete this; |
|
40 } |
|
41 return result; |
|
42 } |
|
43 |
|
44 |
|
45 TInt RefCount() const |
|
46 { |
|
47 return iRefCount; |
|
48 } |
|
49 |
|
50 protected: |
|
51 |
|
52 CCatalogsReferenceBase () |
|
53 : iRefCount( 1 ) |
|
54 { |
|
55 } |
|
56 |
|
57 virtual ~CCatalogsReferenceBase() |
|
58 { |
|
59 } |
|
60 |
|
61 protected: |
|
62 |
|
63 mutable TInt iRefCount; |
|
64 |
|
65 }; |
|
66 |
|
67 |
|
68 template<> |
|
69 class CCatalogsReferenceBase<CActive> : public CActive |
|
70 { |
|
71 |
|
72 public: |
|
73 |
|
74 TInt AddRef() const |
|
75 { |
|
76 return ++iRefCount; |
|
77 } |
|
78 |
|
79 TInt Release() const |
|
80 { |
|
81 TInt result = --iRefCount; |
|
82 if( result == 0 ) |
|
83 { |
|
84 delete this; |
|
85 } |
|
86 return result; |
|
87 } |
|
88 |
|
89 TInt RefCount() const |
|
90 { |
|
91 return iRefCount; |
|
92 } |
|
93 |
|
94 protected: |
|
95 |
|
96 CCatalogsReferenceBase () : |
|
97 CActive( EPriorityStandard ), |
|
98 iRefCount( 1 ) |
|
99 { |
|
100 } |
|
101 |
|
102 virtual ~CCatalogsReferenceBase() |
|
103 { |
|
104 } |
|
105 |
|
106 protected: |
|
107 |
|
108 mutable TInt iRefCount; |
|
109 |
|
110 }; |
|
111 |
|
112 |
|
113 |
|
114 #endif // C_CATALOGSREFERENCEBASE_H |