Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:05

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         IResultCapture* getResultCapture() const { return m_resultCapture; }
0030         IConfig const* getConfig() const { return m_config; }
0031         void setResultCapture( IResultCapture* resultCapture );
0032         void setConfig( IConfig const* config );
0033     };
0034 
0035     Context& getCurrentMutableContext();
0036 
0037     inline Context const& getCurrentContext() {
0038         // We duplicate the logic from `getCurrentMutableContext` here,
0039         // to avoid paying the call overhead in debug mode.
0040         if ( !Context::currentContext ) { Context::createContext(); }
0041         // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn)
0042         return *Context::currentContext;
0043     }
0044 
0045     void cleanUpContext();
0046 
0047     class SimplePcg32;
0048     SimplePcg32& sharedRng();
0049 }
0050 
0051 #endif // CATCH_CONTEXT_HPP_INCLUDED