Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return installed reactor #95

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
T& 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() {
T& 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 static_cast<T&>(*reactors.back());
}

// Default emit with no types
Expand Down