| 
									
										
										
										
											2012-08-06 20:16:53 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  *  Created by Phil on 5/8/2012. | 
					
						
							|  |  |  |  *  Copyright 2012 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)
 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-09-17 01:42:29 -04:00
										 |  |  | #ifndef TWOBLUECUBES_CATCH_REGISTRY_HUB_HPP_INCLUDED
 | 
					
						
							|  |  |  | #define TWOBLUECUBES_CATCH_REGISTRY_HUB_HPP_INCLUDED
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-07 07:58:34 +01:00
										 |  |  | #include "catch_interfaces_registry_hub.h"
 | 
					
						
							| 
									
										
										
										
											2012-08-06 08:33:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-06 20:16:53 +01:00
										 |  |  | #include "catch_test_case_registry_impl.hpp"
 | 
					
						
							|  |  |  | #include "catch_reporter_registry.hpp"
 | 
					
						
							|  |  |  | #include "catch_exception_translator_registry.hpp"
 | 
					
						
							| 
									
										
										
										
											2012-08-06 08:33:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-06 20:16:53 +01:00
										 |  |  | namespace Catch { | 
					
						
							| 
									
										
										
										
											2012-08-06 08:33:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-06 20:16:53 +01:00
										 |  |  |     namespace { | 
					
						
							|  |  |  |          | 
					
						
							| 
									
										
										
										
											2012-08-07 07:58:34 +01:00
										 |  |  |         class RegistryHub : public IRegistryHub, public IMutableRegistryHub { | 
					
						
							| 
									
										
										
										
											2012-08-06 08:33:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-07 07:58:34 +01:00
										 |  |  |             RegistryHub( const RegistryHub& ); | 
					
						
							|  |  |  |             void operator=( const RegistryHub& ); | 
					
						
							| 
									
										
										
										
											2012-08-06 20:16:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-07 07:58:34 +01:00
										 |  |  |         public: // IRegistryHub
 | 
					
						
							|  |  |  |             RegistryHub() { | 
					
						
							| 
									
										
										
										
											2012-08-06 20:16:53 +01:00
										 |  |  |             } | 
					
						
							|  |  |  |             virtual const IReporterRegistry& getReporterRegistry() const { | 
					
						
							|  |  |  |                 return m_reporterRegistry; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             virtual const ITestCaseRegistry& getTestCaseRegistry() const { | 
					
						
							|  |  |  |                 return m_testCaseRegistry; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() { | 
					
						
							|  |  |  |                 return m_exceptionTranslatorRegistry; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-07 07:58:34 +01:00
										 |  |  |         public: // IMutableRegistryHub
 | 
					
						
							| 
									
										
										
										
											2012-08-06 20:16:53 +01:00
										 |  |  |             virtual void registerReporter( const std::string& name, IReporterFactory* factory ) { | 
					
						
							|  |  |  |                 m_reporterRegistry.registerReporter( name, factory ); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             virtual void registerTest( const TestCaseInfo& testInfo ) { | 
					
						
							|  |  |  |                 m_testCaseRegistry.registerTest( testInfo ); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             virtual void registerTranslator( const IExceptionTranslator* translator ) { | 
					
						
							|  |  |  |                 m_exceptionTranslatorRegistry.registerTranslator( translator ); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         private: | 
					
						
							|  |  |  |             TestRegistry m_testCaseRegistry; | 
					
						
							|  |  |  |             ReporterRegistry m_reporterRegistry; | 
					
						
							|  |  |  |             ExceptionTranslatorRegistry m_exceptionTranslatorRegistry; | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-07 07:58:34 +01:00
										 |  |  |         // Single, global, instance
 | 
					
						
							|  |  |  |         inline RegistryHub*& getTheRegistryHub() { | 
					
						
							|  |  |  |             static RegistryHub* theRegistryHub = NULL; | 
					
						
							|  |  |  |             if( !theRegistryHub ) | 
					
						
							|  |  |  |                 theRegistryHub = new RegistryHub(); | 
					
						
							|  |  |  |             return theRegistryHub; | 
					
						
							| 
									
										
										
										
											2012-08-06 20:16:53 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-07 07:58:34 +01:00
										 |  |  |     IRegistryHub& getRegistryHub() { | 
					
						
							|  |  |  |         return *getTheRegistryHub(); | 
					
						
							| 
									
										
										
										
											2012-08-06 20:16:53 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-07 07:58:34 +01:00
										 |  |  |     IMutableRegistryHub& getMutableRegistryHub() { | 
					
						
							|  |  |  |         return *getTheRegistryHub(); | 
					
						
							| 
									
										
										
										
											2012-08-06 20:16:53 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     void cleanUp() { | 
					
						
							| 
									
										
										
										
											2012-08-07 07:58:34 +01:00
										 |  |  |         delete getTheRegistryHub(); | 
					
						
							|  |  |  |         getTheRegistryHub() = NULL; | 
					
						
							| 
									
										
										
										
											2012-08-08 08:33:54 +01:00
										 |  |  |         cleanUpContext(); | 
					
						
							| 
									
										
										
										
											2012-08-06 20:16:53 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-10-17 08:14:22 +01:00
										 |  |  |     std::string translateActiveException() { | 
					
						
							|  |  |  |         return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-06 20:16:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // end namespace Catch
 | 
					
						
							| 
									
										
										
										
											2012-09-17 01:42:29 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif // TWOBLUECUBES_CATCH_REGISTRY_HUB_HPP_INCLUDED
 |