Migrated Config and IConfig to shared_ptr (from Ptr)

This commit is contained in:
Phil Nash
2017-04-25 20:18:02 +01:00
parent 41afd0c3d4
commit 338ba6b9ba
10 changed files with 32 additions and 32 deletions

View File

@@ -56,10 +56,7 @@ namespace Catch {
};
class Config : public SharedImpl<IConfig> {
private:
Config( Config const& other );
Config& operator = ( Config const& other );
class Config : public IConfig {
virtual void dummy();
public:

View File

@@ -89,7 +89,7 @@ namespace {
IColourImpl* platformColourInstance() {
static Win32ColourImpl s_instance;
Ptr<IConfig const> config = getCurrentContext().getConfig();
IConfigPtr config = getCurrentContext().getConfig();
UseColour::YesOrNo colourMode = config
? config->useColour()
: UseColour::Auto;
@@ -150,7 +150,7 @@ namespace {
IColourImpl* platformColourInstance() {
ErrnoGuard guard;
Ptr<IConfig const> config = getCurrentContext().getConfig();
IConfigPtr config = getCurrentContext().getConfig();
UseColour::YesOrNo colourMode = config
? config->useColour()
: UseColour::Auto;

View File

@@ -21,6 +21,8 @@ namespace Catch {
struct IGeneratorsForTest;
struct IConfig;
using IConfigPtr = std::shared_ptr<IConfig const>;
struct IContext
{
virtual ~IContext();
@@ -29,7 +31,7 @@ namespace Catch {
virtual IRunner* getRunner() = 0;
virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0;
virtual bool advanceGeneratorsForCurrentTest() = 0;
virtual Ptr<IConfig const> getConfig() const = 0;
virtual IConfigPtr getConfig() const = 0;
};
struct IMutableContext : IContext
@@ -37,7 +39,7 @@ namespace Catch {
virtual ~IMutableContext();
virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
virtual void setRunner( IRunner* runner ) = 0;
virtual void setConfig( Ptr<IConfig const> const& config ) = 0;
virtual void setConfig( IConfigPtr const& config ) = 0;
};
IContext& getCurrentContext();

View File

@@ -40,7 +40,7 @@ namespace Catch {
return generators && generators->moveNext();
}
virtual Ptr<IConfig const> getConfig() const {
virtual IConfigPtr getConfig() const {
return m_config;
}
@@ -51,7 +51,7 @@ namespace Catch {
virtual void setRunner( IRunner* runner ) {
m_runner = runner;
}
virtual void setConfig( Ptr<IConfig const> const& config ) {
virtual void setConfig( IConfigPtr const& config ) {
m_config = config;
}
@@ -79,7 +79,7 @@ namespace Catch {
}
private:
Ptr<IConfig const> m_config;
IConfigPtr m_config;
IRunner* m_runner = nullptr;
IResultCapture* m_resultCapture = nullptr;
std::map<std::string, IGeneratorsForTest*> m_generatorsByTestName;

View File

@@ -45,7 +45,7 @@ namespace Catch {
class TestSpec;
struct IConfig : IShared {
struct IConfig : NonCopyable {
virtual ~IConfig();
@@ -63,8 +63,9 @@ namespace Catch {
virtual unsigned int rngSeed() const = 0;
virtual UseColour::YesOrNo useColour() const = 0;
virtual std::vector<std::string> const& getSectionsToRun() const = 0;
};
using IConfigPtr = std::shared_ptr<IConfig const>;
}
#endif // TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED

View File

@@ -25,18 +25,18 @@
namespace Catch
{
struct ReporterConfig {
explicit ReporterConfig( Ptr<IConfig const> const& _fullConfig )
explicit ReporterConfig( IConfigPtr const& _fullConfig )
: m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {}
ReporterConfig( Ptr<IConfig const> const& _fullConfig, std::ostream& _stream )
ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream )
: m_stream( &_stream ), m_fullConfig( _fullConfig ) {}
std::ostream& stream() const { return *m_stream; }
Ptr<IConfig const> fullConfig() const { return m_fullConfig; }
IConfigPtr fullConfig() const { return m_fullConfig; }
private:
std::ostream* m_stream;
Ptr<IConfig const> m_fullConfig;
IConfigPtr m_fullConfig;
};
struct ReporterPreferences {
@@ -247,7 +247,7 @@ namespace Catch
typedef std::vector<Ptr<IReporterFactory> > Listeners;
virtual ~IReporterRegistry();
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig const> const& config ) const = 0;
virtual IStreamingReporter* create( std::string const& name, IConfigPtr const& config ) const = 0;
virtual FactoryMap const& getFactories() const = 0;
virtual Listeners const& getListeners() const = 0;
};

View File

@@ -20,7 +20,7 @@ namespace Catch {
virtual ~ReporterRegistry() override {}
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig const> const& config ) const override {
virtual IStreamingReporter* create( std::string const& name, IConfigPtr const& config ) const override {
FactoryMap::const_iterator it = m_factories.find( name );
if( it == m_factories.end() )
return nullptr;

View File

@@ -59,7 +59,7 @@ namespace Catch {
public:
explicit RunContext( Ptr<IConfig const> const& _config, Ptr<IStreamingReporter> const& reporter )
explicit RunContext( IConfigPtr const& _config, Ptr<IStreamingReporter> const& reporter )
: m_runInfo( _config->name() ),
m_context( getCurrentMutableContext() ),
m_config( _config ),
@@ -128,7 +128,7 @@ namespace Catch {
return deltaTotals;
}
Ptr<IConfig const> config() const {
IConfigPtr config() const {
return m_config;
}
@@ -353,7 +353,7 @@ namespace Catch {
ITracker* m_currentSectionTracker;
AssertionResult m_lastResult;
Ptr<IConfig const> m_config;
IConfigPtr m_config;
Totals m_totals;
Ptr<IStreamingReporter> m_reporter;
std::vector<MessageInfo> m_messages;