Merge "Fix Jira issue (db lock issue)" into tizen_2.1
[platform/framework/native/appfw.git] / src / io / inc / FIo_DbContextImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18 // This method is for internal use only. The Tizen platform team is not
19 // responsible for any behavioral correctness, consistency, and
20 // security-related issues that might arise after using this method.
21 //
22 // @file        FIo_DbContextImpl.h
23 // @brief       This is the header file for the %_DbContextImpl class.
24 //
25 // This header file contains declarations of the %_DbContextImpl class.
26
27 #ifndef _FIO_INTERNAL_DBCONTEXTIMPL_H_
28 #define _FIO_INTERNAL_DBCONTEXTIMPL_H_
29
30 #include <FOspConfig.h>
31 #include <FBaseString.h>
32
33 namespace Tizen { namespace Io
34 {
35
36 class _IDbUserFunctionListener;
37 class _IDbUserAggregateListener;
38 class _IDbUserCollationListener;
39
40 // This method is for internal use only. The Tizen platform team is not
41 // responsible for any behavioral correctness, consistency, and
42 // security-related issues that might arise after using this method.
43 //
44 // @enum                _DbUserListenerErrorCode
45 // Defines Database error codes used by user listeners.
46 //
47 // @since 2.1
48 // @see         Tizen::Io::_IDbUserFunctionListener, Tizen::Io::_IDbUserAggregateListener, and
49 //                      Tizen::Io::_IDbUserCollationListener.
50
51 enum _DbUserListenerErrorCode
52 {
53         DB_USER_LISTENER_OK = 0,    /** Successful result */
54         DB_USER_LISTENER_ERROR,     /** SQL error */
55         DB_USER_LISTENER_ABORT,     /** Callback routine requested an abort */
56         DB_USER_LISTENER_NOMEM,     /** Insufficient memory */
57 };
58
59 // This method is for internal use only. The Tizen platform team is not
60 // responsible for any behavioral correctness, consistency, and
61 // security-related issues that might arise after using this method.
62 //
63 // @class       _DbContext
64 // @brief       This class provides methods for managing the user defined SQL function or aggregate.
65 // @since 2.1
66 class _OSP_EXPORT_ _DbContextImpl
67         : public Tizen::Base::Object
68 {
69
70 public:
71         // This method is for internal use only. The Tizen platform team is not
72         // responsible for any behavioral correctness, consistency, and
73         // security-related issues that might arise after using this method.
74         //
75         // This is the default destructor for this class.
76         //
77         // @since 2.1
78         virtual ~_DbContextImpl(void);
79
80         // This method is for internal use only. The Tizen platform team is not
81         // responsible for any behavioral correctness, consistency, and
82         // security-related issues that might arise after using this method.
83         //
84         // Gets the String value from a parameter of the user defined SQL function or aggregate.
85         //
86         // @since 2.1
87         // @return              An error code
88         // @param[in]   argumentIndex           The index of the arguments of the user defined SQL function or aggregate. @n
89         //                                   It starts from @c 0.
90         // @param[in]    value               The String value obtained from the argument pointed by the specified @c argumentIndex.
91         // @exception   E_SUCCESS                       The method was successful. @n
92         // @exception   E_INVALID_STATE         This instance has not been properly constructed yet. @n
93         // @exception   E_INVALID_ARG           If the specified @c argumentIndex is negative. @n
94         // @exception   E_DATABASE                      Failed to retrieve the String value.
95         //
96         result GetStringAt(int argumentIndex, Tizen::Base::String& value);
97
98         // This method is for internal use only. The Tizen platform team is not
99         // responsible for any behavioral correctness, consistency, and
100         // security-related issues that might arise after using this method.
101         //
102         // Sets the String value as result to be passsed to database engine.
103         //
104         // @since 2.1
105         // @return              An error code
106         // @param[in]   value                       String value to be set @n
107         // @exception   E_SUCCESS                       The method was successful. @n
108         // @exception   E_INVALID_STATE         This instance has not been properly constructed yet. @n
109         // @exception   E_DATABASE                      Failed to set the result.
110         //
111         result SetResultString(const Tizen::Base::String& value);
112
113         // This method is for internal use only. The Tizen platform team is not
114         // responsible for any behavioral correctness, consistency, and
115         // security-related issues that might arise after using this method.
116         //
117         // Sets the integer value as result to be passsed to database engine.
118         //
119         // @since 2.1
120         // @return              An error code.
121         // @param[in]   result                      Interger value to be set. @n
122         // @exception   E_SUCCESS                       The method was successful. @n
123         // @exception   E_INVALID_STATE         This instance has not been properly constructed yet. @n
124         // @exception   E_DATABASE                      Failed to set the result. @n
125         //
126         result SetResultInt(int value);
127
128         // This method is for internal use only. The Tizen platform team is not
129         // responsible for any behavioral correctness, consistency, and
130         // security-related issues that might arise after using this method.
131         //
132         // Sets the double value as result to be passsed to database engine.
133         //
134         // @since 2.1
135         // @return              An error code.
136         // @param[in]   result                      double value to be set. @n
137         // @exception   E_SUCCESS                       The method was successful. @n
138         // @exception   E_INVALID_STATE         This instance has not been properly constructed yet. @n
139         // @exception   E_DATABASE                      Failed to set the result. @n
140         //
141         result SetResultDouble(double value);
142
143         // This method is for internal use only. The Tizen platform team is not
144         // responsible for any behavioral correctness, consistency, and
145         // security-related issues that might arise after using this method.
146         //
147         // Sets the result error code to be passsed to database engine.
148         //
149         // @since 2.1
150         // @return              An error code.
151         // @param[in]   errorCode                   SQLite error code. @n
152         // @exception   E_SUCCESS                       The method was successful. @n
153         // @exception   E_INVALID_STATE         This instance has not been properly constructed yet. @n
154         // @exception   E_DATABASE                      Failed to set the error code. @n
155         //
156         result SetResultErrorCode(_DbUserListenerErrorCode errorCode);
157
158         // This method is for internal use only. The Tizen platform team is not
159         // responsible for any behavioral correctness, consistency, and
160         // security-related issues that might arise after using this method.
161         //
162         // Gets the user data if set any while creating SQL functions or aggregate.
163         //
164         // @since 2.1
165         // @return              user data pointer.
166         // @exception   E_SUCCESS                       The method was successful. @n
167         // @exception   E_INVALID_STATE         This instance has not been properly constructed yet. @n
168         void* GetUserData(void);
169
170         static void DestroyListener(void* pData);
171
172 private:
173         // This method is for internal use only. The Tizen platform team is not
174         // responsible for any behavioral correctness, consistency, and
175         // security-related issues that might arise after using this method.
176         //
177         // This is the default constructor for this class.
178         //
179         // @since 2.1
180         _DbContextImpl(void);
181
182         static int ConvertDbErrorToNativeSqliteError(int errorCode);
183
184         void* __pContext;
185
186         void** __pArgList;
187
188         void* __pUserData;
189
190         _IDbUserFunctionListener* __pUserFunctionListener;
191
192         _IDbUserAggregateListener* __pUserAggregateListener;
193
194         _IDbUserCollationListener* __pUserCollationListener;
195
196         int __argumentCount;
197
198         Tizen::Base::String __functionName;
199
200         Tizen::Base::String __collationName;
201
202         friend class _DatabaseImpl;
203
204 }; // _DbContextImpl
205
206 }} // Tizen::Io
207
208 #endif  //_FIO_INTERNAL_DBCONTEXTIMPL_H_