catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Migrated IReporterFactory to std::shared_ptr
- Commit
dd78824697ec42e87b5623f0fb99200d7c83c4b4- Author
- Phil Nash ·
- Parents
338ba6b9baa4
Changes
include/internal/catch_interfaces_registry_hub.h | 6 ++++-- include/internal/catch_interfaces_reporter.h | 7 ++++--- include/internal/catch_registry_hub.hpp | 4 ++-- include/internal/catch_reporter_registrars.hpp | 8 ++++---- include/internal/catch_reporter_registry.hpp | 4 ++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/include/internal/catch_interfaces_registry_hub.h b/include/internal/catch_interfaces_registry_hub.h index 5e0a7f01..9a42fbad 100644 --- a/include/internal/catch_interfaces_registry_hub.h +++ b/include/internal/catch_interfaces_registry_hub.h @@ -22,6 +22,8 @@ namespace Catch { struct IReporterFactory; struct ITagAliasRegistry; + using IReporterFactoryPtr = std::shared_ptr<IReporterFactory>; + struct IRegistryHub { virtual ~IRegistryHub(); @@ -34,8 +36,8 @@ namespace Catch { struct IMutableRegistryHub { virtual ~IMutableRegistryHub(); - virtual void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) = 0; - virtual void registerListener( Ptr<IReporterFactory> const& factory ) = 0; + virtual void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) = 0; + virtual void registerListener( IReporterFactoryPtr const& factory ) = 0; virtual void registerTest( TestCase const& testInfo ) = 0; virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0; diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index 07524b93..6a38528b 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -236,15 +236,16 @@ namespace Catch }; - struct IReporterFactory : IShared { + struct IReporterFactory { virtual ~IReporterFactory(); virtual IStreamingReporter* create( ReporterConfig const& config ) const = 0; virtual std::string getDescription() const = 0; }; + using IReporterFactoryPtr = std::shared_ptr<IReporterFactory>; struct IReporterRegistry { - typedef std::map<std::string, Ptr<IReporterFactory> > FactoryMap; - typedef std::vector<Ptr<IReporterFactory> > Listeners; + using FactoryMap = std::map<std::string, IReporterFactoryPtr>; + using Listeners = std::vector<IReporterFactoryPtr>; virtual ~IReporterRegistry(); virtual IStreamingReporter* create( std::string const& name, IConfigPtr const& config ) const = 0; diff --git a/include/internal/catch_registry_hub.hpp b/include/internal/catch_registry_hub.hpp index b9e42b72..d51306fd 100644 --- a/include/internal/catch_registry_hub.hpp +++ b/include/internal/catch_registry_hub.hpp @@ -42,10 +42,10 @@ namespace Catch { public: // IMutableRegistryHub - virtual void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) override { + virtual void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) override { m_reporterRegistry.registerReporter( name, factory ); } - virtual void registerListener( Ptr<IReporterFactory> const& factory ) override { + virtual void registerListener( IReporterFactoryPtr const& factory ) override { m_reporterRegistry.registerListener( factory ); } virtual void registerTest( TestCase const& testInfo ) override { diff --git a/include/internal/catch_reporter_registrars.hpp b/include/internal/catch_reporter_registrars.hpp index b12bbc6b..086c5df2 100644 --- a/include/internal/catch_reporter_registrars.hpp +++ b/include/internal/catch_reporter_registrars.hpp @@ -15,7 +15,7 @@ namespace Catch { template<typename T> class ReporterRegistrar { - class ReporterFactory : public SharedImpl<IReporterFactory> { + class ReporterFactory : public IReporterFactory { virtual IStreamingReporter* create( ReporterConfig const& config ) const { return new T( config ); @@ -29,14 +29,14 @@ namespace Catch { public: ReporterRegistrar( std::string const& name ) { - getMutableRegistryHub().registerReporter( name, new ReporterFactory() ); + getMutableRegistryHub().registerReporter( name, std::make_shared<ReporterFactory>() ); } }; template<typename T> class ListenerRegistrar { - class ListenerFactory : public SharedImpl<IReporterFactory> { + class ListenerFactory : public IReporterFactory { virtual IStreamingReporter* create( ReporterConfig const& config ) const { return new T( config ); @@ -49,7 +49,7 @@ namespace Catch { public: ListenerRegistrar() { - getMutableRegistryHub().registerListener( new ListenerFactory() ); + getMutableRegistryHub().registerListener( std::make_shared<ListenerFactory>() ); } }; } diff --git a/include/internal/catch_reporter_registry.hpp b/include/internal/catch_reporter_registry.hpp index ad212437..3d503321 100644 --- a/include/internal/catch_reporter_registry.hpp +++ b/include/internal/catch_reporter_registry.hpp @@ -27,10 +27,10 @@ namespace Catch { return it->second->create( ReporterConfig( config ) ); } - void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) { + void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) { m_factories.insert( std::make_pair( name, factory ) ); } - void registerListener( Ptr<IReporterFactory> const& factory ) { + void registerListener( IReporterFactoryPtr const& factory ) { m_listeners.push_back( factory ); }