0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-03 06:08:52 +02:00

ircd::mods: Add sym_ptr / import_shared reference ctors.

This commit is contained in:
Jason Volk 2018-02-22 13:47:55 -08:00
parent 797142f710
commit 0569b41f4b
2 changed files with 23 additions and 3 deletions

View file

@ -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>
{

View file

@ -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));