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"
|
2013-04-08 12:44:03 +02:00
|
|
|
#include "catch_legacy_reporter_adapter.h"
|
2010-12-31 23:46:51 +01:00
|
|
|
|
2012-05-16 09:02:20 +02:00
|
|
|
namespace Catch {
|
|
|
|
|
2010-12-31 23:46:51 +01:00
|
|
|
template<typename T>
|
2012-11-30 20:15:23 +01:00
|
|
|
class LegacyReporterRegistrar {
|
2012-05-16 09:02:20 +02:00
|
|
|
|
|
|
|
class ReporterFactory : public IReporterFactory {
|
|
|
|
|
2013-04-23 19:58:56 +02:00
|
|
|
virtual IStreamingReporter* create( ReporterConfig const& config ) const {
|
2013-05-28 19:39:32 +02:00
|
|
|
return new LegacyReporterAdapter( new T( config ) );
|
2010-12-31 23:46:51 +01:00
|
|
|
}
|
2012-05-16 09:02:20 +02:00
|
|
|
|
|
|
|
virtual std::string getDescription() const {
|
2010-12-31 23:46:51 +01:00
|
|
|
return T::getDescription();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-11-30 20:15:23 +01:00
|
|
|
public:
|
|
|
|
|
2013-04-23 19:58:56 +02:00
|
|
|
LegacyReporterRegistrar( std::string const& name ) {
|
2012-11-30 20:15:23 +01:00
|
|
|
getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
class ReporterRegistrar {
|
|
|
|
|
|
|
|
class ReporterFactory : public IReporterFactory {
|
|
|
|
|
2012-11-30 20:29:03 +01:00
|
|
|
// *** Please Note ***:
|
|
|
|
// - If you end up here looking at a compiler error because it's trying to register
|
|
|
|
// your custom reporter class be aware that the native reporter interface has changed
|
|
|
|
// to IStreamingReporter. The "legacy" interface, IReporter, is still supported via
|
|
|
|
// an adapter. Just use REGISTER_LEGACY_REPORTER to take advantage of the adapter.
|
|
|
|
// However please consider updating to the new interface as the old one is now
|
|
|
|
// deprecated and will probably be removed quite soon!
|
|
|
|
// Please contact me via github if you have any questions at all about this.
|
|
|
|
// In fact, ideally, please contact me anyway to let me know you've hit this - as I have
|
|
|
|
// no idea who is actually using custom reporters at all (possibly no-one!).
|
|
|
|
// The new interface is designed to minimise exposure to interface changes in the future.
|
2013-04-23 19:58:56 +02:00
|
|
|
virtual IStreamingReporter* create( ReporterConfig const& config ) const {
|
2012-11-30 20:15:23 +01:00
|
|
|
return new T( config );
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string getDescription() const {
|
|
|
|
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 ) {
|
2012-08-07 08:58:34 +02:00
|
|
|
getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
|
2010-12-31 23:46:51 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2012-11-30 20:29:03 +01:00
|
|
|
#define INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) \
|
2012-11-30 20:15:23 +01:00
|
|
|
Catch::LegacyReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name );
|
2012-11-30 20:29:03 +01:00
|
|
|
#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
|
2010-12-31 23:46:51 +01:00
|
|
|
Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name );
|
|
|
|
|
|
|
|
#endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|