Made ReportConfig a value type

This commit is contained in:
Phil Nash
2012-07-20 19:07:42 +01:00
parent f606517376
commit d2553cdc64
10 changed files with 156 additions and 134 deletions

View File

@@ -60,7 +60,7 @@ namespace Catch {
};
class Config : public IReporterConfig, public IConfig {
class Config : public IConfig {
private:
Config( const Config& other );
Config& operator = ( const Config& other );

View File

@@ -18,12 +18,20 @@
namespace Catch
{
struct IReporterConfig {
virtual ~IReporterConfig() {}
virtual std::ostream& stream () const = 0;
virtual bool includeSuccessfulResults () const = 0;
virtual std::string getName () const = 0;
};
struct ReporterConfig
{
ReporterConfig( const std::string& _name,
std::ostream& _stream,
bool _includeSuccessfulResults = false )
: name( _name ),
stream( _stream ),
includeSuccessfulResults( _includeSuccessfulResults )
{}
std::string name;
std::ostream& stream;
bool includeSuccessfulResults;
};
class TestCaseInfo;
class ResultInfo;
@@ -45,7 +53,7 @@ namespace Catch
struct IReporterFactory {
virtual ~IReporterFactory() {}
virtual IReporter* create( const IReporterConfig& config ) const = 0;
virtual IReporter* create( const ReporterConfig& config ) const = 0;
virtual std::string getDescription() const = 0;
};
@@ -53,7 +61,7 @@ namespace Catch
typedef std::map<std::string, IReporterFactory*> FactoryMap;
virtual ~IReporterRegistry() {}
virtual IReporter* create( const std::string& name, const IReporterConfig& config ) const = 0;
virtual IReporter* create( const std::string& name, const ReporterConfig& config ) const = 0;
virtual void registerReporter( const std::string& name, IReporterFactory* factory ) = 0;
virtual const FactoryMap& getFactories() const = 0;
};

View File

@@ -17,7 +17,7 @@ namespace Catch {
class ReporterFactory : public IReporterFactory {
virtual IReporter* create( const IReporterConfig& config ) const {
virtual IReporter* create( const ReporterConfig& config ) const {
return new T( config );
}

View File

@@ -22,7 +22,7 @@ namespace Catch {
deleteAllValues( m_factories );
}
virtual IReporter* create( const std::string& name, const IReporterConfig& config ) const {
virtual IReporter* create( const std::string& name, const ReporterConfig& config ) const {
FactoryMap::const_iterator it = m_factories.find( name );
if( it == m_factories.end() )
return NULL;