cscore: Add properties support to VideoSink (#1228)

Refactor the Property internals into PropertyContainer.
This commit is contained in:
Peter Johnson
2018-07-27 22:12:30 -07:00
committed by GitHub
parent c9a75a119a
commit 9398278250
24 changed files with 695 additions and 389 deletions

View File

@@ -11,6 +11,7 @@
#include <string>
#include <vector>
#include <wpi/Signal.h>
#include <wpi/StringRef.h>
#include "cscore_c.h"
@@ -21,41 +22,18 @@ namespace cs {
class PropertyImpl {
public:
PropertyImpl() = default;
explicit PropertyImpl(wpi::StringRef name_) : name{name_} {}
explicit PropertyImpl(wpi::StringRef name_);
PropertyImpl(wpi::StringRef name_, CS_PropertyKind kind_, int step_,
int defaultValue_, int value_)
: name{name_},
propKind{kind_},
step{step_},
defaultValue{defaultValue_},
value{value_} {}
int defaultValue_, int value_);
PropertyImpl(wpi::StringRef name_, CS_PropertyKind kind_, int minimum_,
int maximum_, int step_, int defaultValue_, int value_);
virtual ~PropertyImpl() = default;
PropertyImpl(const PropertyImpl& oth) = delete;
PropertyImpl& operator=(const PropertyImpl& oth) = delete;
void SetValue(int v) {
if (hasMinimum && v < minimum)
value = minimum;
else if (hasMaximum && v > maximum)
value = maximum;
else
value = v;
valueSet = true;
}
void SetValue(wpi::StringRef v) {
valueStr = v;
valueSet = true;
}
void SetDefaultValue(int v) {
if (hasMinimum && v < minimum)
defaultValue = minimum;
else if (hasMaximum && v > maximum)
defaultValue = maximum;
else
defaultValue = v;
}
void SetValue(int v);
void SetValue(wpi::StringRef v);
void SetDefaultValue(int v);
std::string name;
CS_PropertyKind propKind{CS_PROP_NONE};
@@ -69,6 +47,9 @@ class PropertyImpl {
std::string valueStr;
std::vector<std::string> enumChoices;
bool valueSet{false};
// emitted when value changes
wpi::sig::Signal<> changed;
};
} // namespace cs