Update wrt-commons_0.2.53
[framework/web/wrt-commons.git] / modules / widget_dao / include / dpl / wrt-dao-ro / plugin_dao_read_only.h
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_dao_read_only.h
18  * @author  Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
19  * @version 1.0
20  * @brief   This file contains the declaration of plugin dao read only
21  */
22
23
24 #ifndef WRT_SRC_CONFIGURATION_PLUGIN_DAO_READ_ONLY_H_
25 #define WRT_SRC_CONFIGURATION_PLUGIN_DAO_READ_ONLY_H_
26
27 #include <string>
28 #include <list>
29 #include <dpl/exception.h>
30 #include <dpl/shared_ptr.h>
31 #include <dpl/wrt-dao-ro/common_dao_types.h>
32
33 namespace WrtDB {
34
35 typedef std::list<DbPluginHandle> PluginHandleList;
36 typedef std::set<DbPluginHandle> PluginHandleSet;
37 typedef std::list<std::string> ImplementedObjectsList;
38 typedef DPL::SharedPtr<PluginHandleSet> PluginHandleSetPtr;
39
40 //TODO make it friend to FeatureDAO or inherit
41 class PluginDAOReadOnly
42 {
43   public:
44     enum PluginInstallationState
45     {
46         INSTALLATION_DEFAULT,
47         //when plugin data are up to date and plugin model may be created
48         INSTALLATION_COMPLETED,
49         //installation is in progress, some data may not be valid
50         INSTALLATION_IN_PROGRESS,
51         //installation not completed due to missing dependency
52         INSTALLATION_WAITING,
53
54         UNKNOWN_ERROR
55     };
56
57     static int ToInt(PluginInstallationState state)
58     {
59         return static_cast<int>(state);
60     }
61
62     static PluginInstallationState ToState(int state)
63     {
64         return static_cast<PluginDAOReadOnly::PluginInstallationState>(state);
65     }
66
67     /**
68      * PluginDAO Exception classes
69      */
70     class Exception
71     {
72       public:
73         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
74         DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
75         DECLARE_EXCEPTION_TYPE(Base, PluginNotExist)
76         DECLARE_EXCEPTION_TYPE(Base, PluginInstallationNotCompleted)
77     };
78
79   public:
80     PluginDAOReadOnly(DbPluginHandle pluginHandle);
81     PluginDAOReadOnly(const std::string &libraryName);
82
83     static PluginHandleList getPluginHandleList();
84
85     static bool isPluginInstalled(const std::string &libraryName);
86     static bool isPluginInstalled(DbPluginHandle pluginHandle);
87
88     static PluginHandleSetPtr getPluginHandleByStatus(
89             PluginInstallationState state);
90
91     static DbPluginHandle getPluginHandleForImplementedObject(
92             const std::string& objectName);
93
94     static ImplementedObjectsList getImplementedObjectsForPluginHandle(
95             DbPluginHandle handle);
96
97     static PluginObjectsDAO::ObjectsPtr getRequiredObjectsForPluginHandle(
98             DbPluginHandle handle);
99
100     static PluginInstallationState getInstallationStateForHandle(
101             DbPluginHandle handle);
102
103     DbPluginHandle getPluginHandle() const;
104     PluginInstallationState getInstallationStatus() const;
105     std::string  getLibraryPath() const;
106     std::string  getLibraryName() const;
107     PluginHandleSetPtr getLibraryDependencies() const;
108
109   private:
110     DbPluginHandle m_pluginHandle;
111
112     void checkInstallationCompleted();
113 };
114
115 } // namespace WrtDB
116
117 #endif /* WRT_SRC_CONFIGURATION_PLUGIN_DAO_READ_ONLY_H_ */