Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: re-run new clang format on all files #153

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion components/cli/include/cli.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ class Cli : private cli::CliSession {
* @param _out The output stream to which to write characters.
*/
explicit Cli(cli::Cli &_cli, std::istream &_in = std::cin, std::ostream &_out = std::cout)
: CliSession(_cli, _out, 1), exit(false), in(_in) {
: CliSession(_cli, _out, 1)
, exit(false)
, in(_in) {
if (!_in.good())
throw std::invalid_argument("istream invalid");
if (!_out.good())
Expand Down
26 changes: 20 additions & 6 deletions components/color/src/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace espp {

Rgb::Rgb(const float &_r, const float &_g, const float &_b) : r(_r), g(_g), b(_b) {
Rgb::Rgb(const float &_r, const float &_g, const float &_b)
: r(_r)
, g(_g)
, b(_b) {
if (r > 1.0 || g > 1.0 || b > 1.0) {
r /= 255.;
g /= 255.;
Expand All @@ -13,9 +16,13 @@ Rgb::Rgb(const float &_r, const float &_g, const float &_b) : r(_r), g(_g), b(_b
b = std::clamp(b, 0.0f, 1.0f);
}

Rgb::Rgb(const Rgb &rgb) : r(rgb.r), g(rgb.g), b(rgb.b) {}
Rgb::Rgb(const Rgb &rgb)
: r(rgb.r)
, g(rgb.g)
, b(rgb.b) {}

Rgb::Rgb(const Hsv &hsv) : Rgb(hsv.rgb()) {}
Rgb::Rgb(const Hsv &hsv)
: Rgb(hsv.rgb()) {}

Rgb Rgb::operator+(const Rgb &rhs) const {
// divide by number of elements that went into it (blending) instead of just
Expand Down Expand Up @@ -71,15 +78,22 @@ Hsv Rgb::hsv() const {
return HSV;
}

Hsv::Hsv(const float &_h, const float &_s, const float &_v) : h(_h), s(_s), v(_v) {
Hsv::Hsv(const float &_h, const float &_s, const float &_v)
: h(_h)
, s(_s)
, v(_v) {
h = std::clamp(h, 0.0f, 360.0f);
s = std::clamp(s, 0.0f, 1.0f);
v = std::clamp(v, 0.0f, 1.0f);
}

Hsv::Hsv(const Hsv &hsv) : h(hsv.h), s(hsv.s), v(hsv.v) {}
Hsv::Hsv(const Hsv &hsv)
: h(hsv.h)
, s(hsv.s)
, v(hsv.v) {}

Hsv::Hsv(const Rgb &rgb) : Hsv(rgb.hsv()) {}
Hsv::Hsv(const Rgb &rgb)
: Hsv(rgb.hsv()) {}

Rgb Hsv::rgb() const {
Rgb RGB;
Expand Down
3 changes: 2 additions & 1 deletion components/display_drivers/example/main/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class Gui {
};

explicit Gui(const Config &config)
: display_(config.display), logger_({.tag = "Gui", .level = config.log_level}) {
: display_(config.display)
, logger_({.tag = "Gui", .level = config.log_level}) {
init_ui();
// now start the gui updater task
using namespace std::placeholders;
Expand Down
7 changes: 4 additions & 3 deletions components/event_manager/src/event_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ bool EventManager::remove_subscriber(const std::string &topic, const std::string
auto elem = std::find(std::begin(topic_subscribers), std::end(topic_subscribers), component);
bool exists = elem != std::end(topic_subscribers);
if (!exists) {
logger_.warn("Cannot remove subscriber, '{}' is not registered as a subscriber for topic '{}'",
component, topic);
logger_.warn(
"Cannot remove subscriber, '{}' is not registered as a subscriber for topic '{}'",
component, topic);
// component is not registered as a subscriber, so return false
return false;
}
Expand All @@ -141,7 +142,7 @@ bool EventManager::remove_subscriber(const std::string &topic, const std::string
// remove from `subscriber_callbacks_`
{
std::lock_guard<std::recursive_mutex> lk(callbacks_mutex_);
auto& callbacks = subscriber_callbacks_[topic];
auto &callbacks = subscriber_callbacks_[topic];

auto is_component = [&component](std::pair<std::string, event_callback_fn> &e) {
return std::get<0>(e) == component;
Expand Down
4 changes: 3 additions & 1 deletion components/filters/include/transfer_function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ namespace espp {
template <size_t N> struct TransferFunction {
TransferFunction() = default;

TransferFunction(const std::array<float, N> &b, const std::array<float, N> &a) : b(b), a(a) {}
TransferFunction(const std::array<float, N> &b, const std::array<float, N> &a)
: b(b)
, a(a) {}

std::array<float, N> b = {}; /**< B coefficients. */
std::array<float, N> a = {}; /**< A coefficients. */
Expand Down
3 changes: 2 additions & 1 deletion components/i2c/example/main/i2c_menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

class I2cMenu {
public:
explicit I2cMenu(std::reference_wrapper<espp::I2c> i2c) : i2c_(i2c) {}
explicit I2cMenu(std::reference_wrapper<espp::I2c> i2c)
: i2c_(i2c) {}

std::unique_ptr<cli::Menu> get(std::string_view name = "i2c",
std::string_view description = "I2c menu") {
Expand Down
7 changes: 5 additions & 2 deletions components/math/include/bezier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,18 @@ template <typename T> class Bezier {
* @param config Unweighted Config structure containing the control points.
*/
explicit Bezier(const Config &config)
: weighted_(false), control_points_(config.control_points) {}
: weighted_(false)
, control_points_(config.control_points) {}

/**
* @brief Construct a rational / weighted cubic bezier curve for evaluation.
* @param config Rational / weighted WeightedConfig structure containing the
* control points and their weights.
*/
explicit Bezier(const WeightedConfig &config)
: weighted_(true), control_points_(config.control_points), weights_(config.weights) {}
: weighted_(true)
, control_points_(config.control_points)
, weights_(config.weights) {}

/**
* @brief Evaluate the bezier at \p t.
Expand Down
4 changes: 3 additions & 1 deletion components/math/include/gaussian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class Gaussian {
* @param config Config structure for the gaussian.
*/
explicit Gaussian(const Config &config)
: gamma_(config.gamma), alpha_(config.alpha), beta_(config.beta) {}
: gamma_(config.gamma)
, alpha_(config.alpha)
, beta_(config.beta) {}

/**
* @brief Get the currently configured gamma (shape).
Expand Down
8 changes: 6 additions & 2 deletions components/math/include/vector2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ template <typename T> class Vector2d {
* @param x The starting X value.
* @param y The starting Y value.
*/
explicit Vector2d(T x = T(0), T y = T(0)) : x_(x), y_(y) {}
explicit Vector2d(T x = T(0), T y = T(0))
: x_(x)
, y_(y) {}

/**
* @brief Vector copy constructor.
* @param other Vector to copy.
*/
Vector2d(const Vector2d &other) : x_(other.x_), y_(other.y_) {}
Vector2d(const Vector2d &other)
: x_(other.x_)
, y_(other.y_) {}

/**
* @brief Assignment operator
Expand Down
3 changes: 2 additions & 1 deletion components/rtsp/include/jpeg_frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class JpegFrame {
/// @param data The buffer containing the jpeg data.
/// @param size The size of the buffer.
explicit JpegFrame(const char *data, size_t size)
: data_(data, data + size), header_(std::string_view((const char *)data_.data(), size)) {}
: data_(data, data + size)
, header_(std::string_view((const char *)data_.data(), size)) {}

/// Get a reference to the header.
/// @return A reference to the header.
Expand Down
8 changes: 6 additions & 2 deletions components/rtsp/include/jpeg_header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ class JpegHeader {
/// @param q0_table The quantization table for the Y channel.
/// @param q1_table The quantization table for the Cb and Cr channels.
explicit JpegHeader(int width, int height, std::string_view q0_table, std::string_view q1_table)
: width_(width), height_(height), q0_table_(q0_table), q1_table_(q1_table) {
: width_(width)
, height_(height)
, q0_table_(q0_table)
, q1_table_(q1_table) {
serialize();
}

/// Create a JPEG header from a given JPEG header data.
explicit JpegHeader(std::string_view data) : data_(data.data(), data.data() + data.size()) {
explicit JpegHeader(std::string_view data)
: data_(data.data(), data.data() + data.size()) {
parse();
}

Expand Down
23 changes: 18 additions & 5 deletions components/rtsp/include/rtp_jpeg_packet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ class RtpJpegPacket : public RtpPacket {
public:
/// Construct an RTP packet from a buffer.
/// @param data The buffer containing the RTP packet.
explicit RtpJpegPacket(std::string_view data) : RtpPacket(data) { parse_mjpeg_header(); }
explicit RtpJpegPacket(std::string_view data)
: RtpPacket(data) {
parse_mjpeg_header();
}

/// Construct an RTP packet from fields
/// @details This will construct a packet with quantization tables, so it
Expand All @@ -25,8 +28,13 @@ class RtpJpegPacket : public RtpPacket {
explicit RtpJpegPacket(const int type_specific, const int frag_type, const int q, const int width,
const int height, std::string_view q0, std::string_view q1,
std::string_view scan_data)
: RtpPacket(PAYLOAD_OFFSET_WITH_QUANT + scan_data.size()), type_specific_(type_specific),
offset_(0), frag_type_(frag_type), q_(q), width_(width), height_(height) {
: RtpPacket(PAYLOAD_OFFSET_WITH_QUANT + scan_data.size())
, type_specific_(type_specific)
, offset_(0)
, frag_type_(frag_type)
, q_(q)
, width_(width)
, height_(height) {

jpeg_data_start_ = PAYLOAD_OFFSET_WITH_QUANT;
jpeg_data_size_ = scan_data.size();
Expand All @@ -51,8 +59,13 @@ class RtpJpegPacket : public RtpPacket {
/// @param scan_data The scan data.
explicit RtpJpegPacket(const int type_specific, const int offset, const int frag_type,
const int q, const int width, const int height, std::string_view scan_data)
: RtpPacket(PAYLOAD_OFFSET_NO_QUANT + scan_data.size()), type_specific_(type_specific),
offset_(offset), frag_type_(frag_type), q_(q), width_(width), height_(height) {
: RtpPacket(PAYLOAD_OFFSET_NO_QUANT + scan_data.size())
, type_specific_(type_specific)
, offset_(offset)
, frag_type_(frag_type)
, q_(q)
, width_(width)
, height_(height) {
jpeg_data_start_ = PAYLOAD_OFFSET_NO_QUANT;
jpeg_data_size_ = scan_data.size();

Expand Down
25 changes: 20 additions & 5 deletions components/rtsp/include/rtp_packet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,32 @@ class RtpPacket {
/// Construct an empty RtpPacket.
/// The packet_ vector is empty and the header fields are set to 0.
RtpPacket()
: version_(2), padding_(false), extension_(false), csrc_count_(0), marker_(false),
payload_type_(0), sequence_number_(0), timestamp_(0), ssrc_(0), payload_size_(0) {
: version_(2)
, padding_(false)
, extension_(false)
, csrc_count_(0)
, marker_(false)
, payload_type_(0)
, sequence_number_(0)
, timestamp_(0)
, ssrc_(0)
, payload_size_(0) {
// ensure that the packet_ vector is at least RTP_HEADER_SIZE bytes long
packet_.resize(RTP_HEADER_SIZE);
}

/// Construct an RtpPacket with a payload of size payload_size.
explicit RtpPacket(size_t payload_size)
: version_(2), padding_(false), extension_(false), csrc_count_(0), marker_(false),
payload_type_(0), sequence_number_(0), timestamp_(0), ssrc_(0),
payload_size_(payload_size) {
: version_(2)
, padding_(false)
, extension_(false)
, csrc_count_(0)
, marker_(false)
, payload_type_(0)
, sequence_number_(0)
, timestamp_(0)
, ssrc_(0)
, payload_size_(payload_size) {
// ensure that the packet_ vector is at least RTP_HEADER_SIZE + payload_size bytes long
packet_.resize(RTP_HEADER_SIZE + payload_size);
}
Expand Down
4 changes: 2 additions & 2 deletions components/socket/include/tcp_socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ class TcpSocket : public Socket {
* @param remote_info The remote endpoint info.
*/
explicit TcpSocket(int socket_fd, const Socket::Info &remote_info)
: Socket(socket_fd, Logger::Config{.tag = "TcpSocket", .level = Logger::Verbosity::WARN}),
remote_info_(remote_info) {
: Socket(socket_fd, Logger::Config{.tag = "TcpSocket", .level = Logger::Verbosity::WARN})
, remote_info_(remote_info) {
connected_ = true;
set_keepalive();
}
Expand Down
Loading
Loading