Compare commits

..

2 Commits

Author SHA1 Message Date
1118ec3205 Fixes 2025-11-08 23:46:27 +05:30
a7abdbae57 Fixes 2025-11-07 00:16:34 +05:30
3 changed files with 37 additions and 24 deletions

View File

@ -16,7 +16,7 @@
#pragma once #pragma once
#include "interface/StreamReader.interface.inl" #include "Interface/StreamReader.interface.inl"
namespace ia namespace ia
{ {

View File

@ -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) // Copyright (C) 2024 IAS (ias@iasoft.dev)
// //
// This program is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
@ -19,11 +19,18 @@
#include <IACore/Base.hpp> #include <IACore/Base.hpp>
#include <memory> #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 namespace ia
{ {
template<typename _value_type> template<typename _value_type> using RefPtr = std::shared_ptr<_value_type>;
using RefPtr = std::shared_ptr<_value_type>;
template<typename _value_type, typename... Args> template<typename _value_type, typename... Args> INLINE RefPtr<_value_type> MakeRefPtr(Args &&...args)
INLINE RefPtr<_value_type> MakeRefPtr(Args... args) { return std::make_shared<_value_type>(args...); } {
} return std::make_shared<_value_type>(std::forward<Args>(args)...);
}
} // namespace ia

View File

@ -35,12 +35,14 @@ namespace ia
INLINE ~DynamicLib(); INLINE ~DynamicLib();
INLINE VOID Destroy();
public: public:
INLINE PVOID GetSymbol(IN CONST String &name); INLINE PVOID GetSymbol(IN CONST String &name);
template<typename FunctionType> FunctionType GetFunction(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: private:
@ -57,6 +59,10 @@ namespace ia
{ {
} }
DynamicLib::~DynamicLib()
{
}
#if defined(_WIN32) #if defined(_WIN32)
DynamicLib DynamicLib::Load(IN CONST String &searchPath, IN CONST String &name) DynamicLib DynamicLib::Load(IN CONST String &searchPath, IN CONST String &name)
{ {
@ -66,12 +72,6 @@ namespace ia
return DynamicLib((PVOID) handle); return DynamicLib((PVOID) handle);
} }
DynamicLib::~DynamicLib()
{
if (m_moduleHandle)
FreeLibrary(static_cast<HMODULE>(m_moduleHandle));
}
PVOID DynamicLib::GetSymbol(IN CONST String &name) PVOID DynamicLib::GetSymbol(IN CONST String &name)
{ {
const auto symbol = GetProcAddress(static_cast<HMODULE>(m_moduleHandle), name.c_str()); 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()); THROW_UNKNOWN("DynamicLib: Failed to find the symbol \"", name, "\" with error: ", GetLastError());
return (PVOID) symbol; return (PVOID) symbol;
} }
VOID DynamicLib::Destroy()
{
if (m_moduleHandle)
FreeLibrary(static_cast<HMODULE>(m_moduleHandle));
}
#else #else
DynamicLib DynamicLib::Load(IN CONST String &searchPath, IN CONST String &name) DynamicLib DynamicLib::Load(IN CONST String &searchPath, IN CONST String &name)
{ {
@ -89,12 +95,6 @@ namespace ia
return DynamicLib((PVOID) handle); return DynamicLib((PVOID) handle);
} }
DynamicLib::~DynamicLib()
{
if (m_moduleHandle)
dlclose(m_moduleHandle);
}
PVOID DynamicLib::GetSymbol(IN CONST String &name) PVOID DynamicLib::GetSymbol(IN CONST String &name)
{ {
dlerror(); dlerror();
@ -102,7 +102,13 @@ namespace ia
const char *dlsym_error = dlerror(); const char *dlsym_error = dlerror();
if (dlsym_error) if (dlsym_error)
THROW_UNKNOWN("DynamicLib: Failed to find the symbol \"", name, "\" with error: ", dlerror()); 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 #endif
} // namespace ia } // namespace ia