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
|
|
|
|
|
2012-05-10 09:17:06 +02:00
|
|
|
#include "catch_context.h"
|
2017-01-16 11:30:44 +01:00
|
|
|
#include "catch_common.h"
|
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
|
|
|
|
2017-04-25 19:56:53 +02:00
|
|
|
class Context : public IMutableContext, NonCopyable {
|
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
|
|
|
}
|
|
|
|
|
2017-04-25 21:18:02 +02:00
|
|
|
virtual IConfigPtr getConfig() const {
|
2012-08-08 09:33:54 +02:00
|
|
|
return m_config;
|
|
|
|
}
|
|
|
|
|
|
|
|
public: // IMutableContext
|
|
|
|
virtual void setResultCapture( IResultCapture* resultCapture ) {
|
|
|
|
m_resultCapture = resultCapture;
|
|
|
|
}
|
|
|
|
virtual void setRunner( IRunner* runner ) {
|
|
|
|
m_runner = runner;
|
|
|
|
}
|
2017-04-25 21:18:02 +02:00
|
|
|
virtual void setConfig( IConfigPtr 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:
|
|
|
|
|
|
|
|
private:
|
2017-04-25 21:18:02 +02:00
|
|
|
IConfigPtr m_config;
|
2017-04-25 19:56:53 +02:00
|
|
|
IRunner* m_runner = nullptr;
|
|
|
|
IResultCapture* m_resultCapture = nullptr;
|
2012-08-08 09:33:54 +02:00
|
|
|
};
|
2013-07-03 20:14:59 +02:00
|
|
|
|
2012-05-22 09:55:19 +02:00
|
|
|
namespace {
|
2017-04-25 12:41:30 +02:00
|
|
|
Context* currentContext = nullptr;
|
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;
|
2017-04-25 12:41:30 +02:00
|
|
|
currentContext = nullptr;
|
2011-01-27 00:23:33 +01:00
|
|
|
}
|
2010-12-31 23:54:35 +01:00
|
|
|
}
|
2012-09-17 07:42:29 +02:00
|
|
|
|
|
|
|
#endif // TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED
|