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 #include "matrix_event.h"
16 namespace OHOS::DistributedData {
MatrixEvent(int32_t evtId,const std::string & device,const MatrixData & data)17 MatrixEvent::MatrixEvent(int32_t evtId, const std::string &device, const MatrixData &data)
18     : Event(evtId), data_(data), deviceId_(device)
19 {
20 }
21 
GetMatrixData() const22 MatrixEvent::MatrixData MatrixEvent::GetMatrixData() const
23 {
24     return data_;
25 }
26 
GetDeviceId() const27 std::string MatrixEvent::GetDeviceId() const
28 {
29     return deviceId_;
30 }
31 
Equals(const Event & event) const32 bool MatrixEvent::Equals(const Event &event) const
33 {
34     auto &evt = static_cast<const MatrixEvent &>(event);
35     return deviceId_ == evt.deviceId_;
36 }
37 
SetRefCount(RefCount refCount)38 void MatrixEvent::SetRefCount(RefCount refCount)
39 {
40     refCount_ = std::move(refCount);
41 }
42 
StealRefCount() const43 RefCount MatrixEvent::StealRefCount() const
44 {
45     return std::move(refCount_);
46 }
47 
IsValid() const48 bool MatrixEvent::MatrixData::IsValid() const
49 {
50     return !(dynamic == INVALID_LEVEL && statics == INVALID_LEVEL &&
51         switches == INVALID_VALUE && switchesLen == INVALID_LENGTH);
52 }
53 } // namespace OHOS::DistributedData