• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "common_event_subscriber.h"
17 
18 namespace OHOS {
19 namespace EventFwk {
CommonEventSubscriber()20 CommonEventSubscriber::CommonEventSubscriber() : result_(nullptr)
21 {}
22 
CommonEventSubscriber(const CommonEventSubscribeInfo & subscribeInfo)23 CommonEventSubscriber::CommonEventSubscriber(const CommonEventSubscribeInfo& subscribeInfo)
24     : subscribeInfo_(subscribeInfo), result_(nullptr)
25 {}
26 
~CommonEventSubscriber()27 CommonEventSubscriber::~CommonEventSubscriber()
28 {}
29 
GetSubscribeInfo() const30 const CommonEventSubscribeInfo& CommonEventSubscriber::GetSubscribeInfo() const
31 {
32     return subscribeInfo_;
33 }
34 
SetCode(const int & code)35 bool CommonEventSubscriber::SetCode(const int& code)
36 {
37     return result_->SetCode(code);
38 }
39 
GetCode() const40 int CommonEventSubscriber::GetCode() const
41 {
42     return result_->GetCode();
43 }
44 
SetData(const std::string & data)45 bool CommonEventSubscriber::SetData(const std::string& data)
46 {
47     return result_->SetData(data);
48 }
49 
GetData() const50 std::string CommonEventSubscriber::GetData() const
51 {
52     return result_->GetData();
53 }
54 
SetCodeAndData(const int & code,const std::string & data)55 bool CommonEventSubscriber::SetCodeAndData(const int& code, const std::string& data)
56 {
57     return result_->SetCodeAndData(code, data);
58 }
59 
AbortCommonEvent()60 bool CommonEventSubscriber::AbortCommonEvent()
61 {
62     return result_->AbortCommonEvent();
63 }
64 
ClearAbortCommonEvent()65 bool CommonEventSubscriber::ClearAbortCommonEvent()
66 {
67     return result_->ClearAbortCommonEvent();
68 }
69 
GetAbortCommonEvent() const70 bool CommonEventSubscriber::GetAbortCommonEvent() const
71 {
72     return result_->GetAbortCommonEvent();
73 }
74 
GoAsyncCommonEvent()75 std::shared_ptr<AsyncCommonEventResult> CommonEventSubscriber::GoAsyncCommonEvent()
76 {
77     std::shared_ptr<AsyncCommonEventResult> res = result_;
78     result_ = nullptr;
79     return res;
80 }
81 
IsOrderedCommonEvent() const82 bool CommonEventSubscriber::IsOrderedCommonEvent() const
83 {
84     return (result_ != nullptr) ? result_->IsOrderedCommonEvent() : false;
85 }
86 
IsStickyCommonEvent() const87 bool CommonEventSubscriber::IsStickyCommonEvent() const
88 {
89     return (result_ != nullptr) ? result_->IsStickyCommonEvent() : false;
90 }
91 
SetAsyncCommonEventResult(const std::shared_ptr<AsyncCommonEventResult> & result)92 bool CommonEventSubscriber::SetAsyncCommonEventResult(const std::shared_ptr<AsyncCommonEventResult>& result)
93 {
94     result_ = result;
95 
96     return true;
97 }
98 
GetAsyncCommonEventResult()99 std::shared_ptr<AsyncCommonEventResult> CommonEventSubscriber::GetAsyncCommonEventResult()
100 {
101     return result_;
102 }
103 
CheckSynchronous() const104 bool CommonEventSubscriber::CheckSynchronous() const
105 {
106     return true;
107 }
108 } // namespace EventFwk
109 } // namespace OHOS