Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:53:27

0001 
0002 //              Copyright Catch2 Authors
0003 // Distributed under the Boost Software License, Version 1.0.
0004 //   (See accompanying file LICENSE.txt or copy at
0005 //        https://www.boost.org/LICENSE_1_0.txt)
0006 
0007 // SPDX-License-Identifier: BSL-1.0
0008 #ifndef CATCH_CONTEXT_HPP_INCLUDED
0009 #define CATCH_CONTEXT_HPP_INCLUDED
0010 
0011 #include <catch2/internal/catch_compiler_capabilities.hpp>
0012 
0013 namespace Catch {
0014 
0015     class IResultCapture;
0016     class IConfig;
0017 
0018     class Context {
0019         IConfig const* m_config = nullptr;
0020         IResultCapture* m_resultCapture = nullptr;
0021 
0022         CATCH_EXPORT static Context* currentContext;
0023         friend Context& getCurrentMutableContext();
0024         friend Context const& getCurrentContext();
0025         static void createContext();
0026         friend void cleanUpContext();
0027 
0028     public:
0029         constexpr IResultCapture* getResultCapture() const {
0030             return m_resultCapture;
0031         }
0032         constexpr IConfig const* getConfig() const { return m_config; }
0033         constexpr void setResultCapture( IResultCapture* resultCapture ) {
0034             m_resultCapture = resultCapture;
0035         }
0036         constexpr void setConfig( IConfig const* config ) { m_config = config; }
0037 
0038     };
0039 
0040     Context& getCurrentMutableContext();
0041 
0042     inline Context const& getCurrentContext() {
0043         // We duplicate the logic from `getCurrentMutableContext` here,
0044         // to avoid paying the call overhead in debug mode.
0045         if ( !Context::currentContext ) { Context::createContext(); }
0046         // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn)
0047         return *Context::currentContext;
0048     }
0049 
0050     void cleanUpContext();
0051 
0052     class SimplePcg32;
0053     SimplePcg32& sharedRng();
0054 }
0055 
0056 #endif // CATCH_CONTEXT_HPP_INCLUDED