Skip to content

Commit

Permalink
Fix the reactor name for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
TrentHouliston committed Aug 9, 2023
1 parent 414034f commit c0e9081
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/PowerPlant.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ void PowerPlant::install() {
// Make sure that the class that we received is a reactor
static_assert(std::is_base_of<Reactor, T>::value, "You must install Reactors");

// Get the demangled reactor name and strip `struct ` and `class ` from it
std::string reactor_name = util::demangle(typeid(T).name());
reactor_name = std::regex_replace(reactor_name, std::regex(R"(struct\s+)"), "");
reactor_name = std::regex_replace(reactor_name, std::regex(R"(class\s+)"), "");

// The reactor constructor should handle subscribing to events
reactors.push_back(
std::make_unique<T>(std::make_unique<Environment>(*this, util::demangle(typeid(T).name()), level)));
reactors.push_back(std::make_unique<T>(std::make_unique<Environment>(*this, reactor_name, level)));
}

// Default emit with no types
Expand Down
2 changes: 1 addition & 1 deletion src/Reactor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class Reactor {
std::vector<threading::ReactionHandle> reaction_handles{};

public:
/// @brief TODO
/// @brief The powerplant that this reactor is running in
PowerPlant& powerplant;

/// @brief The demangled string name of this reactor
Expand Down

0 comments on commit c0e9081

Please sign in to comment.