mirror of
https://github.com/matrix-construct/construct
synced 2025-03-16 22:41:46 +01:00
ircd::mods: Add sym_ptr / import_shared reference ctors.
This commit is contained in:
parent
797142f710
commit
0569b41f4b
2 changed files with 23 additions and 3 deletions
|
@ -156,6 +156,7 @@ class ircd::mods::sym_ptr
|
|||
template<class T> T *operator->();
|
||||
template<class T> T &operator*();
|
||||
|
||||
sym_ptr(module, const std::string &symname);
|
||||
sym_ptr(const std::string &modname, const std::string &symname);
|
||||
~sym_ptr() noexcept;
|
||||
};
|
||||
|
@ -258,15 +259,25 @@ struct ircd::mods::import_shared
|
|||
operator const T &() const { return std::shared_ptr<T>::operator*(); }
|
||||
operator T &() { return std::shared_ptr<T>::operator*(); }
|
||||
|
||||
import_shared(module, const std::string &symname);
|
||||
import_shared(const std::string &modname, const std::string &symname);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
ircd::mods::import_shared<T>::import_shared(const std::string &modname,
|
||||
const std::string &symname)
|
||||
:import_shared
|
||||
{
|
||||
module(modname), symname
|
||||
}
|
||||
{}
|
||||
|
||||
template<class T>
|
||||
ircd::mods::import_shared<T>::import_shared(module module,
|
||||
const std::string &symname)
|
||||
:import<std::shared_ptr<T>>
|
||||
{
|
||||
modname, symname
|
||||
module, symname
|
||||
}
|
||||
,std::shared_ptr<T>
|
||||
{
|
||||
|
|
13
ircd/mods.cc
13
ircd/mods.cc
|
@ -386,11 +386,20 @@ const
|
|||
|
||||
ircd::mods::sym_ptr::sym_ptr(const std::string &modname,
|
||||
const std::string &symname)
|
||||
:sym_ptr
|
||||
{
|
||||
module(modname), symname
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
ircd::mods::sym_ptr::sym_ptr(module module,
|
||||
const std::string &symname)
|
||||
:std::weak_ptr<mod>
|
||||
{
|
||||
module(modname)
|
||||
module
|
||||
}
|
||||
,ptr{[this, &modname, &symname]
|
||||
,ptr{[this, &symname]
|
||||
{
|
||||
const life_guard<mods::mod> mod{*this};
|
||||
const auto &mangled(mod->mangle(symname));
|
||||
|
|
Loading…
Add table
Reference in a new issue