Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
catch_reporter_registrars.hpp
Go to the documentation of this file.
1
2/*
3 * Created by Phil on 31/12/2010.
4 * Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
5 *
6 * Distributed under the Boost Software License, Version 1.0. (See accompanying
7 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 */
9#ifndef TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
10#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
11
13
14namespace Catch {
15
16 template<typename T>
18
19 class ReporterFactory : public IReporterFactory {
20
21 IStreamingReporterPtr create( ReporterConfig const& config ) const override {
22 return std::unique_ptr<T>( new T( config ) );
23 }
24
25 std::string getDescription() const override {
26 return T::getDescription();
27 }
28 };
29
30 public:
31
32 explicit ReporterRegistrar( std::string const& name ) {
33 getMutableRegistryHub().registerReporter( name, std::make_shared<ReporterFactory>() );
34 }
35 };
36
37 template<typename T>
39
40 class ListenerFactory : public IReporterFactory {
41
42 IStreamingReporterPtr create( ReporterConfig const& config ) const override {
43 return std::unique_ptr<T>( new T( config ) );
44 }
45 std::string getDescription() const override {
46 return std::string();
47 }
48 };
49
50 public:
51
53 getMutableRegistryHub().registerListener( std::make_shared<ListenerFactory>() );
54 }
55 };
56}
57
58#if !defined(CATCH_CONFIG_DISABLE)
59
60#define CATCH_REGISTER_REPORTER( name, reporterType ) \
61 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
62 namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); } \
63 CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS
64
65#define CATCH_REGISTER_LISTENER( listenerType ) \
66 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
67 namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; } \
68 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS
69#else // CATCH_CONFIG_DISABLE
70
71#define CATCH_REGISTER_REPORTER(name, reporterType)
72#define CATCH_REGISTER_LISTENER(listenerType)
73
74#endif // CATCH_CONFIG_DISABLE
75
76#endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
std::string name
ReporterRegistrar(std::string const &name)
std::unique_ptr< IStreamingReporter > IStreamingReporterPtr
IMutableRegistryHub & getMutableRegistryHub()
#define T(meth, val, expected)
virtual void registerReporter(std::string const &name, IReporterFactoryPtr const &factory)=0
virtual void registerListener(IReporterFactoryPtr const &factory)=0