Skip to content

Commit b214e17

Browse files
committed
clang tidy
1 parent 8410802 commit b214e17

28 files changed

+80
-100
lines changed

examples/count/main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using namespace reactor;
66
using namespace std::chrono_literals;
77

8-
class Count : public Reactor {
8+
class Count final : public Reactor {
99
private:
1010
// actions
1111
Timer timer{"timer", this};

examples/hello/main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using namespace reactor;
77
using namespace std::chrono_literals;
88

9-
class Hello : public Reactor {
9+
class Hello final : public Reactor {
1010
private:
1111
// actions
1212
Timer timer{"timer", this, 1s, 2s};

examples/multiport_mutation/consumer.hh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* Tassilo Tanneberger
77
*/
88

9-
#ifndef CONSUMER_HH // NOLINT
10-
#define CONSUMER_HH // NOLINT
9+
#ifndef MULTIPORT_MUTATION_CONSUMER_HH
10+
#define MULTIPORT_MUTATION_CONSUMER_HH
1111

1212
#include <reactor-cpp/reactor-cpp.hh>
1313
#include <reactor-cpp/scopes.hh>
@@ -45,4 +45,4 @@ public:
4545
void assemble() override { handle.declare_trigger(&in); }
4646
};
4747

48-
#endif // CONSUMER_HH
48+
#endif // MULTIPORT_MUTATION_CONSUMER_HH

examples/multiport_mutation/load_balancer.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* Tassilo Tanneberger
77
*/
88

9-
#ifndef MULTIPORT_MUTATION_LOAD_BALANCER_HH // NOLINT
10-
#define MULTIPORT_MUTATION_LOAD_BALANCER_HH // NOLINT
9+
#ifndef MULTIPORT_MUTATION_LOAD_BALANCER_HH
10+
#define MULTIPORT_MUTATION_LOAD_BALANCER_HH
1111

1212
#include <reactor-cpp/mutations/multiport.hh>
1313
#include <reactor-cpp/reactor-cpp.hh>

examples/multiport_mutation/main.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Deployment final : public Reactor { // NOLINT
2929
int state = 0;
3030

3131
public:
32-
Inner(Reactor* reactor)
32+
explicit Inner(Reactor* reactor)
3333
: MutableScope(reactor) {}
3434
void reaction_1(const Input<unsigned>& scale, std::vector<std::unique_ptr<Consumer>>& reactor_bank,
3535
ModifableMultiport<Output<unsigned>>& load_balancer) {
@@ -41,8 +41,8 @@ class Deployment final : public Reactor { // NOLINT
4141
};
4242

4343
std::function get_input_port = [](const std::unique_ptr<Consumer>& consumer) { return &consumer->in; };
44-
auto rescale = std::make_shared<ResizeMultiportToBank<unsigned, Consumer>>(&load_balancer, &reactor_bank,
45-
get_input_port, lambda, new_size);
44+
const auto rescale = std::make_shared<ResizeMultiportToBank<unsigned, Consumer>>(
45+
&load_balancer, &reactor_bank, get_input_port, lambda, new_size);
4646

4747
add_to_transaction(rescale);
4848

examples/multiport_mutation/producer.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* Tassilo Tanneberger
77
*/
88

9-
#ifndef MULTIPORT_MUTATION_PRODUCER_HH // NOLINT
10-
#define MULTIPORT_MUTATION_PRODUCER_HH // NOLINT
9+
#ifndef MULTIPORT_MUTATION_PRODUCER_HH
10+
#define MULTIPORT_MUTATION_PRODUCER_HH
1111

1212
#include <reactor-cpp/reactor-cpp.hh>
1313

examples/ports/main.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using namespace reactor;
66
using namespace std::chrono_literals;
77

8-
class Trigger : public Reactor {
8+
class Trigger final : public Reactor {
99
private:
1010
Timer timer;
1111
Reaction r_timer{"r_timer", 1, this, [this]() { on_timer(); }};
@@ -25,7 +25,7 @@ class Trigger : public Reactor {
2525
void on_timer() { trigger.set(); }
2626
};
2727

28-
class Counter : public Reactor {
28+
class Counter final : public Reactor {
2929
private:
3030
int value_{0};
3131
Reaction r_trigger{"r_trigger", 1, this, [this]() { on_trigger(); }};
@@ -49,7 +49,7 @@ class Counter : public Reactor {
4949
}
5050
};
5151

52-
class Printer : public Reactor {
52+
class Printer final : public Reactor {
5353
private:
5454
Reaction r_value{"r_value", 1, this, [this]() { on_value(); }};
5555

@@ -64,10 +64,10 @@ class Printer : public Reactor {
6464
r_value.declare_trigger(&value);
6565
}
6666

67-
void on_value() { std::cout << this->name() << ": " << *value.get() << '\n'; }
67+
void on_value() const { std::cout << this->name() << ": " << *value.get() << '\n'; }
6868
};
6969

70-
class Adder : public Reactor {
70+
class Adder final : public Reactor {
7171
private:
7272
Reaction r_add{"r_add", 1, this, [this]() { add(); }};
7373

examples/power_train/main.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
using namespace reactor;
66

7-
class LeftPedal : public Reactor {
7+
class LeftPedal final : public Reactor {
88
public:
99
// ports
1010
Output<void> angle{"angle", this}; // NOLINT
@@ -30,7 +30,7 @@ class LeftPedal : public Reactor {
3030
}
3131
};
3232

33-
class RightPedal : public Reactor {
33+
class RightPedal final : public Reactor {
3434
public:
3535
// ports
3636
Output<void> angle{"angle", this}; // NOLINT
@@ -60,7 +60,7 @@ class RightPedal : public Reactor {
6060
}
6161
};
6262

63-
class BrakeControl : public Reactor {
63+
class BrakeControl final : public Reactor {
6464
public:
6565
// ports
6666
Input<void> angle{"angle", this}; // NOLINT
@@ -81,7 +81,7 @@ class BrakeControl : public Reactor {
8181
}
8282
};
8383

84-
class EngineControl : public Reactor {
84+
class EngineControl final : public Reactor {
8585
public:
8686
// ports
8787
Input<void> angle{"angle", this}; // NOLINT
@@ -118,7 +118,7 @@ class EngineControl : public Reactor {
118118
}
119119
};
120120

121-
class Brake : public Reactor {
121+
class Brake final : public Reactor {
122122
public:
123123
// ports
124124
Input<void> force{"force", this}; // NOLINT
@@ -136,7 +136,7 @@ class Brake : public Reactor {
136136
void assemble() override { r1.declare_trigger(&force); }
137137
};
138138

139-
class Engine : public Reactor {
139+
class Engine final : public Reactor {
140140
public:
141141
// ports
142142
Input<void> torque{"torque", this}; // NOLINT

include/reactor-cpp/assert.hh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "reactor-cpp/fwd.hh"
1414

1515
#include <cassert>
16-
#include <sstream>
1716
#include <stdexcept>
1817
#include <string>
1918

@@ -71,7 +70,7 @@ public:
7170
: std::runtime_error(build_message(msg)) {}
7271
};
7372

74-
constexpr void validate([[maybe_unused]] bool condition, [[maybe_unused]] const std::string_view message) {
73+
constexpr void validate([[maybe_unused]] const bool condition, [[maybe_unused]] const std::string_view message) {
7574
if constexpr (runtime_validation) {
7675
if (!condition) {
7776
print_backtrace();
@@ -80,8 +79,8 @@ constexpr void validate([[maybe_unused]] bool condition, [[maybe_unused]] const
8079
}
8180
}
8281

83-
template <typename E> constexpr auto extract_value(E enum_value) -> typename std::underlying_type_t<E> {
84-
return static_cast<typename std::underlying_type_t<E>>(enum_value);
82+
template <typename E> constexpr auto extract_value(E enum_value) -> std::underlying_type_t<E> {
83+
return static_cast<std::underlying_type_t<E>>(enum_value);
8584
}
8685

8786
void assert_phase([[maybe_unused]] const ReactorElement* ptr, [[maybe_unused]] Phase phase);

include/reactor-cpp/connection.hh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "logical_time.hh"
1818
#include "port.hh"
1919
#include "reaction.hh"
20-
#include "reactor.hh"
2120
#include "time.hh"
2221
#include "time_barrier.hh"
2322

@@ -69,7 +68,7 @@ protected:
6968
return [this](const BasePort& port) {
7069
// We know that port must be of type Port<T>
7170
auto& typed_port = reinterpret_cast<const Port<T>&>(port); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
72-
if constexpr (std::is_same<T, void>::value) {
71+
if constexpr (std::is_same_v<T, void>) {
7372
this->schedule();
7473
} else {
7574
this->schedule(std::move(typed_port.get()));
@@ -81,7 +80,7 @@ public:
8180
void setup() noexcept override {
8281
Action<T>::setup();
8382

84-
if constexpr (std::is_same<T, void>::value) {
83+
if constexpr (std::is_same_v<T, void>) {
8584
for (auto port : this->downstream_ports()) {
8685
port->set();
8786
}
@@ -134,7 +133,7 @@ public:
134133
// without locking.
135134
auto tag = Tag::from_logical_time(scheduler->logical_time());
136135
[[maybe_unused]] bool result{false};
137-
if constexpr (std::is_same<T, void>::value) {
136+
if constexpr (std::is_same_v<T, void>) {
138137
result = this->schedule_at(tag);
139138
} else {
140139
result = this->schedule_at(std::move(typed_port.get()), tag);

0 commit comments

Comments
 (0)