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