Documentation for DynLib & PluginManager

Former-commit-id: 3602bd9a6f24ed4adb38879097ea5679b55e3b99
This commit is contained in:
Gawaboumga
2016-02-21 14:38:35 +01:00
parent 5a5f25a950
commit 99370683b3
4 changed files with 136 additions and 5 deletions

View File

@@ -25,11 +25,26 @@
namespace Nz
{
/*!
* \class Nz::DynLib
* \brief Core class that represents a dynamic library loader
*/
/*!
* \brief Constructs a DynLib object by default
*/
DynLib::DynLib() :
m_impl(nullptr)
{
}
/*!
* \brief Constructs a DynLib object by move semantic
*
* \param lib DynLib to move into this
*/
DynLib::DynLib(DynLib&& lib) :
m_lastError(std::move(lib.m_lastError)),
m_impl(lib.m_impl)
@@ -37,11 +52,22 @@ namespace Nz
lib.m_impl = nullptr;
}
/*!
* \brief Destructs the object and calls Unload
*
* \see Unload
*/
DynLib::~DynLib()
{
Unload();
}
/*!
* \brief Gets the last error
* \return Last error
*/
String DynLib::GetLastError() const
{
NazaraLock(m_mutex)
@@ -49,12 +75,19 @@ namespace Nz
return m_lastError;
}
/*!
* \brief Gets the symbol for the name
* \return Function which is the symbol of the function name
*
* \remark Produces a NazaraError if library is not loaded with NAZARA_CORE_SAFE defined
*/
DynLibFunc DynLib::GetSymbol(const String& symbol) const
{
NazaraLock(m_mutex)
#if NAZARA_CORE_SAFE
if (!m_impl)
if (!IsLoaded())
{
NazaraError("Library not opened");
return nullptr;
@@ -64,11 +97,25 @@ namespace Nz
return m_impl->GetSymbol(symbol, &m_lastError);
}
/*!
* \brief Checks whether the library is loaded
* \return true if loaded
*/
bool DynLib::IsLoaded() const
{
return m_impl != nullptr;
}
/*!
* \brief Loads the library with that path
* \return true if loading is successful
*
* \param libraryPath Path of the library
*
* \remark Produces a NazaraError if library is could not be loaded
*/
bool DynLib::Load(const String& libraryPath)
{
NazaraLock(m_mutex)
@@ -87,11 +134,15 @@ namespace Nz
return true;
}
/*!
* \brief Unloads the library
*/
void DynLib::Unload()
{
NazaraLock(m_mutex)
if (m_impl)
if (IsLoaded())
{
m_impl->Unload();
delete m_impl;
@@ -99,6 +150,13 @@ namespace Nz
}
}
/*!
* \brief Moves the other lib into this
* \return A reference to this
*
* \param lib DynLib to move in this
*/
DynLib& DynLib::operator=(DynLib&& lib)
{
Unload();