mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-25 23:06:10 +01:00
Only Hub #includes report_registry. Seperated reporter registrars from registry.
This commit is contained in:
parent
764229ac4e
commit
18e32b9b9f
@ -13,7 +13,8 @@
|
||||
#define TWOBLUECUBES_CATCH_REPORTER_BASIC_HPP_INCLUDED
|
||||
|
||||
#include "internal/catch_capture.hpp"
|
||||
#include "internal/catch_reporter_registry.hpp"
|
||||
#include "internal/catch_interfaces_reporter.h"
|
||||
#include "internal/catch_reporter_registrars.hpp"
|
||||
|
||||
namespace Catch
|
||||
{
|
||||
|
@ -13,7 +13,8 @@
|
||||
#define TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED
|
||||
|
||||
#include "internal/catch_capture.hpp"
|
||||
#include "internal/catch_reporter_registry.hpp"
|
||||
#include "internal/catch_interfaces_reporter.h"
|
||||
#include "internal/catch_reporter_registrars.hpp"
|
||||
#include "internal/catch_xmlwriter.hpp"
|
||||
|
||||
namespace Catch
|
||||
|
@ -13,7 +13,8 @@
|
||||
#define TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED
|
||||
|
||||
#include "internal/catch_capture.hpp"
|
||||
#include "internal/catch_reporter_registry.hpp"
|
||||
#include "internal/catch_interfaces_reporter.h"
|
||||
#include "internal/catch_reporter_registrars.hpp"
|
||||
#include "internal/catch_xmlwriter.hpp"
|
||||
|
||||
namespace Catch
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* catch_ireporterregistry.h
|
||||
* catch_interfaces_reporter.h
|
||||
* Test
|
||||
*
|
||||
* Created by Phil on 31/12/2010.
|
58
internal/catch_reporter_registrars.hpp
Normal file
58
internal/catch_reporter_registrars.hpp
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* catch_reporter_registrars.hpp
|
||||
* Test
|
||||
*
|
||||
* 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_hub.hpp"
|
||||
|
||||
namespace Catch
|
||||
{
|
||||
template<typename T>
|
||||
class ReporterRegistrar
|
||||
{
|
||||
class ReporterFactory : public IReporterFactory
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////
|
||||
virtual IReporter* create
|
||||
(
|
||||
const IReporterConfig& config
|
||||
)
|
||||
const
|
||||
{
|
||||
return new T( config );
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////
|
||||
virtual std::string getDescription
|
||||
()
|
||||
const
|
||||
{
|
||||
return T::getDescription();
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
ReporterRegistrar
|
||||
(
|
||||
const std::string& name
|
||||
)
|
||||
{
|
||||
Hub::getReporterRegistry().registerReporter( name, new ReporterFactory() );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#define CATCH_REGISTER_REPORTER( name, reporterType ) \
|
||||
Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name );
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|
@ -12,18 +12,19 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_REPORTER_REGISTRY_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_REPORTER_REGISTRY_HPP_INCLUDED
|
||||
|
||||
#include "catch_ireporterregistry.h"
|
||||
#include "catch_interfaces_reporter.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace Catch
|
||||
{
|
||||
|
||||
class ReporterRegistry : public IReporterRegistry
|
||||
{
|
||||
public:
|
||||
|
||||
~ReporterRegistry()
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
~ReporterRegistry
|
||||
()
|
||||
{
|
||||
FactoryMap::const_iterator it = m_factories.begin();
|
||||
FactoryMap::const_iterator itEnd = m_factories.end();
|
||||
@ -33,7 +34,13 @@ namespace Catch
|
||||
}
|
||||
}
|
||||
|
||||
virtual IReporter* create( const std::string& name, const IReporterConfig& config ) const
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
virtual IReporter* create
|
||||
(
|
||||
const std::string& name,
|
||||
const IReporterConfig& config
|
||||
)
|
||||
const
|
||||
{
|
||||
FactoryMap::const_iterator it = m_factories.find( name );
|
||||
if( it == m_factories.end() )
|
||||
@ -41,12 +48,20 @@ namespace Catch
|
||||
return it->second->create( config );
|
||||
}
|
||||
|
||||
void registerReporter( const std::string& name, IReporterFactory* factory )
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
void registerReporter
|
||||
(
|
||||
const std::string& name,
|
||||
IReporterFactory* factory
|
||||
)
|
||||
{
|
||||
m_factories.insert( std::make_pair( name, factory ) );
|
||||
}
|
||||
|
||||
const FactoryMap& getFactories() const
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
const FactoryMap& getFactories
|
||||
()
|
||||
const
|
||||
{
|
||||
return m_factories;
|
||||
}
|
||||
@ -54,30 +69,6 @@ namespace Catch
|
||||
private:
|
||||
FactoryMap m_factories;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class ReporterFactory : public IReporterFactory
|
||||
{
|
||||
virtual IReporter* create( const IReporterConfig& config ) const
|
||||
{
|
||||
return new T( config );
|
||||
}
|
||||
virtual std::string getDescription() const
|
||||
{
|
||||
return T::getDescription();
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct ReporterRegistrar
|
||||
{
|
||||
ReporterRegistrar( const std::string& name )
|
||||
{
|
||||
Hub::getReporterRegistry().registerReporter( name, new ReporterFactory<T>() );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#define CATCH_REGISTER_REPORTER( name, reporterType ) Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name );
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRY_HPP_INCLUDED
|
@ -12,7 +12,7 @@
|
||||
#ifndef TWOBLUECUBES_INTERNAL_CATCH_RUNNER_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_INTERNAL_CATCH_RUNNER_HPP_INCLUDED
|
||||
|
||||
#include "catch_reporter_registry.hpp"
|
||||
#include "catch_interfaces_reporter.h"
|
||||
#include "catch_runnerconfig.hpp"
|
||||
#include "catch_registry.hpp"
|
||||
#include "catch_capture.hpp"
|
||||
|
@ -13,7 +13,7 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_RUNNERCONFIG_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_RUNNERCONFIG_HPP_INCLUDED
|
||||
|
||||
#include "catch_reporter_registry.hpp"
|
||||
#include "catch_interfaces_reporter.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
Loading…
Reference in New Issue
Block a user