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 * @file plugin_dao_read_only.h
18 * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
20 * @brief This file contains the declaration of plugin dao read only
23 #ifndef WRT_SRC_CONFIGURATION_PLUGIN_DAO_READ_ONLY_H_
24 #define WRT_SRC_CONFIGURATION_PLUGIN_DAO_READ_ONLY_H_
29 #include <dpl/exception.h>
30 #include <dpl/wrt-dao-ro/common_dao_types.h>
33 typedef std::list<DbPluginHandle> PluginHandleList;
34 typedef std::set<DbPluginHandle> PluginHandleSet;
35 typedef std::list<std::string> ImplementedObjectsList;
36 typedef std::shared_ptr<PluginHandleSet> PluginHandleSetPtr;
38 //TODO make it friend to FeatureDAO or inherit
39 class PluginDAOReadOnly
42 enum PluginInstallationState
45 //when plugin data are up to date and plugin model may be created
46 INSTALLATION_COMPLETED,
47 //installation is in progress, some data may not be valid
48 INSTALLATION_IN_PROGRESS,
49 //installation not completed due to missing dependency
55 static int ToInt(PluginInstallationState state)
57 return static_cast<int>(state);
60 static PluginInstallationState ToState(int state)
62 return static_cast<PluginDAOReadOnly::PluginInstallationState>(state);
66 * PluginDAO Exception classes
71 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
72 DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
73 DECLARE_EXCEPTION_TYPE(Base, PluginNotExist)
74 DECLARE_EXCEPTION_TYPE(Base, PluginInstallationNotCompleted)
78 PluginDAOReadOnly(DbPluginHandle pluginHandle);
79 PluginDAOReadOnly(const std::string &libraryName);
81 static PluginHandleList getPluginHandleList();
83 static bool isPluginInstalled(const std::string &libraryName);
84 static bool isPluginInstalled(DbPluginHandle pluginHandle);
86 static PluginHandleSetPtr getPluginHandleByStatus(
87 PluginInstallationState state);
89 static DbPluginHandle getPluginHandleForImplementedObject(
90 const std::string& objectName);
92 static ImplementedObjectsList getImplementedObjectsForPluginHandle(
93 DbPluginHandle handle);
95 static PluginObjectsDAO::ObjectsPtr getRequiredObjectsForPluginHandle(
96 DbPluginHandle handle);
98 static PluginInstallationState getInstallationStateForHandle(
99 DbPluginHandle handle);
101 DbPluginHandle getPluginHandle() const;
102 PluginInstallationState getInstallationStatus() const;
103 std::string getLibraryPath() const;
104 std::string getLibraryName() const;
105 PluginHandleSetPtr getLibraryDependencies() const;
108 DbPluginHandle m_pluginHandle;
110 void checkInstallationCompleted();
114 #endif /* WRT_SRC_CONFIGURATION_PLUGIN_DAO_READ_ONLY_H_ */