Some dll header

This commit is contained in:
Matthias Hochsteger 2018-12-12 17:45:06 +01:00
parent 835b2703f4
commit c48663d708
2 changed files with 26 additions and 23 deletions

View File

@ -21,11 +21,11 @@
namespace ngcore namespace ngcore
{ {
// Libraries using this archive can store their version here to implement backwards compatibility // Libraries using this archive can store their version here to implement backwards compatibility
const VersionInfo& GetLibraryVersion(const std::string& library); NGCORE_API const VersionInfo& GetLibraryVersion(const std::string& library);
void SetLibraryVersion(const std::string& library, const VersionInfo& version); NGCORE_API void SetLibraryVersion(const std::string& library, const VersionInfo& version);
NGCORE_API std::string Demangle(const char* typeinfo);
class NGCORE_API Archive; class NGCORE_API Archive;
NGCORE_API std::string Demangle(const char* typeinfo);
namespace detail namespace detail
{ {
@ -99,22 +99,6 @@ namespace ngcore
std::vector<std::shared_ptr<void>> nr2shared_ptr; std::vector<std::shared_ptr<void>> nr2shared_ptr;
std::vector<void*> nr2ptr; std::vector<void*> nr2ptr;
// Helper class for up-/downcasting
template<typename T, typename ... Bases>
struct Caster
{
static void* tryUpcast(const std::type_info& ti, T* p);
static void* tryDowncast(const std::type_info& ti, void* p);
};
template<typename T, typename ... Bases>
friend class RegisterClassForArchive;
// Returns ClassArchiveInfo of Demangled typeid
static const detail::ClassArchiveInfo& GetArchiveRegister(const std::string& classname);
// Set ClassArchiveInfo for Demangled typeid, this is done by creating an instance of
// RegisterClassForArchive<type, bases...>
static void SetArchiveRegister(const std::string& classname, const detail::ClassArchiveInfo& info);
static bool IsRegistered(const std::string& classname);
public: public:
Archive() = delete; Archive() = delete;
Archive(const Archive&) = delete; Archive(const Archive&) = delete;
@ -455,7 +439,22 @@ namespace ngcore
protected: protected:
static std::map<std::string, VersionInfo>& GetLibraryVersions(); static std::map<std::string, VersionInfo>& GetLibraryVersions();
private: private:
template<typename T, typename ... Bases>
friend class RegisterClassForArchive;
// Returns ClassArchiveInfo of Demangled typeid
static const detail::ClassArchiveInfo& GetArchiveRegister(const std::string& classname);
// Set ClassArchiveInfo for Demangled typeid, this is done by creating an instance of
// RegisterClassForArchive<type, bases...>
static void SetArchiveRegister(const std::string& classname, const detail::ClassArchiveInfo& info);
static bool IsRegistered(const std::string& classname);
// Helper class for up-/downcasting
template<typename T, typename ... Bases>
struct Caster{};
template<typename T> template<typename T>
struct Caster<T> struct Caster<T>
{ {
@ -504,7 +503,7 @@ namespace ngcore
public: public:
RegisterClassForArchive() RegisterClassForArchive()
{ {
static_assert(all_of_tmpl<std::is_base_of<Bases,T>::value...>, static_assert(detail::all_of_tmpl<std::is_base_of<Bases,T>::value...>,
"Variadic template arguments must be base classes of T"); "Variadic template arguments must be base classes of T");
detail::ClassArchiveInfo info; detail::ClassArchiveInfo info;
info.creator = [this,&info](const std::type_info& ti) -> void* info.creator = [this,&info](const std::type_info& ti) -> void*

View File

@ -5,9 +5,13 @@
namespace ngcore namespace ngcore
{ {
namespace detail
{
template<bool... b> struct _BoolArray{}; template<bool... b> struct _BoolArray{};
template<bool ... vals> template<bool ... vals>
constexpr bool all_of_tmpl = std::is_same<_BoolArray<vals...>, _BoolArray<(vals || true)...>>::value; // NOLINT constexpr bool all_of_tmpl = std::is_same<_BoolArray<vals...>, _BoolArray<(vals || true)...>>::value; // NOLINT
} // namespace detail
} // namespace ngcore } // namespace ngcore
#endif // NETGEN_LIBSRC_CORE_TYPE_TRAITS_HPP #endif // NETGEN_LIBSRC_CORE_TYPE_TRAITS_HPP