|
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: Singleton base class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CCASingletonPC.h" |
|
22 #include <e32std.h> |
|
23 |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CCASingletonPC::CCASingletonPC |
|
29 // C++ default constructor can NOT contain any code, that |
|
30 // might leave. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CCASingletonPC::CCASingletonPC() |
|
34 { |
|
35 } |
|
36 |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CCASingletonPC::~CCASingletonPC |
|
40 // Destructor |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CCASingletonPC::~CCASingletonPC() |
|
44 { |
|
45 Dll::SetTls( NULL ); |
|
46 } |
|
47 |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CCASingletonPC::BaseInstanceL() |
|
51 // (other items were commented in a header). |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 TAny* CCASingletonPC::BaseInstanceL() |
|
55 { |
|
56 TAny* instance = Dll::Tls(); |
|
57 if ( !instance ) |
|
58 { |
|
59 instance = ConstructSingletonInstanceL(); |
|
60 TInt err( Dll::SetTls( instance ) ); |
|
61 if ( err == KErrNone ) |
|
62 { |
|
63 return instance; |
|
64 } |
|
65 else |
|
66 { |
|
67 delete instance; |
|
68 User::Leave( err ); |
|
69 return NULL; // this line just keeps the compiler happy |
|
70 } |
|
71 } |
|
72 else |
|
73 { |
|
74 return instance; |
|
75 } |
|
76 } |
|
77 |
|
78 // End of File |