|
1 /* |
|
2 * Copyright (c) 2005 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: Class compacting a landmark database in steps. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "EPos_CPosLmCompactDatabase.h" |
|
22 #include "EPos_CPosLmLocalDbAccess.h" |
|
23 |
|
24 // CONSTANTS |
|
25 const TReal32 KOperationDone = 1; |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CPosLmCompactDatabase::CPosLmCompactDatabase |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CPosLmCompactDatabase::CPosLmCompactDatabase() : |
|
36 CBase() |
|
37 { |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CPosLmCompactDatabase::ConstructL |
|
42 // Symbian 2nd phase constructor can leave. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 void CPosLmCompactDatabase::ConstructL( |
|
46 CPosLmLocalDbAccess& aDbAccess) |
|
47 { |
|
48 RDbNamedDatabase db; |
|
49 aDbAccess.GetDatabase(db); |
|
50 User::LeaveIfError(iDbIncremental.Compact(db, iIncrementalStep)); |
|
51 iIncrementalStartValue = iIncrementalStep; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CPosLmCompactDatabase::NewL |
|
56 // Two-phased constructor. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 EXPORT_C CPosLmCompactDatabase* CPosLmCompactDatabase::NewL( |
|
60 CPosLmLocalDbAccess& aDbAccess) |
|
61 { |
|
62 CPosLmCompactDatabase* self = new( ELeave ) CPosLmCompactDatabase(); |
|
63 CleanupStack::PushL(self); |
|
64 self->ConstructL(aDbAccess); |
|
65 CleanupStack::Pop(self); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // Destructor |
|
70 CPosLmCompactDatabase::~CPosLmCompactDatabase() |
|
71 { |
|
72 iDbIncremental.Close(); |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CPosLmCompactDatabase::NextL |
|
77 // |
|
78 // (other items were commented in a header). |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 EXPORT_C TBool CPosLmCompactDatabase::NextL( |
|
82 TReal32& aProgress) |
|
83 { |
|
84 User::LeaveIfError(iDbIncremental.Next(iIncrementalStep)); |
|
85 |
|
86 if (iIncrementalStartValue == 0 || iIncrementalStep == 0) |
|
87 { |
|
88 aProgress = KOperationDone; |
|
89 iDbIncremental.Close(); |
|
90 return ETrue; |
|
91 } |
|
92 |
|
93 aProgress = TReal32((iIncrementalStartValue - iIncrementalStep)) / |
|
94 iIncrementalStartValue; |
|
95 |
|
96 return EFalse; |
|
97 } |
|
98 |
|
99 // End of File |