Final refactoring to remove direct access to encapsulated ConfigData once in Config

This commit is contained in:
Phil Nash 2013-05-28 19:07:29 +01:00
parent 43fe6c6e9e
commit 6b8837bd93
2 changed files with 14 additions and 12 deletions

View File

@ -33,7 +33,7 @@ namespace Catch {
Totals runTests() { Totals runTests() {
std::vector<TestCaseFilters> filterGroups = m_config->data().filters; std::vector<TestCaseFilters> filterGroups = m_config->filters();
if( filterGroups.empty() ) { if( filterGroups.empty() ) {
TestCaseFilters filterGroup( "" ); TestCaseFilters filterGroup( "" );
filterGroups.push_back( filterGroup ); filterGroups.push_back( filterGroup );
@ -76,8 +76,8 @@ namespace Catch {
private: private:
void openStream() { void openStream() {
if( !m_config->data().stream.empty() ) if( !m_config->getStreamName().empty() )
m_config->useStream( m_config->data().stream ); m_config->useStream( m_config->getStreamName() );
// Open output file, if specified // Open output file, if specified
if( !m_config->getFilename().empty() ) { if( !m_config->getFilename().empty() ) {
@ -91,9 +91,9 @@ namespace Catch {
} }
} }
void makeReporter() { void makeReporter() {
std::string reporterName = m_config->data().reporter.empty() std::string reporterName = m_config->getReporterName().empty()
? "console" ? "console"
: m_config->data().reporter; : m_config->getReporterName();
m_reporter = getRegistryHub().getReporterRegistry().create( reporterName, m_config.get() ); m_reporter = getRegistryHub().getReporterRegistry().create( reporterName, m_config.get() );
if( !m_reporter ) { if( !m_reporter ) {

View File

@ -88,7 +88,8 @@ namespace Catch {
Config( ConfigData const& data ) Config( ConfigData const& data )
: m_data( data ), : m_data( data ),
m_os( std::cout.rdbuf() ) m_os( std::cout.rdbuf() ),
m_filters( data.filters )
{} {}
virtual ~Config() { virtual ~Config() {
@ -134,6 +135,10 @@ namespace Catch {
m_stream.release(); m_stream.release();
m_stream = stream; m_stream = stream;
} }
std::string getStreamName() const { return m_data.stream; }
std::string getReporterName() const { return m_data.reporter; }
void addTestSpec( std::string const& testSpec ) { void addTestSpec( std::string const& testSpec ) {
TestCaseFilters filters( testSpec ); TestCaseFilters filters( testSpec );
@ -145,11 +150,8 @@ namespace Catch {
return m_data.cutoff; return m_data.cutoff;
} }
ConfigData const& data() const { std::vector<TestCaseFilters> const& filters() const {
return m_data; return m_filters;
}
ConfigData& data() {
return m_data;
} }
// IConfig interface // IConfig interface
@ -162,9 +164,9 @@ namespace Catch {
private: private:
ConfigData m_data; ConfigData m_data;
// !TBD Move these out of here
Stream m_stream; Stream m_stream;
mutable std::ostream m_os; mutable std::ostream m_os;
std::vector<TestCaseFilters> m_filters;
}; };