Files
Catch2/src/catch2/internal/catch_context.cpp

64 lines
1.7 KiB
C++
Raw Normal View History

// 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
#include <catch2/internal/catch_context.hpp>
#include <catch2/internal/catch_noncopyable.hpp>
#include <catch2/internal/catch_random_number_generator.hpp>
2012-05-16 08:02:20 +01:00
namespace Catch {
class Context : public IMutableContext, private Detail::NonCopyable {
public: // IContext
IResultCapture* getResultCapture() override {
2014-05-20 18:49:28 +01:00
return m_resultCapture;
}
2020-05-19 15:40:32 +02:00
IConfig const* getConfig() const override {
return m_config;
}
~Context() override;
public: // IMutableContext
void setResultCapture( IResultCapture* resultCapture ) override {
m_resultCapture = resultCapture;
}
void setConfig( IConfig const* config ) override {
m_config = config;
}
friend IMutableContext& getCurrentMutableContext();
private:
IConfig const* m_config = nullptr;
IResultCapture* m_resultCapture = nullptr;
};
IMutableContext *IMutableContext::currentContext = nullptr;
void IMutableContext::createContext()
{
currentContext = new Context();
}
void cleanUpContext() {
delete IMutableContext::currentContext;
IMutableContext::currentContext = nullptr;
2011-01-26 23:23:33 +00:00
}
IContext::~IContext() = default;
IMutableContext::~IMutableContext() = default;
Context::~Context() = default;
2022-05-17 15:37:14 +02:00
SimplePcg32& sharedRng() {
static SimplePcg32 s_rng;
return s_rng;
}
}