• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 IPC_TRANSACTORS_IMPL_H
17 #define IPC_TRANSACTORS_IMPL_H
18 
19 #include <string_view>
20 #include "ipc_transactors.h"
21 #include "common_event_manager.h"
22 
23 namespace OHOS::uitest {
24     /**Transceiver implemented basing on ohos CommonEvent.*/
25     class TransactionTransceiverImpl : public MessageTransceiver {
26     public:
27         TransactionTransceiverImpl() = delete;
28 
29         explicit TransactionTransceiverImpl(std::string_view token, bool asServer);
30 
31         bool Initialize() override;
32 
33         void Finalize() override;
34 
35     protected:
36         void DoEmitMessage(const TransactionMessage &message) override;
37 
38     private:
39         const bool asServer_;
40         const std::string token_;
41         std::shared_ptr<OHOS::EventFwk::CommonEventSubscriber> subscriber_;
42     };
43 
44     /**Implementation TransactionServer with token.*/
45     class TransactionServerImpl : public TransactionServer {
46     public:
47         explicit TransactionServerImpl(std::string_view token);
48 
49         virtual ~TransactionServerImpl();
50 
51         bool Initialize() override;
52 
53     protected:
54         std::unique_ptr<MessageTransceiver> CreateTransceiver() override;
55 
56     private:
57         const std::string token_;
58     };
59 
60     /**Implementation TransactionClient with token.*/
61     class TransactionClientImpl final : public TransactionClient {
62     public:
63         explicit TransactionClientImpl(std::string_view token);
64 
65         virtual ~TransactionClientImpl();
66 
67         bool Initialize() override;
68 
69     protected:
70         std::unique_ptr<MessageTransceiver> CreateTransceiver() override;
71 
72     private:
73         const std::string token_;
74     };
75 }
76 
77 #endif