diff --git a/src/PowerPlant.hpp b/src/PowerPlant.hpp index 550d0869e..9ec3374db 100644 --- a/src/PowerPlant.hpp +++ b/src/PowerPlant.hpp @@ -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 - void install(); + T& install(); /** * @brief Generic submit function for submitting tasks to the thread pool. diff --git a/src/PowerPlant.ipp b/src/PowerPlant.ipp index e31d4115c..3f12de36b 100644 --- a/src/PowerPlant.ipp +++ b/src/PowerPlant.ipp @@ -53,13 +53,15 @@ inline PowerPlant::PowerPlant(Configuration config, int argc, const char* argv[] } template -void PowerPlant::install() { +T& PowerPlant::install() { // Make sure that the class that we received is a reactor static_assert(std::is_base_of::value, "You must install Reactors"); // The reactor constructor should handle subscribing to events reactors.push_back(std::make_unique(std::make_unique(*this, util::demangle(typeid(T).name())))); + + return static_cast(*reactors.back()); } // Default emit with no types