mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-29 16:53:30 +01:00
Moved registry hub to generic singleton
This commit is contained in:
parent
eb783fc20e
commit
5884ec1e28
@ -33,7 +33,7 @@ namespace Catch {
|
|||||||
virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0;
|
virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0;
|
||||||
virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0;
|
virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0;
|
||||||
|
|
||||||
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0;
|
virtual IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const = 0;
|
||||||
|
|
||||||
|
|
||||||
virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0;
|
virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0;
|
||||||
@ -49,7 +49,7 @@ namespace Catch {
|
|||||||
virtual void registerStartupException() noexcept = 0;
|
virtual void registerStartupException() noexcept = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
IRegistryHub& getRegistryHub();
|
IRegistryHub const& getRegistryHub();
|
||||||
IMutableRegistryHub& getMutableRegistryHub();
|
IMutableRegistryHub& getMutableRegistryHub();
|
||||||
void cleanUp();
|
void cleanUp();
|
||||||
std::string translateActiveException();
|
std::string translateActiveException();
|
||||||
|
@ -31,7 +31,7 @@ namespace Catch {
|
|||||||
ITestCaseRegistry const& getTestCaseRegistry() const override {
|
ITestCaseRegistry const& getTestCaseRegistry() const override {
|
||||||
return m_testCaseRegistry;
|
return m_testCaseRegistry;
|
||||||
}
|
}
|
||||||
IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() override {
|
IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const override {
|
||||||
return m_exceptionTranslatorRegistry;
|
return m_exceptionTranslatorRegistry;
|
||||||
}
|
}
|
||||||
ITagAliasRegistry const& getTagAliasRegistry() const override {
|
ITagAliasRegistry const& getTagAliasRegistry() const override {
|
||||||
@ -68,26 +68,18 @@ namespace Catch {
|
|||||||
TagAliasRegistry m_tagAliasRegistry;
|
TagAliasRegistry m_tagAliasRegistry;
|
||||||
StartupExceptionRegistry m_exceptionRegistry;
|
StartupExceptionRegistry m_exceptionRegistry;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Single, global, instance
|
|
||||||
RegistryHub*& getTheRegistryHub() {
|
|
||||||
static RegistryHub* theRegistryHub = nullptr;
|
|
||||||
if( !theRegistryHub )
|
|
||||||
theRegistryHub = new RegistryHub();
|
|
||||||
return theRegistryHub;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IRegistryHub& getRegistryHub() {
|
using RegistryHubSingleton = Singleton<RegistryHub, IRegistryHub, IMutableRegistryHub>;
|
||||||
return *getTheRegistryHub();
|
|
||||||
|
IRegistryHub const& getRegistryHub() {
|
||||||
|
return RegistryHubSingleton::get();
|
||||||
}
|
}
|
||||||
IMutableRegistryHub& getMutableRegistryHub() {
|
IMutableRegistryHub& getMutableRegistryHub() {
|
||||||
return *getTheRegistryHub();
|
return RegistryHubSingleton::getMutable();
|
||||||
}
|
}
|
||||||
void cleanUp() {
|
void cleanUp() {
|
||||||
cleanupSingletons();
|
cleanupSingletons();
|
||||||
delete getTheRegistryHub();
|
|
||||||
getTheRegistryHub() = nullptr;
|
|
||||||
cleanUpContext();
|
cleanUpContext();
|
||||||
ReusableStringStream::cleanup();
|
ReusableStringStream::cleanup();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user