1 /*
2  * Copyright (c) 2022 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 OHOS_DM_IPC_CLIENT_MANAGER_H
17 #define OHOS_DM_IPC_CLIENT_MANAGER_H
18 
19 #include <cstdint>
20 #include <set>
21 #include <string>
22 
23 #include "ipc_client.h"
24 #include "ipc_client_server_proxy.h"
25 
26 namespace OHOS {
27 namespace DistributedHardware {
28 class IpcClientManager : public IpcClient {
29     DECLARE_IPC_INTERFACE(IpcClientManager);
30 
31 public:
32     /**
33      * @tc.name: IpcClientManager::Init
34      * @tc.desc: ipc client Manager initialization
35      * @tc.type: FUNC
36      */
37     virtual int32_t Init(const std::string &pkgName) override;
38     /**
39      * @tc.name: IpcClientManager::Init
40      * @tc.desc: ipc client Manager Uninitialization
41      * @tc.type: FUNC
42      */
43     virtual int32_t UnInit(const std::string &pkgName) override;
44     /**
45      * @tc.name: IpcClientManager::Init
46      * @tc.desc: ipc client Manager Send Request
47      * @tc.type: FUNC
48      */
49     virtual int32_t SendRequest(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp) override;
50 
51     virtual int32_t OnDmServiceDied() override;
52 private:
53     bool IsInit(const std::string &pkgName);
54 
55 private:
56     IpcClientServerProxy serverProxy_;
57     std::set<std::string> packageInitSet_;
58 };
59 } // namespace DistributedHardware
60 } // namespace OHOS
61 #endif // OHOS_DM_IPC_CLIENT_MANAGER_H
62