Skip to content

Commit 0b2eb68

Browse files
committed
clang tidy
1 parent 8410802 commit 0b2eb68

37 files changed

+109
-144
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ 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) {
3636
std::size_t new_size = *scale.get();
37-
std::size_t old_size = reactor_bank.size();
37+
3838
std::function lambda = [](Environment* env, std::size_t index) {
3939
std::string _lf_inst_name = "consumer_" + std::to_string(index);
4040
return std::make_unique<Consumer>(_lf_inst_name, env, index);
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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
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(); }};
1212

1313
public:
14-
Trigger(const std::string& name, Environment* env, Duration period)
14+
Trigger(const std::string& name, Environment* env, const Duration period)
1515
: Reactor(name, env)
1616
, timer{"timer", this, period, Duration::zero()} {}
1717

@@ -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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
#include <iostream>
2-
31
#include "reactor-cpp/reactor-cpp.hh"
42

53
using namespace reactor;
64

7-
class LeftPedal : public Reactor {
5+
class LeftPedal final : public Reactor {
86
public:
97
// ports
108
Output<void> angle{"angle", this}; // NOLINT
@@ -30,7 +28,7 @@ class LeftPedal : public Reactor {
3028
}
3129
};
3230

33-
class RightPedal : public Reactor {
31+
class RightPedal final : public Reactor {
3432
public:
3533
// ports
3634
Output<void> angle{"angle", this}; // NOLINT
@@ -60,7 +58,7 @@ class RightPedal : public Reactor {
6058
}
6159
};
6260

63-
class BrakeControl : public Reactor {
61+
class BrakeControl final : public Reactor {
6462
public:
6563
// ports
6664
Input<void> angle{"angle", this}; // NOLINT
@@ -81,7 +79,7 @@ class BrakeControl : public Reactor {
8179
}
8280
};
8381

84-
class EngineControl : public Reactor {
82+
class EngineControl final : public Reactor {
8583
public:
8684
// ports
8785
Input<void> angle{"angle", this}; // NOLINT
@@ -118,7 +116,7 @@ class EngineControl : public Reactor {
118116
}
119117
};
120118

121-
class Brake : public Reactor {
119+
class Brake final : public Reactor {
122120
public:
123121
// ports
124122
Input<void> force{"force", this}; // NOLINT
@@ -136,7 +134,7 @@ class Brake : public Reactor {
136134
void assemble() override { r1.declare_trigger(&force); }
137135
};
138136

139-
class Engine : public Reactor {
137+
class Engine final : public Reactor {
140138
public:
141139
// ports
142140
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)