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