comparison base/Clipboard.h @ 1610:7db29268cf4c single-point

Bitfield + reorder for packing
author Chris Cannam
date Tue, 05 Mar 2019 14:18:37 +0000
parents ad5f892c0c4d
children b2f32c554199
comparison
equal deleted inserted replaced
1609:560453546749 1610:7db29268cf4c
29 public: 29 public:
30 Point(sv_frame_t frame, QString label); 30 Point(sv_frame_t frame, QString label);
31 Point(sv_frame_t frame, float value, QString label); 31 Point(sv_frame_t frame, float value, QString label);
32 Point(sv_frame_t frame, float value, sv_frame_t duration, QString label); 32 Point(sv_frame_t frame, float value, sv_frame_t duration, QString label);
33 Point(sv_frame_t frame, float value, sv_frame_t duration, float level, QString label); 33 Point(sv_frame_t frame, float value, sv_frame_t duration, float level, QString label);
34 Point(const Point &point); 34
35 Point &operator=(const Point &point); 35 Point(const Point &point) =default;
36 Point &operator=(const Point &point) =default;
36 37
37 bool haveFrame() const; 38 bool haveFrame() const;
38 sv_frame_t getFrame() const; 39 sv_frame_t getFrame() const;
39 Point withFrame(sv_frame_t frame) const; 40 Point withFrame(sv_frame_t frame) const;
40 41
59 60
60 sv_frame_t getReferenceFrame() const; 61 sv_frame_t getReferenceFrame() const;
61 void setReferenceFrame(sv_frame_t); 62 void setReferenceFrame(sv_frame_t);
62 63
63 private: 64 private:
64 bool m_haveFrame; 65 // Order of fields here is chosen to minimise overall size of struct.
66 // If you change something, check what difference it makes to packing.
67 bool m_haveValue : 1;
68 bool m_haveLevel : 1;
69 bool m_haveFrame : 1;
70 bool m_haveDuration : 1;
71 bool m_haveReferenceFrame : 1;
72 bool m_haveLabel : 1;
73 float m_value;
74 float m_level;
65 sv_frame_t m_frame; 75 sv_frame_t m_frame;
66 bool m_haveValue;
67 float m_value;
68 bool m_haveDuration;
69 sv_frame_t m_duration; 76 sv_frame_t m_duration;
70 bool m_haveLabel; 77 sv_frame_t m_referenceFrame;
71 QString m_label; 78 QString m_label;
72 bool m_haveLevel;
73 float m_level;
74 bool m_haveReferenceFrame;
75 sv_frame_t m_referenceFrame;
76 }; 79 };
77 80
78 Clipboard(); 81 Clipboard();
79 ~Clipboard(); 82 ~Clipboard();
80 83