2010-12-31 23:54:35 +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)
|
|
|
|
*/
|
2012-09-17 07:42:29 +02:00
|
|
|
#ifndef TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED
|
|
|
|
|
2015-08-05 20:02:17 +02:00
|
|
|
#include "catch_run_context.hpp"
|
2012-05-10 09:17:06 +02:00
|
|
|
|
|
|
|
#include "catch_context.h"
|
2011-01-18 10:20:06 +01:00
|
|
|
#include "catch_stream.hpp"
|
2010-12-31 23:54:35 +01:00
|
|
|
|
2012-05-16 09:02:20 +02:00
|
|
|
namespace Catch {
|
2012-08-08 09:33:54 +02:00
|
|
|
|
|
|
|
class Context : public IMutableContext {
|
|
|
|
|
2015-07-01 08:33:27 +02:00
|
|
|
Context() : m_config( CATCH_NULL ), m_runner( CATCH_NULL ), m_resultCapture( CATCH_NULL ) {}
|
2013-04-23 19:58:56 +02:00
|
|
|
Context( Context const& );
|
|
|
|
void operator=( Context const& );
|
2012-08-08 09:33:54 +02:00
|
|
|
|
|
|
|
public: // IContext
|
2014-05-20 19:49:28 +02:00
|
|
|
virtual IResultCapture* getResultCapture() {
|
|
|
|
return m_resultCapture;
|
2012-08-08 09:33:54 +02:00
|
|
|
}
|
2014-05-20 19:49:28 +02:00
|
|
|
virtual IRunner* getRunner() {
|
|
|
|
return m_runner;
|
2012-08-08 09:33:54 +02:00
|
|
|
}
|
2015-11-19 08:35:35 +01:00
|
|
|
virtual IConfig const* getConfig() const {
|
|
|
|
return m_config.get();
|
2012-08-08 09:33:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public: // IMutableContext
|
|
|
|
virtual void setResultCapture( IResultCapture* resultCapture ) {
|
|
|
|
m_resultCapture = resultCapture;
|
|
|
|
}
|
|
|
|
virtual void setRunner( IRunner* runner ) {
|
|
|
|
m_runner = runner;
|
|
|
|
}
|
2013-05-28 19:51:53 +02:00
|
|
|
virtual void setConfig( Ptr<IConfig const> const& config ) {
|
2012-08-08 09:33:54 +02:00
|
|
|
m_config = config;
|
|
|
|
}
|
2013-07-03 20:14:59 +02:00
|
|
|
|
2012-08-08 09:33:54 +02:00
|
|
|
friend IMutableContext& getCurrentMutableContext();
|
|
|
|
|
|
|
|
private:
|
2013-10-23 16:35:07 +02:00
|
|
|
Ptr<IConfig const> m_config;
|
2012-08-08 09:33:54 +02:00
|
|
|
IRunner* m_runner;
|
|
|
|
IResultCapture* m_resultCapture;
|
|
|
|
};
|
2013-07-03 20:14:59 +02:00
|
|
|
|
2012-05-22 09:55:19 +02:00
|
|
|
namespace {
|
2015-07-01 08:33:27 +02:00
|
|
|
Context* currentContext = CATCH_NULL;
|
2012-05-22 09:55:19 +02:00
|
|
|
}
|
|
|
|
IMutableContext& getCurrentMutableContext() {
|
2012-06-05 11:13:52 +02:00
|
|
|
if( !currentContext )
|
|
|
|
currentContext = new Context();
|
|
|
|
return *currentContext;
|
2012-05-22 09:55:19 +02:00
|
|
|
}
|
|
|
|
IContext& getCurrentContext() {
|
|
|
|
return getCurrentMutableContext();
|
|
|
|
}
|
2012-02-18 10:58:30 +01:00
|
|
|
|
2012-08-08 09:33:54 +02:00
|
|
|
void cleanUpContext() {
|
|
|
|
delete currentContext;
|
2015-07-01 08:33:27 +02:00
|
|
|
currentContext = CATCH_NULL;
|
2011-01-27 00:23:33 +01:00
|
|
|
}
|
2015-11-19 08:35:35 +01:00
|
|
|
|
|
|
|
IConfig const* getCurrentConfig() {
|
|
|
|
return currentContext
|
|
|
|
? currentContext->getConfig()
|
|
|
|
: CATCH_NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-31 23:54:35 +01:00
|
|
|
}
|
2012-09-17 07:42:29 +02:00
|
|
|
|
|
|
|
#endif // TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED
|