//This file is part of Bertini 2. // //endgames/observers.hpp is free software: you can redistribute it and/or modify //it under the terms of the GNU General Public License as published by //the Free Software Foundation, either version 3 of the License, or //(at your option) any later version. // //endgames/observers.hpp is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with endgames/observers.hpp. If not, see . // // Copyright(C) 2015 - 2021 by Bertini2 Development Team // // See for a copy of the license, // as well as COPYING. Bertini2 is provided with permitted // additional terms in the b2/licenses/ directory. // individual authors of this file include: // silviana amethyst, university of wisconsin eau claire /** \file endgames/observers.hpp \brief Contains the endgames/observers base types */ #pragma once #include "bertini2/endgames/events.hpp" #include "bertini2/logging.hpp" #include "bertini2/detail/observer.hpp" #include namespace bertini { namespace endgame{ /** \brief Logs the endgame run, with gory detail. \ingroup loggers observers */ template struct GoryDetailLogger : public Observer {BOOST_TYPE_INDEX_REGISTER_CLASS using EmitterT = EndgameT; using BCT = typename EndgameT::BaseComplexType; virtual ~GoryDetailLogger() = default; virtual void Observe(AnyEvent const& e) override { if(auto p = dynamic_cast*>(&e)) { BOOST_LOG_TRIVIAL(severity_level::debug) << "time advanced " << p->Get().LatestTime(); } else if (auto p = dynamic_cast*>(&e)) { BOOST_LOG_TRIVIAL(severity_level::debug) << "refined a sample, huzzah"; } else if (auto p = dynamic_cast*>(&e)) { BOOST_LOG_TRIVIAL(severity_level::debug) << "advanced around the circle, to " << p->NewSample()<< " at time " << p->NewTime(); } else if (auto p = dynamic_cast*>(&e)) { BOOST_LOG_TRIVIAL(severity_level::debug) << "closed a loop, cycle number " << p->Get().CycleNumber(); } else if (auto p = dynamic_cast*>(&e)) { BOOST_LOG_TRIVIAL(severity_level::debug) << "approximated the target root. approximation " << p->Get().template FinalApproximation() << " with error " << p->Get().ApproximateError(); } else if (auto p = dynamic_cast*>(&e)) { BOOST_LOG_TRIVIAL(severity_level::debug) << "precision changed from " << p->Previous() << " to " << p->Next(); } else if (auto p = dynamic_cast*>(&e)) { BOOST_LOG_TRIVIAL(severity_level::debug) << "made it to the endgame operating zone at time " << p->Get().LatestTime(); } else if(auto p = dynamic_cast*>(&e)) { BOOST_LOG_TRIVIAL(severity_level::debug) << "converged at time " << p->Get().LatestTime() << " with result " << p->Get().template FinalApproximation() << " and residual " << p->Get().ApproximateError(); } else if (auto p = dynamic_cast*>(&e)) { BOOST_LOG_TRIVIAL(severity_level::debug) << "starting running " << boost::typeindex::type_id().pretty_name(); } else { BOOST_LOG_TRIVIAL(severity_level::debug) << "unprogrammed response for event of type " << boost::typeindex::type_id_runtime(e).pretty_name(); } } }; // gory detail } //re: namespace endgames }// re: namespace bertini