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-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
|
2017-07-25 17:16:28 +02:00
|
|
|
virtual IResultCapture* getResultCapture() override {
|
2014-05-20 19:49:28 +02:00
|
|
|
return m_resultCapture;
|
2012-08-08 09:33:54 +02:00
|
|
|
}
|
2017-07-25 17:16:28 +02:00
|
|
|
virtual IRunner* getRunner() override {
|
2014-05-20 19:49:28 +02:00
|
|
|
return m_runner;
|
2012-08-08 09:33:54 +02:00
|
|
|
}
|
|
|
|
|
2017-12-09 20:17:47 +01:00
|
|
|
virtual IConfigPtr const& getConfig() const override {
|
2012-08-08 09:33:54 +02:00
|
|
|
return m_config;
|
|
|
|
}
|
|
|
|
|
2017-09-07 16:51:33 +02:00
|
|
|
virtual ~Context() override;
|
|
|
|
|
2012-08-08 09:33:54 +02:00
|
|
|
public: // IMutableContext
|
2017-07-25 17:16:28 +02:00
|
|
|
virtual void setResultCapture( IResultCapture* resultCapture ) override {
|
2012-08-08 09:33:54 +02:00
|
|
|
m_resultCapture = resultCapture;
|
|
|
|
}
|
2017-07-25 17:16:28 +02:00
|
|
|
virtual void setRunner( IRunner* runner ) override {
|
2012-08-08 09:33:54 +02:00
|
|
|
m_runner = runner;
|
|
|
|
}
|
2017-07-25 17:16:28 +02:00
|
|
|
virtual void setConfig( IConfigPtr const& config ) override {
|
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:
|
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
|
|
|
|
2017-11-17 21:55:30 +01:00
|
|
|
IMutableContext *IMutableContext::currentContext = nullptr;
|
|
|
|
|
|
|
|
void IMutableContext::createContext()
|
|
|
|
{
|
|
|
|
currentContext = new Context();
|
2012-05-22 09:55:19 +02:00
|
|
|
}
|
2012-02-18 10:58:30 +01:00
|
|
|
|
2012-08-08 09:33:54 +02:00
|
|
|
void cleanUpContext() {
|
2017-11-17 21:55:30 +01:00
|
|
|
delete IMutableContext::currentContext;
|
|
|
|
IMutableContext::currentContext = nullptr;
|
2011-01-27 00:23:33 +01:00
|
|
|
}
|
2017-09-07 16:51:33 +02:00
|
|
|
IContext::~IContext() = default;
|
|
|
|
IMutableContext::~IMutableContext() = default;
|
|
|
|
Context::~Context() = default;
|
2010-12-31 23:54:35 +01:00
|
|
|
}
|