Change event sync to async
[platform/framework/native/appfw.git] / src / io / inc / FIo_DbEnumeratorImpl.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        FIo_DbEnumeratorImpl.h
19  * @brief       This is the header file for the %_DbEnumeratorImpl class.
20  *
21  * This header file contains declarations of the %_DbEnumeratorImpl class.
22  */
23
24 #ifndef _FIO_INTERNAL_DBENUMERATOR_IMPL_H_
25 #define _FIO_INTERNAL_DBENUMERATOR_IMPL_H_
26
27 #include <FBaseObject.h>
28 #include <FOspConfig.h>
29 #include <FIoDbTypes.h>
30
31 #include <FIoDbEnumerator.h>
32
33 namespace Tizen { namespace Base
34 {
35 class String;
36 class ByteBuffer;
37 class DateTime;
38 }}
39
40 namespace Tizen { namespace Io
41 {
42
43 class _DbEnumeratorCache;
44 class _DbRow;
45 /**
46  * @class   _DbEnumeratorImpl
47  * @brief       This class implements the DbEnumerator.
48  * @since 2.1
49  *
50  * @see Tizen::Io::DbEnumerator
51  */
52
53 class _OSP_EXPORT_ _DbEnumeratorImpl
54         : public Tizen::Base::Object
55 {
56
57 public:
58         /**
59         * This is the default constructor for this class.
60         */
61         _DbEnumeratorImpl(void);
62
63         /**
64         * This is the default destructor for this class.
65         */
66         virtual ~_DbEnumeratorImpl(void);
67
68         /**
69         * @see          DbEnumerator::MoveNext()
70         */
71         result MoveNext(void);
72
73         /**
74         * @see          DbEnumerator::MovePrevious()
75         */
76         result MovePrevious(void);
77
78         /**
79         * @see          DbEnumerator::MoveFirst()
80         */
81         result MoveFirst(void);
82
83         /**
84         * @see          DbEnumerator::MoveLast()
85         */
86         result MoveLast(void);
87
88         /**
89         * @see          DbEnumerator::Reset()
90         */
91         result Reset(void);
92
93         /**
94         * @see          DbEnumerator::GetIntAt()
95         */
96         result GetIntAt(int columnIndex, int& value) const;
97
98         /**
99         * @see          DbEnumerator::GetInt64At()
100         */
101         result GetInt64At(int columnIndex, long long& value) const;
102
103         /**
104         * @see          DbEnumerator::GetDoubleAt()
105         */
106         result GetDoubleAt(int columnIndex, double& value) const;
107
108         /**
109         * @see          DbEnumerator::GetStringAt()
110         */
111         result GetStringAt(int columnIndex, Tizen::Base::String& value) const;
112
113         /**
114         * @see          DbEnumerator::GetBlobAt()
115         */
116         result GetBlobAt(int columnIndex, Tizen::Base::ByteBuffer& value) const;
117
118         /**
119         * @see          DbEnumerator::GetBlobAt()
120         */
121         result GetBlobAt(int columnIndex, void* buffer, int size) const;
122
123         /**
124         * @see          DbEnumerator::GetDateTimeAt()
125         */
126         result GetDateTimeAt(int columnIndex, Tizen::Base::DateTime& value) const;
127
128         /**
129         * @see          DbEnumerator::GetColumnCount()
130         */
131         int GetColumnCount(void) const;
132
133         /**
134         * @see          DbEnumerator::GetColumnType()
135         */
136         DbColumnType GetColumnType(int columnIndex) const;
137
138         /**
139         * @see          DbEnumerator::GetColumnName()
140         */
141         Tizen::Base::String GetColumnName(int columnIndex) const;
142
143         /**
144         * @see          DbEnumerator::GetColumnSize()
145         */
146         int GetColumnSize(int columnIndex) const;
147
148         static _DbEnumeratorImpl* GetInstance(DbEnumerator& dbEnumerator);
149
150         static const _DbEnumeratorImpl* GetInstance(const DbEnumerator& dbEnumerator);
151
152         static DbEnumerator* CreateDbEnumeratorInstanceN(void);
153
154 private:
155         _DbEnumeratorImpl(_DbEnumeratorImpl& dbEnumeratorImpl);
156
157         _DbEnumeratorImpl& operator =(const _DbEnumeratorImpl& dbEnumeratorImpl);
158
159         /**
160         * Moves the cursor to the next row and caches the column data.
161         *
162         * @since 2.1
163         *
164         * @return               An error code
165         * @param[in]    cacheColumnNamesToo             Set to @c true to cache the column names, @n
166         *                                       else @c false to ignore caching column names.
167         * @exception    E_INVALID_STATE                 Either of the following conditions has occurred:
168         *                                                                               - This instance has not been properly constructed.
169         *                                                                               - The data cache is not initialized.*
170         * @exception    E_OUT_OF_RANGE                  The enumerator has reached out of the result set.
171         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
172         */
173         result CacheRow(bool cacheColumnNamesToo = false);
174
175         /**
176         * Moves the cursor to the position specified by @c rowIndex and caches the column data into @c dbRow.
177         *
178         * @since 2.1
179         *
180         * @return                       An error code
181         * @param[in,out]        dbRow                           The list of values obtained from the result row.
182         * @param[in]            rowIndex                        The index of a row data to be cached.
183         * @exception            E_SUCCESS                       The method is successful.
184         * @exception            E_INVALID_STATE         Either of the following conditions has occurred:
185         *                                                                               - This instance has not been properly constructed.
186         *                                                                               - The data cache is not initialized.
187         * @exception            E_DATABASE                      The query did not yield any result.
188         * @exception            E_OUT_OF_MEMORY         The memory is insufficient.
189         */
190         result CacheRow(_DbRow& dbRow, int rowIndex);
191
192         bool __shouldReleaseResource;
193
194         void* __pEnum;
195
196         void* __pDatabase;
197
198         int __columnCount;
199
200         int __rowCount;
201
202         int __currentRowIndex;
203
204         _DbEnumeratorCache* __pDbEnumeratorCache;
205
206         friend class DbEnumerator;
207         friend class _DatabaseImpl;
208
209 }; // _DbEnumeratorImpl
210
211 }} // Tizen::Io
212
213 #endif  //_FIO_INTERNAL_DBENUMERATOR_IMPL_H_
214