Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/interfaces
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-03-14 15:04:42 +0100
committerMartin Hořeňovský2022-03-18 00:36:18 +0100
commit4acc520f763f7a104d11d57afb8d3bab0bfa6ebc (patch)
tree4bcbf287b1db41c6d8608905ca82471545517992 /src/catch2/interfaces
parent18c58667d780bfdc82d0e52d6ac6afc462e28f47 (diff)
downloadcatch3-4acc520f763f7a104d11d57afb8d3bab0bfa6ebc.tar.gz
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.
Diffstat (limited to 'src/catch2/interfaces')
-rw-r--r--src/catch2/interfaces/catch_interfaces_combined_tu.cpp1
-rw-r--r--src/catch2/interfaces/catch_interfaces_registry_hub.hpp3
-rw-r--r--src/catch2/interfaces/catch_interfaces_reporter_factory.hpp8
-rw-r--r--src/catch2/interfaces/catch_interfaces_reporter_registry.hpp3
4 files changed, 13 insertions, 2 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_combined_tu.cpp b/src/catch2/interfaces/catch_interfaces_combined_tu.cpp
index b1ce0928..2e126a46 100644
--- a/src/catch2/interfaces/catch_interfaces_combined_tu.cpp
+++ b/src/catch2/interfaces/catch_interfaces_combined_tu.cpp
@@ -86,4 +86,5 @@ namespace Catch {
namespace Catch {
IReporterFactory::~IReporterFactory() = default;
+ EventListenerFactory::~EventListenerFactory() = default;
}
diff --git a/src/catch2/interfaces/catch_interfaces_registry_hub.hpp b/src/catch2/interfaces/catch_interfaces_registry_hub.hpp
index aeefeedb..1c40f2de 100644
--- a/src/catch2/interfaces/catch_interfaces_registry_hub.hpp
+++ b/src/catch2/interfaces/catch_interfaces_registry_hub.hpp
@@ -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;
diff --git a/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp b/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp
index eb107c20..0f9b90cd 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp
@@ -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
diff --git a/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp b/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp
index 904ffd03..7a7b275d 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp
@@ -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;