refactor: Clean up addReporter()

This commit is contained in:
Eirik Byrkjeflot Anonsen 2016-04-04 19:05:27 +02:00
parent 218d0bdcc7
commit 27373d4f2c

View File

@ -128,23 +128,18 @@ public: // IStreamingReporter
}; };
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) { Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
Ptr<IStreamingReporter> resultingReporter; if( !existingReporter )
return additionalReporter;
if( existingReporter ) { if( existingReporter->supportsChainedReporters() ) {
if( !existingReporter->supportsChainedReporters() ) { existingReporter->addChainedReporter( additionalReporter );
MultipleReporters* multi = new MultipleReporters; return existingReporter;
resultingReporter = Ptr<IStreamingReporter>( multi );
if( existingReporter )
multi->addChainedReporter( existingReporter );
}
else
resultingReporter = existingReporter;
resultingReporter->addChainedReporter( additionalReporter );
} }
else
resultingReporter = additionalReporter;
return resultingReporter; Ptr<MultipleReporters> multi = Ptr<MultipleReporters>( new MultipleReporters );
multi->addChainedReporter( existingReporter );
multi->addChainedReporter( additionalReporter );
return Ptr<IStreamingReporter>( multi.get() );
} }