blob: 8571a9f3d4872ed14c4d5f32adb09810c2af14d0 [file] [log] [blame]
xshu5899e8e2018-01-09 15:36:03 -08001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef RINGBUFFER_H_
18#define RINGBUFFER_H_
19
20#include <list>
21#include <vector>
22
23namespace android {
24namespace hardware {
25namespace wifi {
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080026namespace V1_6 {
xshu5899e8e2018-01-09 15:36:03 -080027namespace implementation {
28
29/**
30 * Ringbuffer object used to store debug data.
31 */
32class Ringbuffer {
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080033 public:
xshu5899e8e2018-01-09 15:36:03 -080034 explicit Ringbuffer(size_t maxSize);
35
36 // Appends the data buffer and deletes from the front until buffer is
37 // within |maxSize_|.
38 void append(const std::vector<uint8_t>& input);
39 const std::list<std::vector<uint8_t>>& getData() const;
xshuc905ea62021-07-11 19:57:02 -070040 void clear();
xshu5899e8e2018-01-09 15:36:03 -080041
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080042 private:
xshu5899e8e2018-01-09 15:36:03 -080043 std::list<std::vector<uint8_t>> data_;
44 size_t size_;
45 size_t maxSize_;
46};
47
48} // namespace implementation
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080049} // namespace V1_6
xshu5899e8e2018-01-09 15:36:03 -080050} // namespace wifi
51} // namespace hardware
52} // namespace android
53
54#endif // RINGBUFFER_H_