Add buxton2.socket dependency
[platform/core/appfw/pkgmgr-info.git] / src / server / request_handler_factory.cc
1 /*
2  * Copyright (c) 2022 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 #include "server/request_handler_factory.hh"
18
19 #include "server/request_handler/command_request_handler.hh"
20 #include "server/request_handler/create_cache_request_handler.hh"
21 #include "server/request_handler/create_db_request_handler.hh"
22 #include "server/request_handler/get_appinfo_request_handler.hh"
23 #include "server/request_handler/get_cert_request_handler.hh"
24 #include "server/request_handler/get_depinfo_request_handler.hh"
25 #include "server/request_handler/get_pkginfo_request_handler.hh"
26 #include "server/request_handler/query_request_handler.hh"
27 #include "server/request_handler/set_cert_request_handler.hh"
28 #include "server/request_handler/set_pkginfo_request_handler.hh"
29 #include "utils/logging.hh"
30
31 namespace pkgmgr_server {
32
33 RequestHandlerFactory::RequestHandlerFactory() {
34   handler[pkgmgr_common::ReqType::GET_PKG_INFO].reset(
35       new request_handler::GetPkginfoRequestHandler());
36   handler[pkgmgr_common::ReqType::GET_APP_INFO].reset(
37       new request_handler::GetAppinfoRequestHandler());
38   handler[pkgmgr_common::ReqType::SET_PKG_INFO].reset(
39       new request_handler::SetPkginfoRequestHandler());
40   handler[pkgmgr_common::ReqType::SET_CERT_INFO].reset(
41       new request_handler::SetCertRequestHandler());
42   handler[pkgmgr_common::ReqType::GET_CERT_INFO].reset(
43       new request_handler::GetCertRequestHandler());
44   handler[pkgmgr_common::ReqType::GET_PKG_DEP_INFO].reset(
45       new request_handler::GetDepinfoRequestHandler());
46   handler[pkgmgr_common::ReqType::READ_QUERY].reset(
47       new request_handler::QueryRequestHandler());
48   handler[pkgmgr_common::ReqType::WRITE_QUERY].reset(
49       new request_handler::QueryRequestHandler());
50   handler[pkgmgr_common::ReqType::COMMAND].reset(
51       new request_handler::CommandRequestHandler());
52   handler[pkgmgr_common::ReqType::CREATE_DB].reset(
53       new request_handler::CreateDBRequestHandler());
54   handler[pkgmgr_common::ReqType::CREATE_CACHE].reset(
55       new request_handler::CreateCacheRequestHandler());
56 }
57
58 std::shared_ptr<request_handler::AbstractRequestHandler>
59     RequestHandlerFactory::GetRequestHandler(pkgmgr_common::ReqType type) {
60   if (type <= pkgmgr_common::ReqType::REQ_TYPE_NONE ||
61       type >= pkgmgr_common::ReqType::MAX)
62     return nullptr;
63
64   return handler[type];
65 }
66
67 }  // namespace pkgmgr_server