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> resultingReporter;
if( !existingReporter )
return additionalReporter;
if( existingReporter ) {
if( !existingReporter->supportsChainedReporters() ) {
MultipleReporters* multi = new MultipleReporters;
resultingReporter = Ptr<IStreamingReporter>( multi );
if( existingReporter )
multi->addChainedReporter( existingReporter );
}
else
resultingReporter = existingReporter;
resultingReporter->addChainedReporter( additionalReporter );
if( existingReporter->supportsChainedReporters() ) {
existingReporter->addChainedReporter( additionalReporter );
return existingReporter;
}
else
resultingReporter = additionalReporter;
return resultingReporter;
Ptr<MultipleReporters> multi = Ptr<MultipleReporters>( new MultipleReporters );
multi->addChainedReporter( existingReporter );
multi->addChainedReporter( additionalReporter );
return Ptr<IStreamingReporter>( multi.get() );
}