Initialize Tizen 2.3
[framework/web/wrt-commons.git] / modules / widget_dao / dao / WrtDatabase.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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 #include <stddef.h>
17 #include <dpl/wrt-dao-ro/WrtDatabase.h>
18
19 #include <dpl/db/thread_database_support.h>
20 #include <dpl/db/sql_connection.h>
21 #include <dpl/thread.h>
22 #include <dpl/wrt-dao-ro/global_config.h>
23
24 namespace WrtDB {
25 const char* WrtDatabase::Address()
26 {
27     using namespace WrtDB;
28     return GlobalConfig::GetWrtDatabaseFilePath();
29 }
30
31 DPL::DB::SqlConnection::Flag::Type WrtDatabase::Flags()
32 {
33     return DPL::DB::SqlConnection::Flag::UseLucene;
34 }
35
36 DPL::DB::ThreadDatabaseSupport WrtDatabase::m_interface(
37     WrtDatabase::Address(),
38     WrtDatabase::Flags());
39
40 void WrtDatabase::attachToThreadRO()
41 {
42     m_interface.AttachToThread(DPL::DB::SqlConnection::Flag::RO);
43 }
44
45 void WrtDatabase::attachToThreadRW()
46 {
47     m_interface.AttachToThread(DPL::DB::SqlConnection::Flag::RW);
48 }
49
50 void WrtDatabase::detachFromThread()
51 {
52     m_interface.DetachFromThread();
53 }
54
55 DPL::DB::ThreadDatabaseSupport& WrtDatabase::interface()
56 {
57     return m_interface;
58 }
59
60 bool WrtDatabase::CheckTableExist(const char *name)
61 {
62     return m_interface.CheckTableExist(name);
63 }
64 }