|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __SQLITESYMBIAN_H__ |
|
17 #define __SQLITESYMBIAN_H__ |
|
18 |
|
19 #include <e32std.h> |
|
20 |
|
21 //Forward declarations |
|
22 class RFs; |
|
23 typedef struct sqlite3 sqlite3; |
|
24 |
|
25 TInt sqlite3SymbianLastOsError(void); |
|
26 TInt sqlite3SymbianLibInit(void); |
|
27 void sqlite3SymbianLibFinalize(void); |
|
28 RFs& sqlite3SymbianFs(void); |
|
29 |
|
30 TInt sqlite3SymbianProfilerStart(TInt aCounterType); |
|
31 TInt sqlite3SymbianProfilerStop(TInt aCounterType); |
|
32 TInt sqlite3SymbianProfilerReset(TInt aCounterType); |
|
33 TInt sqlite3SymbianProfilerQuery(TInt aCounterType, TDes8& aResult); |
|
34 |
|
35 /** |
|
36 The operation code for registering a free page callback. |
|
37 |
|
38 @see TSqlFreePageCallback |
|
39 |
|
40 @internalComponent |
|
41 */ |
|
42 const TInt KSqlFcntlRegisterFreePageCallback = 1000001; |
|
43 |
|
44 /** |
|
45 This structure is used for sending a request (via TVfs::FileControl()) to the OS porting layer to |
|
46 register a free page callback - TSqlFreePageCallback::iCallback, which will be called when the number of |
|
47 the free pages reaches or is above the threshold - TSqlFreePageCallback::iThreshold. |
|
48 |
|
49 @see TSqlFreePageCallback |
|
50 |
|
51 @internalComponent |
|
52 */ |
|
53 NONSHARABLE_STRUCT(TSqlFreePageCallback) |
|
54 { |
|
55 /** |
|
56 "Free page" callback type definition. |
|
57 */ |
|
58 typedef void (*TCallback)(void* aThis, TInt aFreePageCount); |
|
59 |
|
60 inline TSqlFreePageCallback(); |
|
61 inline TSqlFreePageCallback(void* aThis, TInt aFreePageThreshold, TCallback aCallback); |
|
62 inline TBool IsValid() const; |
|
63 inline void CheckAndCallback(TInt aFreePageCount) const; |
|
64 |
|
65 void* iThis; //"this" pointer of the object that has to be called back |
|
66 TInt iThreshold; //"free page threshold" in pages |
|
67 TCallback iCallback; //a pointer to the callback function |
|
68 |
|
69 }; |
|
70 |
|
71 /** |
|
72 Initalizes TSqlFreePageCallback data members with their default values. |
|
73 */ |
|
74 inline TSqlFreePageCallback::TSqlFreePageCallback() : |
|
75 iThis(NULL), |
|
76 iThreshold(0), |
|
77 iCallback(NULL) |
|
78 { |
|
79 } |
|
80 |
|
81 /** |
|
82 Initalizes TSqlFreePageCallback data members with the supplied callback values. |
|
83 |
|
84 @param aThis "this" pointer of the object that has to be called back, |
|
85 @param aThreshold "free page threshold" in pages, |
|
86 @param aCallback a pointer to the callback function; |
|
87 */ |
|
88 inline TSqlFreePageCallback::TSqlFreePageCallback(void* aThis, TInt aFreePageThreshold, TSqlFreePageCallback::TCallback aCallback) : |
|
89 iThis(aThis), |
|
90 iThreshold(aFreePageThreshold), |
|
91 iCallback(aCallback) |
|
92 { |
|
93 } |
|
94 |
|
95 /** |
|
96 @return True if this is a valid (initialized) callback object. |
|
97 */ |
|
98 inline TBool TSqlFreePageCallback::IsValid() const |
|
99 { |
|
100 return iThis && iThreshold >= 0 && iCallback; |
|
101 } |
|
102 |
|
103 /** |
|
104 Calls the callback if aFreePageCount value is above the threshold. |
|
105 |
|
106 @param aFreePageCount Database free pages count |
|
107 */ |
|
108 inline void TSqlFreePageCallback::CheckAndCallback(TInt aFreePageCount) const |
|
109 { |
|
110 if(aFreePageCount > 0 && aFreePageCount >= iThreshold) |
|
111 { |
|
112 (*iCallback)(iThis, aFreePageCount); |
|
113 } |
|
114 } |
|
115 |
|
116 #endif//__SQLITESYMBIAN_H__ |