mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
Merge branch 'fix_nopython' into 'master'
Fix non-Python builds See merge request jschoeberl/netgen!307
This commit is contained in:
commit
3fc52396b0
@ -33,6 +33,11 @@ namespace ngcore
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
void Archive :: RemoveArchiveRegister(const std::string& classname)
|
||||||
|
{
|
||||||
|
if(IsRegistered(classname))
|
||||||
|
type_register->erase(classname);
|
||||||
|
}
|
||||||
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 =
|
||||||
|
@ -124,8 +124,18 @@ namespace ngcore
|
|||||||
// once and put them together correctly afterwards. Therefore all objects that may live in
|
// once and put them together correctly afterwards. Therefore all objects that may live in
|
||||||
// Python should be archived using this Shallow function. If Shallow is called from C++ code
|
// Python should be archived using this Shallow function. If Shallow is called from C++ code
|
||||||
// it archives the object normally.
|
// it archives the object normally.
|
||||||
|
#ifdef NETGEN_PYTHON
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Archive& Shallow(T& val); // implemented in python_ngcore.hpp
|
Archive& Shallow(T& val); // implemented in python_ngcore.hpp
|
||||||
|
#else // NETGEN_PYTHON
|
||||||
|
template<typename T>
|
||||||
|
Archive& Shallow(T& val)
|
||||||
|
{
|
||||||
|
static_assert(detail::is_any_pointer<T>, "ShallowArchive must be given pointer type!");
|
||||||
|
*this & val;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif // NETGEN_PYTHON
|
||||||
|
|
||||||
#ifdef NETGEN_PYTHON
|
#ifdef NETGEN_PYTHON
|
||||||
virtual void ShallowOutPython(const pybind11::object& /*unused*/)
|
virtual void ShallowOutPython(const pybind11::object& /*unused*/)
|
||||||
@ -572,6 +582,7 @@ namespace ngcore
|
|||||||
// Set ClassArchiveInfo for Demangled typeid, this is done by creating an instance of
|
// Set ClassArchiveInfo for Demangled typeid, this is done by creating an instance of
|
||||||
// RegisterClassForArchive<type, bases...>
|
// RegisterClassForArchive<type, bases...>
|
||||||
static void SetArchiveRegister(const std::string& classname, const detail::ClassArchiveInfo& info);
|
static void SetArchiveRegister(const std::string& classname, const detail::ClassArchiveInfo& info);
|
||||||
|
static void RemoveArchiveRegister(const std::string& classname);
|
||||||
static bool IsRegistered(const std::string& classname);
|
static bool IsRegistered(const std::string& classname);
|
||||||
|
|
||||||
// Helper class for up-/downcasting
|
// Helper class for up-/downcasting
|
||||||
@ -638,6 +649,10 @@ namespace ngcore
|
|||||||
{ return typeid(T) == ti ? p : Archive::Caster<T, Bases...>::tryDowncast(ti, p); };
|
{ return typeid(T) == ti ? p : Archive::Caster<T, Bases...>::tryDowncast(ti, p); };
|
||||||
Archive::SetArchiveRegister(std::string(Demangle(typeid(T).name())),info);
|
Archive::SetArchiveRegister(std::string(Demangle(typeid(T).name())),info);
|
||||||
}
|
}
|
||||||
|
~RegisterClassForArchive()
|
||||||
|
{
|
||||||
|
Archive::RemoveArchiveRegister(std::string(Demangle(typeid(T).name())));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user