|
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: Handler for singleton objects |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32std.h> |
|
22 |
|
23 #include "npppsysingletonhandler.h" |
|
24 #include "npppsystatushandler.h" |
|
25 #include "npppsysettinghandler.h" |
|
26 #include "npppsylogging.h" |
|
27 #include "npppsypanic.h" |
|
28 |
|
29 |
|
30 // ======================== == == MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // Cnpppsysingletonhandler::GetInstanceL |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CNppPsySingletonHandler* CNppPsySingletonHandler::GetInstanceL( |
|
37 MPositionerStatus& aStatusInterface ) |
|
38 { |
|
39 TRACESTRING( "CNppPsySingletonHandler:: GetInstanceL" ) |
|
40 CNppPsySingletonHandler* self = |
|
41 reinterpret_cast < CNppPsySingletonHandler*>( Dll::Tls() ); |
|
42 |
|
43 if ( !self ) |
|
44 { |
|
45 self = new( ELeave ) CNppPsySingletonHandler; |
|
46 CleanupStack::PushL( self ); |
|
47 self->ConstructL( aStatusInterface ); |
|
48 CleanupStack::Pop( self ); |
|
49 Dll::SetTls( self ); |
|
50 } |
|
51 |
|
52 self->iRefCount++; |
|
53 return self; |
|
54 } |
|
55 |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CNppPsySingletonHandler::ConstructL |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void CNppPsySingletonHandler::ConstructL( MPositionerStatus& aStatusInterface ) |
|
62 { |
|
63 //Construct status handler |
|
64 iStatusHandler = CNppPsyStatusHandler::NewL( aStatusInterface ); |
|
65 |
|
66 //Construct setting handler |
|
67 iSettingHandler = CNppPsySettingHandler::NewL( *iStatusHandler ); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CNppPsySingletonHandler::~CNppPsySingletonHandler |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CNppPsySingletonHandler::~CNppPsySingletonHandler() |
|
75 { |
|
76 delete iSettingHandler; |
|
77 delete iStatusHandler; |
|
78 } |
|
79 |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CNppPsySingletonHandler::ReleaseInstance |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CNppPsySingletonHandler::ReleaseInstance() |
|
86 { |
|
87 iRefCount--; |
|
88 if ( iRefCount == 0 ) |
|
89 { |
|
90 delete this; |
|
91 Dll::SetTls( NULL ); |
|
92 } |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CNppPsySingletonHandler::StatusHandler |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 CNppPsyStatusHandler& CNppPsySingletonHandler::StatusHandler() |
|
100 { |
|
101 return *iStatusHandler; |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CNppPsySingletonHandler::SettingHandler |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 CNppPsySettingHandler& CNppPsySingletonHandler::SettingHandler() |
|
109 { |
|
110 return *iSettingHandler; |
|
111 } |
|
112 |
|
113 |
|
114 // End of File |
|
115 |