|
1 /* |
|
2 * Copyright (c) 2005-2009 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: A singleton that provides system unique ID's* |
|
15 */ |
|
16 |
|
17 #ifndef __MDSINDEXER_H__ |
|
18 #define __MDSINDEXER_H__ |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 #include <e32cmn.h> |
|
23 |
|
24 #include "mdccommon.h" |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class RRowData; |
|
28 |
|
29 |
|
30 // CLASS DECLARATION |
|
31 /** |
|
32 * A static class that is used to provide system unique |
|
33 * ID's for database storage purposes. |
|
34 */ |
|
35 class MMdSIndexer |
|
36 { |
|
37 public: // Public functions |
|
38 |
|
39 /** |
|
40 * Gets last object id from DB |
|
41 * MUST be called once, when connection to DB is established |
|
42 */ |
|
43 static TItemId StartIndexL(); |
|
44 |
|
45 /** |
|
46 * Provides a new system unique ID |
|
47 * @return a new system-wide unique ID |
|
48 */ |
|
49 static TItemId GetIndex( ); |
|
50 |
|
51 /** |
|
52 * Reverts system ID to previous state |
|
53 * used when add item failed |
|
54 */ |
|
55 static void RevertIndex( ); |
|
56 |
|
57 /** |
|
58 * Executes a SQL clause and returns the ID of the last object in DB. |
|
59 * @param aSqlClause SQL clause to execute |
|
60 * @param aRowData query parameters |
|
61 * @return result of last_insert_rowid() |
|
62 */ |
|
63 static TItemId ExecuteAndGetIndexL(const TDesC &aSqlClause, const RRowData &aRowData ); |
|
64 |
|
65 private: |
|
66 static TItemId GetIndexL(); |
|
67 |
|
68 static void GetLastItemIdL(); |
|
69 |
|
70 static TItemId iId; |
|
71 }; |
|
72 |
|
73 class RSQLIndex |
|
74 { |
|
75 public: |
|
76 RSQLIndex(); |
|
77 |
|
78 const TItemId& GetId() const; |
|
79 |
|
80 void Commit(); |
|
81 |
|
82 void Close(); |
|
83 |
|
84 private: |
|
85 const TItemId iId; |
|
86 TBool iCommit; |
|
87 }; |
|
88 |
|
89 #endif // __MDSINDEXER_H__ |