1
0
mirror of https://github.com/catchorg/Catch2.git synced 2025-04-29 12:03:53 +00:00
Catch2/src/catch2/internal/catch_context.cpp
Martin Hořeňovský 90aeffb97d
Add standardized copyright notice + SPDX identifier to source files
This should also be done for test files, but that has lower priority.
2020-08-30 15:43:45 +02:00

71 lines
1.9 KiB
C++

// 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>
namespace Catch {
class Context : public IMutableContext, private Detail::NonCopyable {
public: // IContext
IResultCapture* getResultCapture() override {
return m_resultCapture;
}
IRunner* getRunner() override {
return m_runner;
}
IConfig const* getConfig() const override {
return m_config;
}
~Context() override;
public: // IMutableContext
void setResultCapture( IResultCapture* resultCapture ) override {
m_resultCapture = resultCapture;
}
void setRunner( IRunner* runner ) override {
m_runner = runner;
}
void setConfig( IConfig const* config ) override {
m_config = config;
}
friend IMutableContext& getCurrentMutableContext();
private:
IConfig const* m_config = nullptr;
IRunner* m_runner = nullptr;
IResultCapture* m_resultCapture = nullptr;
};
IMutableContext *IMutableContext::currentContext = nullptr;
void IMutableContext::createContext()
{
currentContext = new Context();
}
void cleanUpContext() {
delete IMutableContext::currentContext;
IMutableContext::currentContext = nullptr;
}
IContext::~IContext() = default;
IMutableContext::~IMutableContext() = default;
Context::~Context() = default;
SimplePcg32& rng() {
static SimplePcg32 s_rng;
return s_rng;
}
}