Event listeners no longer take reporter config in constructor

This also required splitting out Listener factory from
the reporter factory hierarchy. In return, the listener
factories only need to take in `IConfig const*`, which
opens up further refactorings down the road in the colour
selection and implementation.
This commit is contained in:
Martin Hořeňovský committed 2022-03-18 00:36:18 +01:00
1 parent 18c58667d7
commit 4acc520f76
15 files changed
+36 -24

No files matched your search

@@ -86,4 +86,5 @@ namespace Catch {
namespace Catch {
IReporterFactory::~IReporterFactory() = default;
EventListenerFactory::~EventListenerFactory() = default;
}
@@ -27,6 +27,7 @@ namespace Catch {
struct SourceLineInfo;
class StartupExceptionRegistry;
class EventListenerFactory;
using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>;
@@ -45,7 +46,7 @@ namespace Catch {
struct IMutableRegistryHub {
virtual ~IMutableRegistryHub(); // = default
virtual void registerReporter( std::string const& name, IReporterFactoryPtr factory ) = 0;
virtual void registerListener( IReporterFactoryPtr factory ) = 0;
virtual void registerListener( Detail::unique_ptr<EventListenerFactory> factory ) = 0;
virtual void registerTest(Detail::unique_ptr<TestCaseInfo>&& testInfo, Detail::unique_ptr<ITestInvoker>&& invoker) = 0;
virtual void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) = 0;
virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0;
@@ -15,6 +15,7 @@
namespace Catch {
struct ReporterConfig;
struct IConfig;
class IEventListener;
using IStreamingReporterPtr = Detail::unique_ptr<IEventListener>;
@@ -27,6 +28,13 @@ namespace Catch {
virtual std::string getDescription() const = 0;
};
using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>;
class EventListenerFactory {
public:
virtual ~EventListenerFactory(); // = default
virtual IStreamingReporterPtr create( IConfig const* config ) const = 0;
virtual std::string getDescription() const = 0;
};
} // namespace Catch
#endif // CATCH_INTERFACES_REPORTER_FACTORY_HPP_INCLUDED
@@ -24,10 +24,11 @@ namespace Catch {
struct IReporterFactory;
using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>;
struct ReporterConfig;
class EventListenerFactory;
struct IReporterRegistry {
using FactoryMap = std::map<std::string, IReporterFactoryPtr, Detail::CaseInsensitiveLess>;
using Listeners = std::vector<IReporterFactoryPtr>;
using Listeners = std::vector<Detail::unique_ptr<EventListenerFactory>>;
virtual ~IReporterRegistry(); // = default
virtual IStreamingReporterPtr create( std::string const& name, ReporterConfig const& config ) const = 0;