Skip to content

Commit

Permalink
Return installed reactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Bidski committed Oct 5, 2023
1 parent b584fa4 commit aeccb70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/PowerPlant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ class PowerPlant {
*
* @tparam T The type of the reactor to build and install
* @tparam level The initial logging level for this reactor to use
*
* @return A reference to the installed reactor
*/
template <typename T>
void install();
Reactor& install();

/**
* @brief Generic submit function for submitting tasks to the thread pool.
Expand Down
4 changes: 3 additions & 1 deletion src/PowerPlant.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ inline PowerPlant::PowerPlant(Configuration config, int argc, const char* argv[]
}

template <typename T>
void PowerPlant::install() {
Reactor& 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");

// 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()))));

return *reactors.back();
}

// Default emit with no types
Expand Down

0 comments on commit aeccb70

Please sign in to comment.