1 /* 2 * Created by Phil on 29/10/2010. 3 * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. 4 * 5 * Distributed under the Boost Software License, Version 1.0. (See accompanying 6 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 */ 8 #ifndef TWOBLUECUBES_CATCH_REPORTER_REGISTRY_HPP_INCLUDED 9 #define TWOBLUECUBES_CATCH_REPORTER_REGISTRY_HPP_INCLUDED 10 11 #include "catch_interfaces_reporter.h" 12 13 #include <map> 14 15 namespace Catch { 16 17 class ReporterRegistry : public IReporterRegistry { 18 19 public: 20 ~ReporterRegistry()21 virtual ~ReporterRegistry() CATCH_OVERRIDE {} 22 create(std::string const & name,Ptr<IConfig const> const & config) const23 virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig const> const& config ) const CATCH_OVERRIDE { 24 FactoryMap::const_iterator it = m_factories.find( name ); 25 if( it == m_factories.end() ) 26 return CATCH_NULL; 27 return it->second->create( ReporterConfig( config ) ); 28 } 29 registerReporter(std::string const & name,Ptr<IReporterFactory> const & factory)30 void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) { 31 m_factories.insert( std::make_pair( name, factory ) ); 32 } registerListener(Ptr<IReporterFactory> const & factory)33 void registerListener( Ptr<IReporterFactory> const& factory ) { 34 m_listeners.push_back( factory ); 35 } 36 getFactories() const37 virtual FactoryMap const& getFactories() const CATCH_OVERRIDE { 38 return m_factories; 39 } getListeners() const40 virtual Listeners const& getListeners() const CATCH_OVERRIDE { 41 return m_listeners; 42 } 43 44 private: 45 FactoryMap m_factories; 46 Listeners m_listeners; 47 }; 48 } 49 50 #endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRY_HPP_INCLUDED 51