mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Add braces to C++ single-line loops and conditionals (NFC) (#2973)
This makes code easier to read and more consistent between C++ and Java. Also update clang-format settings to always add a line break (even if no braces are used).
This commit is contained in:
@@ -124,10 +124,11 @@ struct RawEvent {
|
||||
RawEvent(const wpi::Twine& name_, CS_Handle handle_, RawEvent::Kind kind_)
|
||||
: kind{kind_}, name{name_.str()} {
|
||||
if (kind_ == kSinkCreated || kind_ == kSinkDestroyed ||
|
||||
kind_ == kSinkEnabled || kind_ == kSinkDisabled)
|
||||
kind_ == kSinkEnabled || kind_ == kSinkDisabled) {
|
||||
sinkHandle = handle_;
|
||||
else
|
||||
} else {
|
||||
sourceHandle = handle_;
|
||||
}
|
||||
}
|
||||
RawEvent(const wpi::Twine& name_, CS_Source source_, const VideoMode& mode_)
|
||||
: kind{kSourceVideoModeChanged},
|
||||
|
||||
@@ -94,7 +94,8 @@ inline VideoSource& VideoSource::operator=(VideoSource other) noexcept {
|
||||
|
||||
inline VideoSource::~VideoSource() {
|
||||
m_status = 0;
|
||||
if (m_handle != 0) ReleaseSource(m_handle, &m_status);
|
||||
if (m_handle != 0)
|
||||
ReleaseSource(m_handle, &m_status);
|
||||
}
|
||||
|
||||
inline VideoSource::Kind VideoSource::GetKind() const {
|
||||
@@ -309,7 +310,8 @@ inline HttpCamera::HttpCamera(const wpi::Twine& name,
|
||||
HttpCameraKind kind) {
|
||||
std::vector<std::string> vec;
|
||||
vec.reserve(urls.size());
|
||||
for (const auto& url : urls) vec.emplace_back(url);
|
||||
for (const auto& url : urls)
|
||||
vec.emplace_back(url);
|
||||
m_handle = CreateHttpCamera(
|
||||
name, vec, static_cast<CS_HttpCameraKind>(static_cast<int>(kind)),
|
||||
&m_status);
|
||||
@@ -330,7 +332,8 @@ template <typename T>
|
||||
inline void HttpCamera::SetUrls(std::initializer_list<T> urls) {
|
||||
std::vector<std::string> vec;
|
||||
vec.reserve(urls.size());
|
||||
for (const auto& url : urls) vec.emplace_back(url);
|
||||
for (const auto& url : urls)
|
||||
vec.emplace_back(url);
|
||||
m_status = 0;
|
||||
::cs::SetHttpCameraUrls(m_handle, vec, &m_status);
|
||||
}
|
||||
@@ -457,7 +460,8 @@ inline void ImageSource::SetEnumPropertyChoices(
|
||||
const VideoProperty& property, std::initializer_list<T> choices) {
|
||||
std::vector<std::string> vec;
|
||||
vec.reserve(choices.size());
|
||||
for (const auto& choice : choices) vec.emplace_back(choice);
|
||||
for (const auto& choice : choices)
|
||||
vec.emplace_back(choice);
|
||||
m_status = 0;
|
||||
SetSourceEnumPropertyChoices(m_handle, property.m_handle, vec, &m_status);
|
||||
}
|
||||
@@ -476,7 +480,8 @@ inline VideoSink& VideoSink::operator=(VideoSink other) noexcept {
|
||||
|
||||
inline VideoSink::~VideoSink() {
|
||||
m_status = 0;
|
||||
if (m_handle != 0) ReleaseSink(m_handle, &m_status);
|
||||
if (m_handle != 0)
|
||||
ReleaseSink(m_handle, &m_status);
|
||||
}
|
||||
|
||||
inline VideoSink::Kind VideoSink::GetKind() const {
|
||||
@@ -625,7 +630,8 @@ inline VideoListener& VideoListener::operator=(VideoListener&& other) noexcept {
|
||||
|
||||
inline VideoListener::~VideoListener() {
|
||||
CS_Status status = 0;
|
||||
if (m_handle != 0) RemoveListener(m_handle, &status);
|
||||
if (m_handle != 0)
|
||||
RemoveListener(m_handle, &status);
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
|
||||
@@ -171,22 +171,22 @@ inline RawCvSink::RawCvSink(const wpi::Twine& name,
|
||||
: RawSink{name, processFrame} {}
|
||||
|
||||
inline uint64_t RawCvSink::GrabFrame(cv::Mat& image, double timeout) {
|
||||
cv::Mat tmpMat;
|
||||
auto retVal = GrabFrameDirect(tmpMat);
|
||||
cv::Mat tmpnam;
|
||||
auto retVal = GrabFrameDirect(tmpnam);
|
||||
if (retVal <= 0) {
|
||||
return retVal;
|
||||
}
|
||||
tmpMat.copyTo(image);
|
||||
tmpnam.copyTo(image);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
inline uint64_t RawCvSink::GrabFrameNoTimeout(cv::Mat& image) {
|
||||
cv::Mat tmpMat;
|
||||
auto retVal = GrabFrameNoTimeoutDirect(tmpMat);
|
||||
cv::Mat tmpnam;
|
||||
auto retVal = GrabFrameNoTimeoutDirect(tmpnam);
|
||||
if (retVal <= 0) {
|
||||
return retVal;
|
||||
}
|
||||
tmpMat.copyTo(image);
|
||||
tmpnam.copyTo(image);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,9 @@ inline uint64_t RawCvSink::GrabFrameDirect(cv::Mat& image, double timeout) {
|
||||
rawFrame.width = 0;
|
||||
rawFrame.pixelFormat = CS_PixelFormat::CS_PIXFMT_BGR;
|
||||
m_status = RawSink::GrabFrame(rawFrame, timeout);
|
||||
if (m_status <= 0) return m_status;
|
||||
if (m_status <= 0) {
|
||||
return m_status;
|
||||
}
|
||||
image = cv::Mat{rawFrame.height, rawFrame.width, CV_8UC3, rawFrame.data};
|
||||
return m_status;
|
||||
}
|
||||
@@ -205,7 +207,9 @@ inline uint64_t RawCvSink::GrabFrameNoTimeoutDirect(cv::Mat& image) {
|
||||
rawFrame.width = 0;
|
||||
rawFrame.pixelFormat = CS_PixelFormat::CS_PIXFMT_BGR;
|
||||
m_status = RawSink::GrabFrameNoTimeout(rawFrame);
|
||||
if (m_status <= 0) return m_status;
|
||||
if (m_status <= 0) {
|
||||
return m_status;
|
||||
}
|
||||
image = cv::Mat{rawFrame.height, rawFrame.width, CV_8UC3, rawFrame.data};
|
||||
return m_status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user