Compare commits
2 Commits
c1cad88224
...
1118ec3205
| Author | SHA1 | Date | |
|---|---|---|---|
| 1118ec3205 | |||
| a7abdbae57 |
@ -16,7 +16,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "interface/StreamReader.interface.inl"
|
||||
#include "Interface/StreamReader.interface.inl"
|
||||
|
||||
namespace ia
|
||||
{
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
// IACore-OSS; The Core Library for All IA Open Source Projects
|
||||
// IACore-OSS; The Core Library for All IA Open Source Projects
|
||||
// Copyright (C) 2024 IAS (ias@iasoft.dev)
|
||||
//
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
@ -19,11 +19,18 @@
|
||||
#include <IACore/Base.hpp>
|
||||
#include <memory>
|
||||
|
||||
#define REF_PTR_CLASS \
|
||||
template<typename _value_type, typename... Args> friend INLINE RefPtr<_value_type> MakeRefPtr(Args &&...args) \
|
||||
{ \
|
||||
return std::make_shared<_value_type>(std::forward<Args>(args)...); \
|
||||
}
|
||||
|
||||
namespace ia
|
||||
{
|
||||
template<typename _value_type>
|
||||
using RefPtr = std::shared_ptr<_value_type>;
|
||||
template<typename _value_type> using RefPtr = std::shared_ptr<_value_type>;
|
||||
|
||||
template<typename _value_type, typename... Args>
|
||||
INLINE RefPtr<_value_type> MakeRefPtr(Args... args) { return std::make_shared<_value_type>(args...); }
|
||||
}
|
||||
template<typename _value_type, typename... Args> INLINE RefPtr<_value_type> MakeRefPtr(Args &&...args)
|
||||
{
|
||||
return std::make_shared<_value_type>(std::forward<Args>(args)...);
|
||||
}
|
||||
} // namespace ia
|
||||
|
||||
@ -35,12 +35,14 @@ namespace ia
|
||||
|
||||
INLINE ~DynamicLib();
|
||||
|
||||
INLINE VOID Destroy();
|
||||
|
||||
public:
|
||||
INLINE PVOID GetSymbol(IN CONST String &name);
|
||||
|
||||
template<typename FunctionType> FunctionType GetFunction(IN CONST String &name)
|
||||
{
|
||||
return reinterpret_cast<FunctionType *>(GetSymbol(name));
|
||||
return reinterpret_cast<FunctionType>(GetSymbol(name));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -57,6 +59,10 @@ namespace ia
|
||||
{
|
||||
}
|
||||
|
||||
DynamicLib::~DynamicLib()
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
DynamicLib DynamicLib::Load(IN CONST String &searchPath, IN CONST String &name)
|
||||
{
|
||||
@ -66,12 +72,6 @@ namespace ia
|
||||
return DynamicLib((PVOID) handle);
|
||||
}
|
||||
|
||||
DynamicLib::~DynamicLib()
|
||||
{
|
||||
if (m_moduleHandle)
|
||||
FreeLibrary(static_cast<HMODULE>(m_moduleHandle));
|
||||
}
|
||||
|
||||
PVOID DynamicLib::GetSymbol(IN CONST String &name)
|
||||
{
|
||||
const auto symbol = GetProcAddress(static_cast<HMODULE>(m_moduleHandle), name.c_str());
|
||||
@ -79,6 +79,12 @@ namespace ia
|
||||
THROW_UNKNOWN("DynamicLib: Failed to find the symbol \"", name, "\" with error: ", GetLastError());
|
||||
return (PVOID) symbol;
|
||||
}
|
||||
|
||||
VOID DynamicLib::Destroy()
|
||||
{
|
||||
if (m_moduleHandle)
|
||||
FreeLibrary(static_cast<HMODULE>(m_moduleHandle));
|
||||
}
|
||||
#else
|
||||
DynamicLib DynamicLib::Load(IN CONST String &searchPath, IN CONST String &name)
|
||||
{
|
||||
@ -89,12 +95,6 @@ namespace ia
|
||||
return DynamicLib((PVOID) handle);
|
||||
}
|
||||
|
||||
DynamicLib::~DynamicLib()
|
||||
{
|
||||
if (m_moduleHandle)
|
||||
dlclose(m_moduleHandle);
|
||||
}
|
||||
|
||||
PVOID DynamicLib::GetSymbol(IN CONST String &name)
|
||||
{
|
||||
dlerror();
|
||||
@ -102,7 +102,13 @@ namespace ia
|
||||
const char *dlsym_error = dlerror();
|
||||
if (dlsym_error)
|
||||
THROW_UNKNOWN("DynamicLib: Failed to find the symbol \"", name, "\" with error: ", dlerror());
|
||||
return (PVOID)symbol;
|
||||
return (PVOID) symbol;
|
||||
}
|
||||
|
||||
VOID DynamicLib::Destroy()
|
||||
{
|
||||
if (m_moduleHandle)
|
||||
dlclose(m_moduleHandle);
|
||||
}
|
||||
#endif
|
||||
} // namespace ia
|
||||
Reference in New Issue
Block a user