catch2/include/internal/catch_reporter_registrars.hpp

41 lines
1.2 KiB
C++
Raw Normal View History

/*
* 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
#include "catch_context.h"
2012-05-16 09:02:20 +02:00
namespace Catch {
template<typename T>
2012-05-16 09:02:20 +02:00
class ReporterRegistrar {
class ReporterFactory : public IReporterFactory {
2012-07-20 20:07:42 +02:00
virtual IReporter* create( const ReporterConfig& config ) const {
return new T( config );
}
2012-05-16 09:02:20 +02:00
virtual std::string getDescription() const {
return T::getDescription();
}
};
2012-05-16 09:02:20 +02:00
public:
2012-05-16 09:02:20 +02:00
ReporterRegistrar( const std::string& name ) {
getCurrentContext().getReporterRegistry().registerReporter( name, new ReporterFactory() );
}
};
}
#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name );
#endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED