2010-12-31 17:46:51 -05:00
|
|
|
/*
|
|
|
|
* Created by Phil on 31/12/2010.
|
|
|
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
|
|
|
*
|
|
|
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
*/
|
|
|
|
#ifndef TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|
|
|
|
|
2012-05-10 02:58:48 -04:00
|
|
|
#include "catch_context.h"
|
2010-12-31 17:46:51 -05:00
|
|
|
|
2012-05-16 03:02:20 -04:00
|
|
|
namespace Catch {
|
|
|
|
|
2010-12-31 17:46:51 -05:00
|
|
|
template<typename T>
|
2012-05-16 03:02:20 -04:00
|
|
|
class ReporterRegistrar {
|
|
|
|
|
|
|
|
class ReporterFactory : public IReporterFactory {
|
|
|
|
|
|
|
|
virtual IReporter* create( const IReporterConfig& config ) const {
|
2010-12-31 17:46:51 -05:00
|
|
|
return new T( config );
|
|
|
|
}
|
2012-05-16 03:02:20 -04:00
|
|
|
|
|
|
|
virtual std::string getDescription() const {
|
2010-12-31 17:46:51 -05:00
|
|
|
return T::getDescription();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-05-16 03:02:20 -04:00
|
|
|
public:
|
2010-12-31 17:46:51 -05:00
|
|
|
|
2012-05-16 03:02:20 -04:00
|
|
|
ReporterRegistrar( const std::string& name ) {
|
2012-05-21 13:52:09 -04:00
|
|
|
getCurrentContext().getReporterRegistry().registerReporter( name, new ReporterFactory() );
|
2010-12-31 17:46:51 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2011-01-27 17:29:36 -05:00
|
|
|
#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
|
2010-12-31 17:46:51 -05:00
|
|
|
Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name );
|
|
|
|
|
|
|
|
#endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|