15 #ifndef SERIALBOX_CORE_FRONTEND_GRIDTOOLS_SERIALIZER_H 16 #define SERIALBOX_CORE_FRONTEND_GRIDTOOLS_SERIALIZER_H 115 std::string
directory() const noexcept {
return serializerImpl_->directory().string(); }
118 std::string
prefix() const noexcept {
return serializerImpl_->prefix(); }
121 std::string
meta_data_file() const noexcept {
return serializerImpl_->metaDataFile().string(); }
124 std::string
archive_name() const noexcept {
return serializerImpl_->archiveName(); }
129 void clear() noexcept { serializerImpl_->clear(); }
148 template <
class StringType,
class ValueType>
150 serializerImpl_->addGlobalMetainfo(std::forward<StringType>(key),
151 std::forward<ValueType>(value));
160 template <
class T,
class StringType>
162 return serializerImpl_->getGlobalMetainfoAs<T>(std::forward<StringType>(key));
180 template <
class StringType,
typename... Args>
182 serializerImpl_->registerField(std::forward<StringType>(name),
190 template <
class StringType>
192 return serializerImpl_->hasField(std::forward<StringType>(name));
203 template <
class StringType,
class KeyType,
class ValueType>
205 return serializerImpl_->addFieldMetainfoImpl(
206 std::forward<StringType>(name), std::forward<KeyType>(key), std::forward<ValueType>(value));
214 template <
class StringType>
217 serializerImpl_->fieldMap().getFieldMetainfoImplPtrOf(std::forward<StringType>(name)));
222 std::vector<std::string>
fieldnames()
const {
return serializerImpl_->fieldnames(); }
232 template <
typename... Args>
234 return serializerImpl_->registerSavepoint(*
savepoint(std::forward<Args>(args)...).impl());
241 template <
typename... Args>
243 return serializerImpl_->savepointVector().exists(*sp.impl());
248 const auto&
savepoints = serializerImpl_->savepointVector().savepoints();
249 if(!savepoints_ || (
savepoints.size() != savepoints_->size())) {
250 savepoints_ = std::make_shared<std::vector<savepoint>>();
251 for(std::size_t i = 0; i <
savepoints.size(); ++i)
272 template <
class StorageType>
273 void write(
const std::string& name,
const savepoint& sp,
const StorageType& storage,
280 std::move(internal::get_dims(storage)), std::move(internal::get_strides(storage)));
281 serializerImpl_->write(name, *sp.
impl(), storageView);
297 const std::vector<int>& strides) {
300 serializerImpl_->write(name, *sp.
impl(), storageView);
312 template <
class StorageType>
316 std::move(internal::get_dims(storage)), std::move(internal::get_strides(storage)));
338 template <
class StorageType>
339 void read(
const std::string& name,
const savepoint& sp, StorageType& storage) {
342 std::move(internal::get_dims(storage)), std::move(internal::get_strides(storage)));
344 serializerImpl_->read(name, *sp.
impl(), storageView);
360 template <
class StorageType>
364 std::move(internal::get_dims(storage)), std::move(internal::get_strides(storage)));
366 serializerImpl_->read(name, *sp.
impl(), storageView);
382 const std::vector<int>& strides) {
385 serializerImpl_->read(name, *sp.
impl(), storageView);
398 template <
class StorageType>
402 std::move(internal::get_dims(storage)), std::move(internal::get_strides(storage)));
411 std::string
to_string()
const {
return serializerImpl_->toString(); }
415 return (stream << *s.serializerImpl_);
419 std::shared_ptr<SerializerImpl> serializerImpl_;
420 std::shared_ptr<std::vector<savepoint>> savepoints_;
static std::string archiveFromExtension(std::string filename)
Deduce the name of the archive according to the extension of the filename
static int serializationStatus() noexcept
Get the status of serialization.
Represent a mutable view to a multi-dimensional storage.
void setSlice(Slice slice)
Set the slice of the StorageView
Namespace of the serialbox library.
static void disableSerialization() noexcept
Disable serialization.
Shared implementation of the Serializer.
static void readFromFile(std::string filename, StorageView &storageView, std::string archiveName, std::string fieldname)
Directly read field (given by storageView) from file.
static void writeToFile(std::string filename, const StorageView &storageView, std::string archiveName, std::string fieldname)
Directly write field (given by storageView) to file.
OpenModeKind
Policy for opening files in the Serializer and Archive.
static void enableSerialization() noexcept
Enable serialization.
Convert C++ type T to TypeID.
Specification of the slice indices which is used for partial loading of serialized data...