Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_mobile / plugin-loading / plugin_model.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 /**
17  * @file    plugin_model.cpp
18  * @author  Pawel Sikorski (p.sikorski@samgsung.com)
19  * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samgsung.com)
20  * @author  Grzegorz Krawczyk (g.krawczyk@samgsung.com)
21  * @version
22  * @brief   This file contains PluginModel, PluginHandle definitions.
23  */
24
25 #include "plugin_model.h"
26 #include <dpl/event/model_bind_to_dao.h>
27 #include <dpl/wrt-dao-ro/feature_dao_read_only.h>
28
29 using namespace WrtDB;
30
31 template <typename RetType, RetType(PluginDAOReadOnly::*extFun) () const >
32 struct BindToPluginDAO :
33     DPL::Event::BindToDAO<PluginModel,
34                           RetType,
35                           WrtDB::DbPluginHandle,
36                           PluginDAOReadOnly,
37                           &PluginModel::getHandle,
38                           extFun>
39 {};
40
41 template <typename RetType, RetType(*extFun) (WrtDB::DbPluginHandle)>
42 struct BindToFeatureDAOStatic :
43     DPL::Event::BindToDAO_Static<PluginModel,
44                                  RetType,
45                                  WrtDB::DbPluginHandle,
46                                  &PluginModel::getHandle,
47                                  extFun>
48 {};
49
50 PluginModel::PluginModel(const WrtDB::DbPluginHandle& handle) :
51     Handle(this, handle),
52     LibraryName(this,
53                 BindToPluginDAO<std::string,
54                                 &PluginDAOReadOnly::getLibraryName>::Get),
55     LibraryPath(this,
56                 BindToPluginDAO<std::string,
57                                 &PluginDAOReadOnly::getLibraryPath>::Get),
58     FeatureHandles(this,
59                    BindToFeatureDAOStatic<FeatureHandleListPtr,
60                                           FeatureDAOReadOnly::
61                                               GetFeatureHandleListForPlugin>::
62                        Get),
63     LibraryDependencies(this,
64                         BindToPluginDAO<PluginHandleSetPtr,
65                                         &PluginDAOReadOnly::
66                                             getLibraryDependencies>::Get),
67     LibraryInstance(this, PluginPtr())
68 {}
69
70 WrtDB::DbPluginHandle PluginModel::getHandle() const
71 {
72     return Handle.Get();
73 }