1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef SERVICES_EDM_PLUGIN_INCLUDE_IPTABLES_EXECUTER_FACTORY_H
17 #define SERVICES_EDM_PLUGIN_INCLUDE_IPTABLES_EXECUTER_FACTORY_H
18 
19 #include <unistd.h>
20 
21 #include <memory>
22 #include <mutex>
23 #include <thread>
24 #include <unordered_map>
25 
26 #include "iexecuter.h"
27 
28 namespace OHOS {
29 namespace EDM {
30 namespace IPTABLES {
31 
32 class ExecuterFactory {
33 public:
34     std::shared_ptr<IExecuter> GetExecuter(const std::string &chainName) const;
35 
36     std::vector<std::shared_ptr<IExecuter>> GetAllExecuter() const;
37 
38     static std::shared_ptr<ExecuterFactory> GetInstance();
39 private:
40     static std::shared_ptr<ExecuterFactory> instance_;
41     static std::mutex mutexLock_;
42 
43     std::unordered_map<std::string, std::shared_ptr<IExecuter>> executerMap_;
44     std::vector<std::string> chainNames_;
45     std::vector<std::shared_ptr<IExecuter>> executerVector_;
46 };
47 } // namespace IPTABLES
48 } // namespace EDM
49 } // namespace OHOS
50 #endif // SERVICES_EDM_PLUGIN_INCLUDE_IPTABLES_EXECUTER_FACTORY_H
51