mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 04:50:34 +05:00
Template archive
This commit is contained in:
parent
ecd077f154
commit
71c9b9b9f1
@ -131,6 +131,9 @@ namespace ngcore
|
||||
std::map<std::string, VersionInfo> version_map = GetLibraryVersions();
|
||||
std::shared_ptr<Logger> logger = GetLogger("Archive");
|
||||
public:
|
||||
template<typename T>
|
||||
static constexpr bool is_archivable = detail::is_Archivable_struct<T>::value;
|
||||
|
||||
Archive() = delete;
|
||||
Archive(const Archive&) = delete;
|
||||
Archive(Archive&&) = delete;
|
||||
|
@ -7,9 +7,13 @@
|
||||
/* Date: 01. Jun. 95 */
|
||||
/**************************************************************************/
|
||||
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
#include "archive.hpp"
|
||||
#include "exception.hpp"
|
||||
#include "logging.hpp" // for logger
|
||||
#include "ngcore_api.hpp" // for NGCORE_API
|
||||
#include "type_traits.hpp" // for all_of_tmpl
|
||||
#include "localheap.hpp"
|
||||
#include "memtracer.hpp"
|
||||
#include "utils.hpp"
|
||||
@ -500,7 +504,8 @@ namespace ngcore
|
||||
return *this;
|
||||
}
|
||||
|
||||
NETGEN_INLINE const FlatArray & operator= (const std::function<T(int)> & func) const
|
||||
template <typename T2, std::enable_if_t<std::is_function<T2>::value>>
|
||||
NETGEN_INLINE const FlatArray & operator= (const T2 & func) const
|
||||
{
|
||||
for (size_t i = 0; i < size; i++)
|
||||
data[i] = func(i+BASE);
|
||||
@ -806,8 +811,9 @@ namespace ngcore
|
||||
}
|
||||
|
||||
// Only provide this function if T is archivable
|
||||
template<typename T2=T>
|
||||
auto DoArchive(Archive& archive) -> typename std::enable_if_t<is_archivable<T2>, void>
|
||||
template<typename ARCHIVE>
|
||||
auto DoArchive(ARCHIVE& archive)
|
||||
-> typename std::enable_if_t<ARCHIVE::template is_archivable<T>, void>
|
||||
{
|
||||
if(archive.Output())
|
||||
archive << size;
|
||||
|
@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "bitarray.hpp"
|
||||
#include "archive.hpp"
|
||||
|
||||
namespace ngcore
|
||||
{
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <cstring>
|
||||
#include <ostream>
|
||||
|
||||
#include "archive.hpp"
|
||||
#include "array.hpp"
|
||||
#include "localheap.hpp"
|
||||
#include "ngcore_api.hpp"
|
||||
@ -147,7 +146,7 @@ public:
|
||||
|
||||
NGCORE_API size_t NumSet () const;
|
||||
|
||||
NGCORE_API void DoArchive(Archive& archive);
|
||||
NGCORE_API void DoArchive(class Archive& archive);
|
||||
|
||||
NGCORE_API auto * Data() const { return data; }
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
/* Date: 10. Oct. 96 */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "archive.hpp"
|
||||
#include "flags.hpp"
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -58,7 +58,7 @@ namespace ngcore
|
||||
Flags & operator= (const Flags & f2) = default;
|
||||
Flags & operator= (Flags && f2) = default;
|
||||
|
||||
void DoArchive(Archive& ar);
|
||||
void DoArchive(class Archive& ar);
|
||||
|
||||
void Update(const Flags& other);
|
||||
|
||||
|
@ -76,7 +76,7 @@ namespace ngcore
|
||||
NETGEN_INLINE INT (T ai1, T ai2, T ai3, T ai4, T ai5, T ai6, T ai7, T ai8, T ai9)
|
||||
: i{ai1, ai2, ai3, ai4, ai5, ai6, ai7, ai8, ai9 } { ; }
|
||||
|
||||
void DoArchive(Archive& ar)
|
||||
void DoArchive(class Archive& ar)
|
||||
{
|
||||
ar.Do(i, N);
|
||||
}
|
||||
@ -1067,15 +1067,6 @@ namespace ngcore
|
||||
return ost;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <int N, typename T>
|
||||
Archive & operator & (Archive & archive, INT<N,T> & mi)
|
||||
{
|
||||
for (int i = 0; i < N; i++)
|
||||
archive & mi[i];
|
||||
return archive;
|
||||
}
|
||||
} // namespace ngcore
|
||||
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "array.hpp"
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <type_traits>
|
||||
#include <functional>
|
||||
#include <tuple>
|
||||
#include <cmath>
|
||||
|
||||
#include "array.hpp"
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "archive.hpp"
|
||||
#include "exception.hpp"
|
||||
#include "ngcore_api.hpp"
|
||||
|
||||
@ -38,8 +37,9 @@ namespace ngcore
|
||||
SymbolTable& operator=(const SymbolTable<T>&) = default;
|
||||
SymbolTable& operator=(SymbolTable<T>&&) = default;
|
||||
|
||||
template<typename T2=T>
|
||||
auto DoArchive(Archive& ar) -> typename std::enable_if_t<is_archivable<T2>>
|
||||
template<typename ARCHIVE>
|
||||
auto DoArchive(ARCHIVE& ar)
|
||||
-> typename std::enable_if_t<ARCHIVE::template is_archivable<T>, void>
|
||||
{
|
||||
ar & names & data;
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "memtracer.hpp"
|
||||
#include "ngcore_api.hpp"
|
||||
#include "profiler.hpp"
|
||||
#include "taskmanager.hpp"
|
||||
|
||||
namespace ngcore
|
||||
{
|
||||
@ -189,7 +188,8 @@ namespace ngcore
|
||||
Swap (data, tab2.data);
|
||||
}
|
||||
|
||||
void DoArchive(Archive& ar)
|
||||
template<typename ARCHIVE>
|
||||
auto DoArchive(ARCHIVE& ar)
|
||||
{
|
||||
ar & size;
|
||||
if(size == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user