diff options
| author | Martin Hořeňovský | 2020-01-25 15:32:56 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2020-01-25 17:41:38 +0100 |
| commit | df2379218b634e0c1b21b49ea56354a2102d4cd1 (patch) | |
| tree | 6bc3a1184eed8325a6855bf5788f5c195e079c21 /src/catch2 | |
| parent | 7134ad9913a1bc206726b9f1c057e1e625a08c27 (diff) | |
| download | catch3-df2379218b634e0c1b21b49ea56354a2102d4cd1.tar.gz | |
Reduce the use of shared_ptrs for various Config objects
Ideally they would not be used at all, but the main config lifetime
is a weird mess right now and will require further refactoring.
Diffstat (limited to 'src/catch2')
| -rw-r--r-- | src/catch2/catch_interfaces_config.h | 2 | ||||
| -rw-r--r-- | src/catch2/catch_interfaces_reporter.cpp | 6 | ||||
| -rw-r--r-- | src/catch2/catch_interfaces_reporter.h | 10 | ||||
| -rw-r--r-- | src/catch2/catch_reporter_registry.cpp | 2 | ||||
| -rw-r--r-- | src/catch2/catch_reporter_registry.h | 2 | ||||
| -rw-r--r-- | src/catch2/catch_session.cpp | 6 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_bases.hpp | 4 |
7 files changed, 16 insertions, 16 deletions
diff --git a/src/catch2/catch_interfaces_config.h b/src/catch2/catch_interfaces_config.h index 3122a48b..1ef601fe 100644 --- a/src/catch2/catch_interfaces_config.h +++ b/src/catch2/catch_interfaces_config.h @@ -51,7 +51,7 @@ namespace Catch { BeforeExit = 2, BeforeStartAndExit = BeforeStart | BeforeExit }; }; - + class TestSpec; struct IConfig : NonCopyable { diff --git a/src/catch2/catch_interfaces_reporter.cpp b/src/catch2/catch_interfaces_reporter.cpp index 815ffeb7..1986b806 100644 --- a/src/catch2/catch_interfaces_reporter.cpp +++ b/src/catch2/catch_interfaces_reporter.cpp @@ -16,14 +16,14 @@ namespace Catch { - ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig ) + ReporterConfig::ReporterConfig( IConfig const* _fullConfig ) : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {} - ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream ) + ReporterConfig::ReporterConfig( IConfig const* _fullConfig, std::ostream& _stream ) : m_stream( &_stream ), m_fullConfig( _fullConfig ) {} std::ostream& ReporterConfig::stream() const { return *m_stream; } - IConfigPtr ReporterConfig::fullConfig() const { return m_fullConfig; } + IConfig const * ReporterConfig::fullConfig() const { return m_fullConfig; } TestRunInfo::TestRunInfo( std::string const& _name ) : name( _name ) {} diff --git a/src/catch2/catch_interfaces_reporter.h b/src/catch2/catch_interfaces_reporter.h index 97ce8ea0..95b4406b 100644 --- a/src/catch2/catch_interfaces_reporter.h +++ b/src/catch2/catch_interfaces_reporter.h @@ -37,16 +37,16 @@ namespace Catch { struct TagInfo; struct ReporterConfig { - explicit ReporterConfig( IConfigPtr const& _fullConfig ); + explicit ReporterConfig( IConfig const* _fullConfig ); - ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream ); + ReporterConfig( IConfig const* _fullConfig, std::ostream& _stream ); std::ostream& stream() const; - IConfigPtr fullConfig() const; + IConfig const* fullConfig() const; private: std::ostream* m_stream; - IConfigPtr m_fullConfig; + IConfig const* m_fullConfig; }; struct ReporterPreferences { @@ -268,7 +268,7 @@ namespace Catch { using Listeners = std::vector<IReporterFactoryPtr>; virtual ~IReporterRegistry(); - virtual IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const = 0; + virtual IStreamingReporterPtr create( std::string const& name, IConfig const* config ) const = 0; virtual FactoryMap const& getFactories() const = 0; virtual Listeners const& getListeners() const = 0; }; diff --git a/src/catch2/catch_reporter_registry.cpp b/src/catch2/catch_reporter_registry.cpp index beb8411e..58ef5f4d 100644 --- a/src/catch2/catch_reporter_registry.cpp +++ b/src/catch2/catch_reporter_registry.cpp @@ -34,7 +34,7 @@ namespace Catch { ReporterRegistry::~ReporterRegistry() = default; - IStreamingReporterPtr ReporterRegistry::create( std::string const& name, IConfigPtr const& config ) const { + IStreamingReporterPtr ReporterRegistry::create( std::string const& name, IConfig const* config ) const { auto it = m_factories.find( name ); if( it == m_factories.end() ) return nullptr; diff --git a/src/catch2/catch_reporter_registry.h b/src/catch2/catch_reporter_registry.h index 456b76f8..e885b0c3 100644 --- a/src/catch2/catch_reporter_registry.h +++ b/src/catch2/catch_reporter_registry.h @@ -20,7 +20,7 @@ namespace Catch { ReporterRegistry(); ~ReporterRegistry() override; // = default, out of line to allow fwd decl - IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const override; + IStreamingReporterPtr create( std::string const& name, IConfig const* config ) const override; void registerReporter( std::string const& name, IReporterFactoryPtr factory ); void registerListener( IReporterFactoryPtr factory ); diff --git a/src/catch2/catch_session.cpp b/src/catch2/catch_session.cpp index f086fb22..fd3e4f62 100644 --- a/src/catch2/catch_session.cpp +++ b/src/catch2/catch_session.cpp @@ -33,14 +33,14 @@ namespace Catch { namespace { const int MaxExitCode = 255; - IStreamingReporterPtr createReporter(std::string const& reporterName, IConfigPtr const& config) { + IStreamingReporterPtr createReporter(std::string const& reporterName, IConfig const* config) { auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, config); CATCH_ENFORCE(reporter, "No reporter registered with name: '" << reporterName << "'"); return reporter; } - IStreamingReporterPtr makeReporter(std::shared_ptr<Config> const& config) { + IStreamingReporterPtr makeReporter(Config const* config) { if (Catch::getRegistryHub().getReporterRegistry().getListeners().empty()) { return createReporter(config->getReporterName(), config); } @@ -273,7 +273,7 @@ namespace Catch { } // Create reporter(s) so we can route listings through them - auto reporter = makeReporter(m_config); + auto reporter = makeReporter(m_config.get()); // Handle list request if (list(*reporter, m_config)) { diff --git a/src/catch2/reporters/catch_reporter_bases.hpp b/src/catch2/reporters/catch_reporter_bases.hpp index 0fbcfe4c..909b819b 100644 --- a/src/catch2/reporters/catch_reporter_bases.hpp +++ b/src/catch2/reporters/catch_reporter_bases.hpp @@ -81,7 +81,7 @@ namespace Catch { // It can optionally be overridden in the derived class. } - IConfigPtr m_config; + IConfig const* m_config; std::ostream& stream; LazyStat<TestRunInfo> currentTestRunInfo; @@ -227,7 +227,7 @@ namespace Catch { void skipTest(TestCaseInfo const&) override {} - IConfigPtr m_config; + IConfig const* m_config; std::ostream& stream; std::vector<AssertionStats> m_assertions; std::vector<std::vector<std::shared_ptr<SectionNode>>> m_sections; |