// Copyright (C) 2013 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp #include #include #include #if defined(NAZARA_PLATFORM_WINDOWS) #include #elif defined(NAZARA_PLATFORM_POSIX) #include #else #error No implementation for this platform #endif #include NzDynLib::NzDynLib(const NzString& libraryPath) : m_path(libraryPath), m_impl(nullptr) { } NzDynLib::~NzDynLib() { Unload(); } NzString NzDynLib::GetLastError() const { NazaraLock(m_mutex) return m_lastError; } NzDynLibFunc NzDynLib::GetSymbol(const NzString& symbol) const { NazaraLock(m_mutex) #if NAZARA_CORE_SAFE if (!m_impl) { NazaraError("Library not opened"); return nullptr; } #endif return m_impl->GetSymbol(symbol); } bool NzDynLib::Load() { NazaraLock(m_mutex) Unload(); m_impl = new NzDynLibImpl(this); if (!m_impl->Load(m_path)) { delete m_impl; m_impl = nullptr; return false; } return true; } void NzDynLib::Unload() { NazaraLock(m_mutex) if (m_impl) { m_impl->Unload(); delete m_impl; m_impl = nullptr; } } void NzDynLib::SetLastError(const NzString& error) { NazaraLock(m_mutex) m_lastError = error; }