1 /* 2 * Created by Phil on 31/12/2010. 3 * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. 4 * 5 * Distributed under the Boost Software License, Version 1.0. (See accompanying 6 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 */ 8 #include "catch_context.h" 9 #include "catch_common.h" 10 11 namespace Catch { 12 13 class Context : public IMutableContext, NonCopyable { 14 15 public: // IContext getResultCapture()16 virtual IResultCapture* getResultCapture() override { 17 return m_resultCapture; 18 } getRunner()19 virtual IRunner* getRunner() override { 20 return m_runner; 21 } 22 getConfig() const23 virtual IConfigPtr const& getConfig() const override { 24 return m_config; 25 } 26 27 virtual ~Context() override; 28 29 public: // IMutableContext setResultCapture(IResultCapture * resultCapture)30 virtual void setResultCapture( IResultCapture* resultCapture ) override { 31 m_resultCapture = resultCapture; 32 } setRunner(IRunner * runner)33 virtual void setRunner( IRunner* runner ) override { 34 m_runner = runner; 35 } setConfig(IConfigPtr const & config)36 virtual void setConfig( IConfigPtr const& config ) override { 37 m_config = config; 38 } 39 40 friend IMutableContext& getCurrentMutableContext(); 41 42 private: 43 IConfigPtr m_config; 44 IRunner* m_runner = nullptr; 45 IResultCapture* m_resultCapture = nullptr; 46 }; 47 48 IMutableContext *IMutableContext::currentContext = nullptr; 49 createContext()50 void IMutableContext::createContext() 51 { 52 currentContext = new Context(); 53 } 54 cleanUpContext()55 void cleanUpContext() { 56 delete IMutableContext::currentContext; 57 IMutableContext::currentContext = nullptr; 58 } 59 IContext::~IContext() = default; 60 IMutableContext::~IMutableContext() = default; 61 Context::~Context() = default; 62 } 63