1 /*
2  * Copyright (c) 2021 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 "fifo_cache_data.h"
17 namespace OHOS {
18 namespace Sensors {
19 
FifoCacheData()20 FifoCacheData::FifoCacheData() : periodCount_(0), channel_(nullptr)
21 {}
22 
~FifoCacheData()23 FifoCacheData::~FifoCacheData()
24 {
25     fifoCacheData_.clear();
26 }
27 
InitFifoCache()28 void FifoCacheData::InitFifoCache()
29 {
30     periodCount_ = 0;
31     fifoCacheData_.clear();
32 }
33 
SetPeriodCount(uint64_t periodCount)34 void FifoCacheData::SetPeriodCount(uint64_t periodCount)
35 {
36     periodCount_ = periodCount;
37 }
38 
GetPeriodCount() const39 uint64_t FifoCacheData::GetPeriodCount() const
40 {
41     return periodCount_;
42 }
43 
SetFifoCacheData(const std::vector<SensorData> & fifoCacheData)44 void FifoCacheData::SetFifoCacheData(const std::vector<SensorData> &fifoCacheData)
45 {
46     fifoCacheData_ = fifoCacheData;
47 }
48 
GetFifoCacheData() const49 std::vector<SensorData> FifoCacheData::GetFifoCacheData() const
50 {
51     return fifoCacheData_;
52 }
53 
SetChannel(const sptr<SensorBasicDataChannel> & channel)54 void FifoCacheData::SetChannel(const sptr<SensorBasicDataChannel> &channel)
55 {
56     channel_ = channel;
57 }
58 
GetChannel() const59 sptr<SensorBasicDataChannel> FifoCacheData::GetChannel() const
60 {
61     return channel_.promote();
62 }
63 } // namespace Sensors
64 } // namespace OHOS
65