2017-08-17 20:21:06 +02:00
|
|
|
|
2010-12-31 23:46:51 +01: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-08-07 08:58:34 +02:00
|
|
|
#include "catch_interfaces_registry_hub.h"
|
2010-12-31 23:46:51 +01:00
|
|
|
|
2013-07-03 20:14:59 +02:00
|
|
|
namespace Catch {
|
2012-05-16 09:02:20 +02:00
|
|
|
|
2012-11-30 20:15:23 +01:00
|
|
|
template<typename T>
|
|
|
|
class ReporterRegistrar {
|
|
|
|
|
2017-04-25 21:28:53 +02:00
|
|
|
class ReporterFactory : public IReporterFactory {
|
2012-11-30 20:15:23 +01:00
|
|
|
|
2017-07-25 17:16:28 +02:00
|
|
|
virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override {
|
2017-04-29 20:38:34 +02:00
|
|
|
return std::unique_ptr<T>( new T( config ) );
|
2012-11-30 20:15:23 +01:00
|
|
|
}
|
|
|
|
|
2017-07-25 17:16:28 +02:00
|
|
|
virtual std::string getDescription() const override {
|
2012-11-30 20:15:23 +01:00
|
|
|
return T::getDescription();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-05-16 09:02:20 +02:00
|
|
|
public:
|
2010-12-31 23:46:51 +01:00
|
|
|
|
2013-04-23 19:58:56 +02:00
|
|
|
ReporterRegistrar( std::string const& name ) {
|
2017-04-25 21:28:53 +02:00
|
|
|
getMutableRegistryHub().registerReporter( name, std::make_shared<ReporterFactory>() );
|
2010-12-31 23:46:51 +01:00
|
|
|
}
|
2013-07-03 20:14:59 +02:00
|
|
|
};
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2015-08-07 09:20:56 +02:00
|
|
|
template<typename T>
|
|
|
|
class ListenerRegistrar {
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2017-04-25 21:28:53 +02:00
|
|
|
class ListenerFactory : public IReporterFactory {
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2017-07-25 17:16:28 +02:00
|
|
|
virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override {
|
2017-08-17 20:21:06 +02:00
|
|
|
return std::unique_ptr<T>( new T( config ) );
|
2015-08-07 09:20:56 +02:00
|
|
|
}
|
2017-07-25 17:16:28 +02:00
|
|
|
virtual std::string getDescription() const override {
|
2017-01-15 09:41:33 +01:00
|
|
|
return std::string();
|
2015-08-07 09:20:56 +02:00
|
|
|
}
|
|
|
|
};
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2015-08-07 09:20:56 +02:00
|
|
|
public:
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2015-08-07 09:20:56 +02:00
|
|
|
ListenerRegistrar() {
|
2017-04-25 21:28:53 +02:00
|
|
|
getMutableRegistryHub().registerListener( std::make_shared<ListenerFactory>() );
|
2015-08-07 09:20:56 +02:00
|
|
|
}
|
|
|
|
};
|
2010-12-31 23:46:51 +01:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:07:24 +02:00
|
|
|
#define CATCH_REGISTER_REPORTER( name, reporterType ) \
|
2013-09-24 08:41:18 +02:00
|
|
|
namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
|
2010-12-31 23:46:51 +01:00
|
|
|
|
2017-03-10 20:15:03 +01:00
|
|
|
#define CATCH_REGISTER_LISTENER( listenerType ) \
|
|
|
|
namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; }
|
|
|
|
|
2010-12-31 23:46:51 +01:00
|
|
|
#endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|