-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_manager.cpp
More file actions
50 lines (41 loc) · 1.01 KB
/
Copy pathdata_manager.cpp
File metadata and controls
50 lines (41 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "data_manager.h"
void DataManager::addFrame(const PMUFrame& frame)
{
std::lock_guard<std::mutex> lock(mutex);
frameBuffer.push_back(frame);
++totalFrames;
if (frameBuffer.size() > maxBufferSize)
frameBuffer.pop_front();
}
PMUFrame DataManager::getLatest() const
{
std::lock_guard<std::mutex> lock(mutex);
if (frameBuffer.empty())
return PMUFrame();
return frameBuffer.back();
}
const std::deque<PMUFrame>& DataManager::getAllFrames() const
{
return frameBuffer;
}
std::deque<PMUFrame> DataManager::getFramesSnapshot() const
{
std::lock_guard<std::mutex> lock(mutex);
return frameBuffer;
}
std::size_t DataManager::getTotalFrameCount() const
{
std::lock_guard<std::mutex> lock(mutex);
return totalFrames;
}
// Added method for history window
const std::deque<PMUFrame>& DataManager::getHistory() const
{
return frameBuffer;
}
void DataManager::clear()
{
std::lock_guard<std::mutex> lock(mutex);
frameBuffer.clear();
totalFrames = 0;
}