mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-13 14:40:35 +05:00
function-pointer instead of std::function, no unique-ptr around type_register
This commit is contained in:
parent
8362349bb8
commit
fda7cfa2bc
@ -10,24 +10,24 @@
|
|||||||
namespace ngcore
|
namespace ngcore
|
||||||
{
|
{
|
||||||
// clang-tidy should ignore this static object
|
// clang-tidy should ignore this static object
|
||||||
static std::unique_ptr<std::map<std::string, detail::ClassArchiveInfo>> type_register; // NOLINT
|
static std::map<std::string, detail::ClassArchiveInfo> type_register; // NOLINT
|
||||||
const detail::ClassArchiveInfo& Archive :: GetArchiveRegister(const std::string& classname)
|
const detail::ClassArchiveInfo& Archive :: GetArchiveRegister(const std::string& classname)
|
||||||
{
|
{
|
||||||
if(type_register == nullptr) type_register =
|
// if(type_register == nullptr) type_register =
|
||||||
std::make_unique<std::map<std::string, detail::ClassArchiveInfo>>();
|
// std::make_unique<std::map<std::string, detail::ClassArchiveInfo>>();
|
||||||
return (*type_register)[classname];
|
return (type_register)[classname];
|
||||||
}
|
}
|
||||||
void Archive :: SetArchiveRegister(const std::string& classname, const detail::ClassArchiveInfo& info)
|
void Archive :: SetArchiveRegister(const std::string& classname, const detail::ClassArchiveInfo& info)
|
||||||
{
|
{
|
||||||
if(type_register == nullptr) type_register =
|
// if(type_register == nullptr) type_register =
|
||||||
std::make_unique<std::map<std::string, detail::ClassArchiveInfo>>();
|
// std::make_unique<std::map<std::string, detail::ClassArchiveInfo>>();
|
||||||
(*type_register)[classname] = info;
|
(type_register)[classname] = info;
|
||||||
}
|
}
|
||||||
bool Archive :: IsRegistered(const std::string& classname)
|
bool Archive :: IsRegistered(const std::string& classname)
|
||||||
{
|
{
|
||||||
if(type_register == nullptr) type_register =
|
// if(type_register == nullptr) type_register =
|
||||||
std::make_unique<std::map<std::string, detail::ClassArchiveInfo>>();
|
// std::make_unique<std::map<std::string, detail::ClassArchiveInfo>>();
|
||||||
return type_register->count(classname) != 0;
|
return type_register.count(classname) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NETGEN_PYTHON
|
#ifdef NETGEN_PYTHON
|
||||||
|
@ -150,7 +150,8 @@ namespace ngcore
|
|||||||
void* (*downcaster)(const std::type_info&, void*);
|
void* (*downcaster)(const std::type_info&, void*);
|
||||||
|
|
||||||
// Archive constructor arguments
|
// Archive constructor arguments
|
||||||
std::function<void(Archive&, void*)> cargs_archiver;
|
// std::function<void(Archive&, void*)> cargs_archiver;
|
||||||
|
void (*cargs_archiver)(Archive&, void*);
|
||||||
|
|
||||||
#ifdef NETGEN_PYTHON
|
#ifdef NETGEN_PYTHON
|
||||||
// std::function<pybind11::object(const std::any&)> anyToPyCaster;
|
// std::function<pybind11::object(const std::any&)> anyToPyCaster;
|
||||||
|
Loading…
Reference in New Issue
Block a user