2020-08-30 15:43:45 +02:00
|
|
|
|
|
|
|
|
// Copyright Catch2 Authors
|
|
|
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
|
|
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
|
|
|
|
// https://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
|
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
2020-03-30 10:34:21 +02:00
|
|
|
#include <catch2/internal/catch_context.hpp>
|
2020-08-18 11:35:58 +02:00
|
|
|
#include <catch2/internal/catch_noncopyable.hpp>
|
2020-03-30 10:34:21 +02:00
|
|
|
#include <catch2/internal/catch_random_number_generator.hpp>
|
2010-12-31 22:54:35 +00:00
|
|
|
|
2012-05-16 08:02:20 +01:00
|
|
|
namespace Catch {
|
2012-08-08 08:33:54 +01:00
|
|
|
|
2020-08-18 11:35:58 +02:00
|
|
|
class Context : public IMutableContext, private Detail::NonCopyable {
|
2012-08-08 08:33:54 +01:00
|
|
|
|
|
|
|
|
public: // IContext
|
2018-07-12 14:27:06 +02:00
|
|
|
IResultCapture* getResultCapture() override {
|
2014-05-20 18:49:28 +01:00
|
|
|
return m_resultCapture;
|
2012-08-08 08:33:54 +01:00
|
|
|
}
|
|
|
|
|
|
2020-05-19 15:40:32 +02:00
|
|
|
IConfig const* getConfig() const override {
|
2020-05-19 18:02:05 +02:00
|
|
|
return m_config;
|
2012-08-08 08:33:54 +01:00
|
|
|
}
|
|
|
|
|
|
2018-07-12 14:27:06 +02:00
|
|
|
~Context() override;
|
2017-09-07 16:51:33 +02:00
|
|
|
|
2012-08-08 08:33:54 +01:00
|
|
|
public: // IMutableContext
|
2018-07-12 14:27:06 +02:00
|
|
|
void setResultCapture( IResultCapture* resultCapture ) override {
|
2012-08-08 08:33:54 +01:00
|
|
|
m_resultCapture = resultCapture;
|
|
|
|
|
}
|
2020-05-19 18:02:05 +02:00
|
|
|
void setConfig( IConfig const* config ) override {
|
2012-08-08 08:33:54 +01:00
|
|
|
m_config = config;
|
|
|
|
|
}
|
2013-07-03 19:14:59 +01:00
|
|
|
|
2012-08-08 08:33:54 +01:00
|
|
|
friend IMutableContext& getCurrentMutableContext();
|
|
|
|
|
|
|
|
|
|
private:
|
2020-05-19 18:02:05 +02:00
|
|
|
IConfig const* m_config = nullptr;
|
2017-04-25 18:56:53 +01:00
|
|
|
IResultCapture* m_resultCapture = nullptr;
|
2012-08-08 08:33:54 +01:00
|
|
|
};
|
2013-07-03 19:14:59 +01:00
|
|
|
|
2017-11-17 14:55:30 -06:00
|
|
|
IMutableContext *IMutableContext::currentContext = nullptr;
|
|
|
|
|
|
|
|
|
|
void IMutableContext::createContext()
|
|
|
|
|
{
|
|
|
|
|
currentContext = new Context();
|
2012-05-22 08:55:19 +01:00
|
|
|
}
|
2012-02-18 09:58:30 +00:00
|
|
|
|
2012-08-08 08:33:54 +01:00
|
|
|
void cleanUpContext() {
|
2017-11-17 14:55:30 -06:00
|
|
|
delete IMutableContext::currentContext;
|
|
|
|
|
IMutableContext::currentContext = nullptr;
|
2011-01-26 23:23:33 +00:00
|
|
|
}
|
2017-09-07 16:51:33 +02:00
|
|
|
IContext::~IContext() = default;
|
|
|
|
|
IMutableContext::~IMutableContext() = default;
|
|
|
|
|
Context::~Context() = default;
|
2019-10-06 21:47:54 +02:00
|
|
|
|
|
|
|
|
|
2022-05-17 15:37:14 +02:00
|
|
|
SimplePcg32& sharedRng() {
|
2019-10-06 21:47:54 +02:00
|
|
|
static SimplePcg32 s_rng;
|
|
|
|
|
return s_rng;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-31 22:54:35 +00:00
|
|
|
}
|