mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 05:50:32 +05:00
fix archive version for pickling
This commit is contained in:
parent
fd3474f5cb
commit
8e53eb46bb
@ -97,23 +97,21 @@ namespace ngcore
|
|||||||
{
|
{
|
||||||
const bool is_output;
|
const bool is_output;
|
||||||
// how many different shared_ptr/pointer have been (un)archived
|
// how many different shared_ptr/pointer have been (un)archived
|
||||||
int shared_ptr_count, ptr_count;
|
int shared_ptr_count{0}, ptr_count{0};
|
||||||
// maps for archived shared pointers and pointers
|
// maps for archived shared pointers and pointers
|
||||||
std::map<void*, int> shared_ptr2nr, ptr2nr;
|
std::map<void*, int> shared_ptr2nr{}, ptr2nr{};
|
||||||
// vectors for storing the unarchived (shared) pointers
|
// vectors for storing the unarchived (shared) pointers
|
||||||
std::vector<std::shared_ptr<void>> nr2shared_ptr;
|
std::vector<std::shared_ptr<void>> nr2shared_ptr{};
|
||||||
std::vector<void*> nr2ptr;
|
std::vector<void*> nr2ptr{};
|
||||||
protected:
|
protected:
|
||||||
bool shallow_to_python = false;
|
bool shallow_to_python = false;
|
||||||
// version map is only used in InArchives
|
std::map<std::string, VersionInfo> version_map = GetLibraryVersions();
|
||||||
std::map<std::string, VersionInfo> version_map;
|
std::shared_ptr<spdlog::logger> logger = GetLogger("Archive");
|
||||||
std::shared_ptr<spdlog::logger> logger;
|
|
||||||
public:
|
public:
|
||||||
Archive() = delete;
|
Archive() = delete;
|
||||||
Archive(const Archive&) = delete;
|
Archive(const Archive&) = delete;
|
||||||
Archive(Archive&&) = delete;
|
Archive(Archive&&) = delete;
|
||||||
Archive (bool ais_output) : is_output(ais_output), shared_ptr_count(0),
|
Archive (bool ais_output) : is_output(ais_output) { ; }
|
||||||
ptr_count(0), logger(GetLogger("Archive")) { ; }
|
|
||||||
|
|
||||||
virtual ~Archive() { ; }
|
virtual ~Archive() { ; }
|
||||||
|
|
||||||
@ -152,8 +150,8 @@ namespace ngcore
|
|||||||
|
|
||||||
bool Output () const { return is_output; }
|
bool Output () const { return is_output; }
|
||||||
bool Input () const { return !is_output; }
|
bool Input () const { return !is_output; }
|
||||||
virtual const VersionInfo& GetVersion(const std::string& library)
|
const VersionInfo& GetVersion(const std::string& library)
|
||||||
{ return GetLibraryVersions()[library]; }
|
{ return version_map[library]; }
|
||||||
|
|
||||||
// Pure virtual functions that have to be implemented by In-/OutArchive
|
// Pure virtual functions that have to be implemented by In-/OutArchive
|
||||||
virtual Archive & operator & (double & d) = 0;
|
virtual Archive & operator & (double & d) = 0;
|
||||||
@ -166,7 +164,7 @@ namespace ngcore
|
|||||||
virtual Archive & operator & (std::string & str) = 0;
|
virtual Archive & operator & (std::string & str) = 0;
|
||||||
virtual Archive & operator & (char *& str) = 0;
|
virtual Archive & operator & (char *& str) = 0;
|
||||||
|
|
||||||
virtual Archive & operator & (VersionInfo & version)
|
Archive & operator & (VersionInfo & version)
|
||||||
{
|
{
|
||||||
if(Output())
|
if(Output())
|
||||||
(*this) << version.to_string();
|
(*this) << version.to_string();
|
||||||
@ -706,9 +704,6 @@ namespace ngcore
|
|||||||
BinaryInArchive (const std::string& filename)
|
BinaryInArchive (const std::string& filename)
|
||||||
: BinaryInArchive(std::make_shared<std::ifstream>(filename)) { ; }
|
: BinaryInArchive(std::make_shared<std::ifstream>(filename)) { ; }
|
||||||
|
|
||||||
const VersionInfo& GetVersion(const std::string& library) override
|
|
||||||
{ return version_map[library]; }
|
|
||||||
|
|
||||||
using Archive::operator&;
|
using Archive::operator&;
|
||||||
Archive & operator & (double & d) override
|
Archive & operator & (double & d) override
|
||||||
{ Read(d); return *this; }
|
{ Read(d); return *this; }
|
||||||
@ -824,9 +819,6 @@ namespace ngcore
|
|||||||
TextInArchive (const std::string& filename)
|
TextInArchive (const std::string& filename)
|
||||||
: TextInArchive(std::make_shared<std::ifstream>(filename)) {}
|
: TextInArchive(std::make_shared<std::ifstream>(filename)) {}
|
||||||
|
|
||||||
const VersionInfo& GetVersion(const std::string& library) override
|
|
||||||
{ return version_map[library]; }
|
|
||||||
|
|
||||||
using Archive::operator&;
|
using Archive::operator&;
|
||||||
Archive & operator & (double & d) override
|
Archive & operator & (double & d) override
|
||||||
{ *stream >> d; return *this; }
|
{ *stream >> d; return *this; }
|
||||||
@ -918,6 +910,7 @@ namespace ngcore
|
|||||||
lst.append(pybind11::bytes(std::static_pointer_cast<std::stringstream>(stream)->str()));
|
lst.append(pybind11::bytes(std::static_pointer_cast<std::stringstream>(stream)->str()));
|
||||||
stream = std::make_shared<std::stringstream>();
|
stream = std::make_shared<std::stringstream>();
|
||||||
*this & GetLibraryVersions();
|
*this & GetLibraryVersions();
|
||||||
|
lst.append(pybind11::bytes(std::static_pointer_cast<std::stringstream>(stream)->str()));
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user