Skip to content

Commit

Permalink
more constification
Browse files Browse the repository at this point in the history
  • Loading branch information
TrentHouliston committed Sep 21, 2023
1 parent 179e292 commit b6ea19d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/dsl/word/emit/UDP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace dsl {
template <typename DataType>
struct UDP {

static inline void emit(PowerPlant& /*powerplant*/,
static inline void emit(const PowerPlant& /*powerplant*/,
std::shared_ptr<DataType> data,
const std::string& to_addr,
in_port_t to_port,
Expand Down
3 changes: 2 additions & 1 deletion src/dsl/word/emit/Watchdog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ namespace dsl {
struct Watchdog {

template <typename WatchdogGroup, typename RuntimeType>
static void emit(PowerPlant& /*powerplant*/, WatchdogServicer<WatchdogGroup, RuntimeType>& servicer) {
static void emit(const PowerPlant& /*powerplant*/,
WatchdogServicer<WatchdogGroup, RuntimeType>& servicer) {
// Update our service time
servicer.service();
}
Expand Down
14 changes: 10 additions & 4 deletions tests/dsl/emit/EmitFusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,28 @@ std::vector<std::string> events; // NOLINT(cppcoreguidelines-avoid-non-const-gl

template <typename T>
struct E1 {
static inline void emit(NUClear::PowerPlant& /*unused*/, std::shared_ptr<T> p, const int& a, const std::string& b) {
static inline void emit(const NUClear::PowerPlant& /*powerplant*/,
std::shared_ptr<T> p,
const int& a,
const std::string& b) {
events.push_back("E1a " + *p + " " + std::to_string(a) + " " + b);
}

static inline void emit(NUClear::PowerPlant& /*unused*/, std::shared_ptr<T> p, const std::string& c) {
static inline void emit(const NUClear::PowerPlant& /*powerplant*/, std::shared_ptr<T> p, const std::string& c) {
events.push_back("E1b " + *p + " " + c);
}
};

template <typename T>
struct E2 {
static inline void emit(NUClear::PowerPlant& /*unused*/, std::shared_ptr<T> p, const bool& d) {
static inline void emit(const NUClear::PowerPlant& /*powerplant*/, std::shared_ptr<T> p, const bool& d) {
events.push_back("E2a " + *p + " " + (d ? "true" : "false"));
}

static inline void emit(NUClear::PowerPlant& /*unused*/, std::shared_ptr<T> p, const int& e, const std::string& f) {
static inline void emit(const NUClear::PowerPlant& /*powerplant*/,
std::shared_ptr<T> p,
const int& e,
const std::string& f) {
events.push_back("E2b " + *p + " " + std::to_string(e) + " " + f);
}
};
Expand Down

0 comments on commit b6ea19d

Please sign in to comment.