3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.1 (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
9 // http://floralicense.org/license/
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.
19 * @file ClkPresentationModelBase.h
20 * @brief This is the header file for PresentationModelBase class
23 #ifndef _CLK_DATA_SERVICE_PROVIDER_H_
24 #define _CLK_DATA_SERVICE_PROVIDER_H_
31 * @class DataServiceProvider
32 * @brief This class declares functions which will manage database
34 class DataServiceProvider
38 * Initialize storage service
40 static result Initialize(void);
43 * Deinitialize storage service
45 static result UnInitialize(void);
49 * This function deletes the database
51 * @return An error code
53 * @exception E_SUCCESS The database closed successfully
54 * @exception E_FAILURE The database is not closed successfully
56 static result CloseDb(void);
59 * This function commits the database
61 * @return An error code
63 * @exception E_SUCCESS The database closed successfully
64 * @exception E_FAILURE The database is not closed successfully
66 static result CommitDb(void);
69 * This function creates the table in database
71 * @return An error code
72 * @param tableType The name of the table
73 * @exception E_SUCCESS The table is created successfully in database
74 * @exception E_FAILURE The table creation in database is not successful
76 static result CreateDBTables(ClockDbTableTypes tableType);
79 * This function finds the next row present in the database or not.
81 * @return An error code
82 * @param nextRowpresent true/false : the next row present or not.
83 * @exception E_SUCCESS The table is dropped successfully from database
84 * @exception E_FAILURE The table drop is unsuccessful
86 static result DbIsNextRowPresent(bool& nextRowpresent);
89 * This function drops the existing tables from database
91 * @return An error code
93 * @exception E_SUCCESS The table is dropped successfully from database
94 * @exception E_FAILURE The table drop is unsuccessful
96 static result DropDBTables(void);
99 * This function drops the existing tables from database
101 * @return An error code
102 * @param No parameter
103 * @exception E_SUCCESS The table is dropped successfully from database
104 * @exception E_FAILURE The table drop is unsuccessful
106 static result ExecuteQuery(const Tizen::Base::String pszFormatQuery, int& nRowCount);
109 * This function returns the instance of WorldClockPresentationModel
111 * @return The instance of WorldClockPresentationModel
113 static DataServiceProvider* GetInstance();
116 * This function gives the last inserted row id
118 * @return An error code
119 * @param tableName The name of the table
120 * @param rowId The rowId in which last inserted rowId will be saved.
121 * @exception E_SUCCESS The method is successful
122 * @exception E_FAILURE The method is not successful
123 * @remarks To work properly , the table name should be passed properly
125 result GetLastInsertedId(Tizen::Base::String& tableName, int& rowId);
128 * This function creates the database and constructs it.
130 * @return An error code
131 * @param No parameter
132 * @exception E_SUCCESS The database created successfully
133 * @exception E_FAILURE The database creation is failed
135 static result OpenDb(void);
138 * This function calls the CreateDBTables function for all the tables
140 * @return An error code
141 * @param No parameter
143 static result InitializeDBTables(void);
147 static result IsNullColumn(int nIndex, bool& isColumNull);
148 static result GetColumn(int nIndex, Tizen::Base::String& strVal);
149 static result GetColumn(int nIndex, int& nIntVal);
150 static result GetColumn(int nIndex, double& dblVal);
151 static result GetColumn(int nIndex, Tizen::Base::DateTime& dtVal);
152 static result RollbackDb(void);
154 static bool GetCurrentDateTime(Tizen::Base::DateTime& dt);
158 * Default constructor
160 DataServiceProvider(void);
165 ~DataServiceProvider(void);
168 * This function constructs the instance of DataServiceProvider
171 result Construct(void);
174 * This function creates the instance of DataServiceProvider
176 * @return No return value
178 static void CreateInstance(void);
181 * This function destroys the instance of DataServiceProvider
183 * @return No return value
185 static void DestroyInstance(void);
188 static Tizen::Base::String DB_FILE_PATH;
191 static bool __isBeginTransaction;
192 static Tizen::Io::Database* __pDataBase;
193 static Tizen::Io::DbEnumerator* __pDbEnum;
194 static Tizen::Io::DbStatement* __pDbStatement;
195 static DataServiceProvider* __pInstance;
198 #endif //_CLK_DATA_SERVICE_PROVIDER_H_