2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <dpl/wrt-dao-ro/WrtDatabase.h>
19 #include <dpl/db/thread_database_support.h>
20 #include <dpl/db/sql_connection.h>
21 #include <dpl/mutex.h>
22 #include <dpl/thread.h>
23 #include <dpl/wrt-dao-ro/global_config.h>
27 const char* WrtDatabase::Address()
29 using namespace WrtDB;
30 return GlobalConfig::GetWrtDatabaseFilePath();
33 DPL::DB::SqlConnection::Flag::Type WrtDatabase::Flags()
35 return DPL::DB::SqlConnection::Flag::UseLucene;
38 DPL::DB::ThreadDatabaseSupport WrtDatabase::m_interface(
39 WrtDatabase::Address(),
40 WrtDatabase::Flags());
42 void WrtDatabase::attachToThreadRO()
44 m_interface.AttachToThread(DPL::DB::SqlConnection::Flag::RO);
47 void WrtDatabase::attachToThreadRW()
49 m_interface.AttachToThread(DPL::DB::SqlConnection::Flag::RW);
52 void WrtDatabase::detachFromThread()
54 m_interface.DetachFromThread();
57 DPL::DB::ThreadDatabaseSupport& WrtDatabase::interface()
62 bool WrtDatabase::CheckTableExist(const char *name)
64 return m_interface.CheckTableExist(name);