PonyPlayer
updatevalue.hpp
浏览该文件的文档.
1//
2// Created by ColorsWind on 2022/5/20.
3//
4#pragma once
5#include <utility>
6#include "frame.hpp"
7
8template<typename T>
10protected:
13public:
14
16 explicit UpdateValue(T value) : m_value(std::move(value)), m_update(true) {}
17
18
19 operator const T&() const { // NOLINT(google-explicit-constructor)
20 return m_value;
21 }
22
23 virtual const T& getUpdate() {
24 m_update = false;
25 return m_value;
26 }
27
28 virtual UpdateValue& operator=(const T &v) {
29 this->m_value = v;
30 m_update = true;
31 return *this;
32 }
33
34 void updateBy(UpdateValue& updateValue) {
35 this->m_update |= updateValue.m_update;
36 this->m_value = updateValue.getUpdate();
37 }
38
39 [[nodiscard]] bool isUpdate() const {
40 return m_update;
41 }
42};
43
44class UpdateValueVideoFrameRef : public UpdateValue<VideoFrameRef> {
45private:
46 bool m_updateSize;
47public:
49
50 explicit UpdateValueVideoFrameRef(const VideoFrameRef &value) : UpdateValue(value), m_updateSize(true) {}
51
52
53
54 UpdateValueVideoFrameRef& operator=(const VideoFrameRef &videoFrame) override {
55 if (videoFrame == this->m_value) { return *this; }
56 if (m_value.isSameSize(videoFrame)) { this->m_updateSize = true; }
57 this->m_value = videoFrame;
58 m_update = true;
59 return *this;
60 }
61
62 const VideoFrameRef& getUpdate() override {
63 m_update = false;
64 m_updateSize = false;
65 return m_value;
66 }
67
69 this->m_update |= updateValue.m_update;
70 this->m_updateSize |= updateValue.m_updateSize;
71 this->m_value = updateValue.getUpdate();
72 }
73
74 bool isUpdateSize() const {
75 return m_updateSize;
76 }
77};
78
Definition: updatevalue.hpp:9
UpdateValue()
Definition: updatevalue.hpp:15
UpdateValue(T value)
Definition: updatevalue.hpp:16
T m_value
Definition: updatevalue.hpp:11
virtual UpdateValue & operator=(const T &v)
Definition: updatevalue.hpp:28
void updateBy(UpdateValue &updateValue)
Definition: updatevalue.hpp:34
bool m_update
Definition: updatevalue.hpp:12
virtual const T & getUpdate()
Definition: updatevalue.hpp:23
bool isUpdate() const
Definition: updatevalue.hpp:39
Definition: updatevalue.hpp:44
UpdateValueVideoFrameRef & operator=(const VideoFrameRef &videoFrame) override
Definition: updatevalue.hpp:54
UpdateValueVideoFrameRef()
Definition: updatevalue.hpp:48
const VideoFrameRef & getUpdate() override
Definition: updatevalue.hpp:62
void updateBy(UpdateValueVideoFrameRef &updateValue)
Definition: updatevalue.hpp:68
UpdateValueVideoFrameRef(const VideoFrameRef &value)
Definition: updatevalue.hpp:50
bool isUpdateSize() const
Definition: updatevalue.hpp:74
Definition: frame.hpp:47
bool isSameSize(const VideoFrameRef &frame) const
Definition: frame.hpp:130