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

+1-1
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

+1-1
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

+3-3
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

+2-2
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

+4-4
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

+2-2
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

+6-6
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

+6-8
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

+3-4
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

+3-4
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);

include/reactor-cpp/environment.hh

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private:
7676
Graph<BasePort*, ConnectionProperties> graph_{};
7777
Graph<BasePort*, ConnectionProperties> optimized_graph_{};
7878

79-
void build_dependency_graph(Reactor* reactor);
79+
void build_dependency_graph(const Reactor* reactor);
8080
void calculate_indexes();
8181

8282
std::mutex shutdown_mutex_{};

include/reactor-cpp/graph.hh

-14
Original file line numberDiff line numberDiff line change
@@ -123,22 +123,8 @@ public:
123123

124124
if (conns != std::end(graph_[source])) {
125125
graph_[source].erase(conns);
126-
} else {
127-
std::cout << "for some reason nothing got deleted! WARNING" << std::endl;
128126
}
129127
}
130-
/*
131-
[[nodiscard]] auto get_destinations(E source) const noexcept -> std::vector<std::pair<P, E>> {
132-
return graph_[source];
133-
}
134-
135-
[[nodiscard]] auto get_upstream(E vertex) const noexcept -> std::optional<E> {
136-
for (const auto& [source, sinks] : graph_) {
137-
if (sinks.second.contains(vertex)) {
138-
return source;
139-
}
140-
}
141-
}*/
142128

143129
friend auto operator<<(std::ostream& outstream, const Graph& graph) -> std::ostream& {
144130
for (auto const& [source, destinations] : graph.graph_) {

include/reactor-cpp/logging.hh

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010
#define REACTOR_CPP_LOGGING_HH
1111

1212
#include "reactor-cpp/config.hh"
13-
#include "reactor-cpp/time.hh"
14-
#include <chrono>
13+
1514
#include <iostream>
1615
#include <memory>
1716
#include <mutex>
1817
#include <string>
19-
#include <utility>
2018

2119
namespace reactor::log {
2220

include/reactor-cpp/multiport.hh

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ namespace reactor {
2424

2525
class BaseMultiport { // NOLINT cppcoreguidelines-special-member-functions,-warnings-as-errors
2626
protected:
27-
std::atomic<std::size_t> size_{0};
28-
std::vector<std::size_t> present_ports_{};
27+
std::atomic<std::size_t> size_{0}; // NOLINT cppcoreguidelines-non-private-member-variables-in-classes
28+
std::vector<std::size_t> present_ports_{}; // NOLINT cppcoreguidelines-non-private-member-variables-in-classes
2929

3030
private:
3131
std::string name_{};
@@ -53,11 +53,11 @@ protected:
5353
public:
5454
BaseMultiport(std::string name, Reactor* container)
5555
: name_(std::move(name))
56-
, container_(container) {};
56+
, container_(container) {}
5757
~BaseMultiport() = default;
5858

5959
[[nodiscard]] auto name() const noexcept -> const std::string& { return name_; }
60-
auto container() const noexcept -> Reactor* { return container_; }
60+
[[nodiscard]] auto container() const noexcept -> Reactor* { return container_; }
6161
};
6262

6363
template <class T, class A = std::allocator<T>>
@@ -79,7 +79,7 @@ public:
7979
using const_iterator = typename std::vector<T>::const_iterator;
8080

8181
Multiport(const std::string& name, Reactor* container) noexcept
82-
: BaseMultiport(name, container) {};
82+
: BaseMultiport(name, container) {}
8383
~Multiport() noexcept = default;
8484

8585
auto operator==(const Multiport& other) const noexcept -> bool {

include/reactor-cpp/mutations/multiport.hh

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#ifndef REACTOR_CPP_MUTATIONS_MULTIPORT_HH
1010
#define REACTOR_CPP_MUTATIONS_MULTIPORT_HH
1111

12-
#include <vector>
13-
1412
#include "../multiport.hh"
1513
#include "../mutations.hh"
1614
#include "../port.hh"

include/reactor-cpp/reaction.hh

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public:
6161

6262
void startup() final {}
6363
void shutdown() final {}
64-
void trigger();
64+
void trigger() const;
6565
void set_index(unsigned index);
6666

6767
template <class Dur> void set_deadline(Dur deadline, const std::function<void(void)>& handler) {

include/reactor-cpp/reactor.hh

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define REACTOR_CPP_REACTOR_HH
1111

1212
#include <set>
13-
#include <sstream>
1413
#include <string>
1514

1615
#include "action.hh"

include/reactor-cpp/reactor_element.hh

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#define REACTOR_CPP_REACTOR_ELEMENT_HH
1212

1313
#include <cstdint>
14-
#include <memory>
15-
#include <set>
1614
#include <sstream>
1715
#include <string>
1816

include/reactor-cpp/semaphore.hh

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef REACTOR_CPP_SEMAPHORE_HH
1010
#define REACTOR_CPP_SEMAPHORE_HH
1111

12-
#include <atomic>
1312
#include <condition_variable>
1413
#include <mutex>
1514

include/reactor-cpp/statistics.hh

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include <atomic>
1313

14-
#include "reactor-cpp/config.hh"
1514
#include "reactor-cpp/logging.hh"
1615

1716
namespace reactor {
@@ -23,7 +22,7 @@ private:
2322
#else
2423
constexpr static bool enabled_{false};
2524
#endif
26-
// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
25+
// NOLINT BEGIN(cppcoreguidelines-avoid-non-const-global-variables)
2726
inline static std::atomic_size_t reactor_instances_{0};
2827
inline static std::atomic_size_t connections_{0};
2928
inline static std::atomic_size_t reactions_{0};
@@ -34,7 +33,7 @@ private:
3433
inline static std::atomic_size_t triggered_actions_{0};
3534
inline static std::atomic_size_t set_ports_{0};
3635
inline static std::atomic_size_t scheduled_actions_{0};
37-
// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)
36+
// NOLINT END(cppcoreguidelines-avoid-non-const-global-variables)
3837

3938
static void increment(std::atomic_size_t& counter) {
4039
if constexpr (enabled_) {

0 commit comments

Comments
 (0)