Serialbox  2.2.0
Data serialization library and tools for C/C++, Python and Fortran
Serializer.cpp
1 /*===-- serialbox-c/Serializer.cpp --------------------------------------------------*- C++ -*-===*\
2  *
3  * S E R I A L B O X
4  *
5  * This file is distributed under terms of BSD license.
6  * See LICENSE.txt for more information
7  *
8  *===------------------------------------------------------------------------------------------===//
9  *
10  *! \file
11  *! This file contains C implementation of the Serializer.
12  *
13 \*===------------------------------------------------------------------------------------------===*/
14 
15 #include "serialbox-c/Serializer.h"
16 #include "serialbox-c/FieldMetainfo.h"
17 #include "serialbox-c/Logging.h"
18 #include "serialbox-c/Metainfo.h"
19 #include "serialbox-c/Savepoint.h"
20 #include "serialbox-c/Utility.h"
22 #include "serialbox/core/Logging.h"
24 #include "serialbox/core/Slice.h"
28 
29 using namespace serialboxC;
30 
31 namespace {
32 
33 template <class VecType>
34 static std::string vecToString(VecType&& vec) {
35  std::stringstream ss;
36  if(!vec.empty()) {
37  for(std::size_t i = 0; i < vec.size() - 1; ++i)
38  ss << vec[i] << ", ";
39  ss << vec.back();
40  }
41  return ss.str();
42 }
43 
44 std::vector<int> make_dims(int iSize, int jSize, int kSize, int lSize) {
45  std::vector<int> dims;
46  if(iSize > 0)
47  dims.push_back(iSize);
48  if(jSize > 0)
49  dims.push_back(jSize);
50  if(kSize > 0)
51  dims.push_back(kSize);
52  if(lSize > 0)
53  dims.push_back(lSize);
54  return dims;
55 }
56 }
57 
58 /*===------------------------------------------------------------------------------------------===*\
59  * Construction & Destruction
60 \*===------------------------------------------------------------------------------------------===*/
61 
62 serialboxSerializer_t* serialboxSerializerCreate(int mode, const char* directory,
63  const char* prefix, const char* archive) {
64  serialboxSerializer_t* serializer = allocate<serialboxSerializer_t>();
65 
66  try {
67  switch(mode) {
68  case Read:
69  serializer->impl = new Serializer(serialbox::OpenModeKind::Read, directory, prefix, archive);
70  break;
71  case Write:
72  serializer->impl = new Serializer(serialbox::OpenModeKind::Write, directory, prefix, archive);
73  break;
74  case Append:
75  serializer->impl =
76  new Serializer(serialbox::OpenModeKind::Append, directory, prefix, archive);
77  break;
78  default:
79  serialbox_unreachable((boost::format("invalid mode (%i)") % mode).str().c_str());
80  }
81  serializer->ownsData = 1;
82  } catch(std::exception& e) {
83  std::free(serializer);
84  serializer = NULL;
85  serialboxFatalError(e.what());
86  }
87  return serializer;
88 }
89 
91  if(serializer) {
92  Serializer* ser = toSerializer(serializer);
93  if(serializer->ownsData)
94  delete ser;
95  std::free(serializer);
96  }
97 }
98 
99 /*===------------------------------------------------------------------------------------------===*\
100  * Utility
101 \*===------------------------------------------------------------------------------------------===*/
102 
104  const Serializer* ser = toConstSerializer(serializer);
105  return static_cast<int>(ser->mode());
106 }
107 
109  const Serializer* ser = toConstSerializer(serializer);
110  return allocateAndCopyString(ser->directory().native());
111 }
112 
114  const Serializer* ser = toConstSerializer(serializer);
115  return allocateAndCopyString(ser->prefix());
116 }
117 
119  Serializer* ser = toSerializer(serializer);
120  try {
121  ser->updateMetaData();
122  } catch(std::exception& e) {
123  serialboxFatalError(e.what());
124  }
125 }
126 
127 int serialboxSerializationStatus(void) { return Serializer::serializationStatus(); }
128 
129 void serialboxEnableSerialization(void) { Serializer::enableSerialization(); }
130 
131 void serialboxDisableSerialization(void) { Serializer::disableSerialization(); }
132 
134  const Serializer* ser = toConstSerializer(serializer);
135  std::stringstream ss;
136  ss << *ser;
137  return allocateAndCopyString(ss.str());
138 }
139 
140 /*===------------------------------------------------------------------------------------------===*\
141  * Global Meta-information
142 \*===------------------------------------------------------------------------------------------===*/
143 
145  Serializer* ser = toSerializer(serializer);
146  serialboxMetainfo_t* metaInfo = allocate<serialboxMetainfo_t>();
147  metaInfo->impl = ser->globalMetainfoPtr().get();
148  metaInfo->ownsData = 0;
149  return metaInfo;
150 }
151 
152 /*===------------------------------------------------------------------------------------------===*\
153  * Register and Query Savepoints
154 \*===------------------------------------------------------------------------------------------===*/
155 
157  const serialboxSavepoint_t* savepoint) {
158  const Savepoint* sp = toConstSavepoint(savepoint);
159  Serializer* ser = toSerializer(serializer);
160  return ser->registerSavepoint(*sp);
161 }
162 
164  const serialboxSavepoint_t* savepoint) {
165  const Savepoint* sp = toConstSavepoint(savepoint);
166  const Serializer* ser = toConstSerializer(serializer);
167  return ser->savepointVector().exists(*sp);
168 }
169 
171  const Serializer* ser = toConstSerializer(serializer);
172  return (int)ser->savepointVector().size();
173 }
174 
177  const Serializer* ser = toConstSerializer(serializer);
178  const auto& savepointVector = ser->savepointVector().savepoints();
179 
180  serialboxSavepoint_t** savepoints = allocate<serialboxSavepoint_t*>(savepointVector.size());
181 
182  if(!savepoints)
183  serialboxFatalError("out of memory");
184 
185  for(std::size_t i = 0; i < savepointVector.size(); ++i) {
186  serialboxSavepoint_t* savepoint = allocate<serialboxSavepoint_t>();
187  savepoint->impl = savepointVector[i].get();
188  savepoint->ownsData = 0;
189  savepoints[i] = savepoint;
190  }
191 
192  return savepoints;
193 }
194 
196  for(int i = 0; i < len; ++i)
197  std::free(savepointVector[i]);
198  std::free(savepointVector);
199 }
200 
203  const serialboxSavepoint_t* savepoint) {
204  const Savepoint* sp = toConstSavepoint(savepoint);
205  const Serializer* ser = toConstSerializer(serializer);
206  serialboxArrayOfString_t* array = NULL;
207 
208  try {
209  const auto& fieldnameMap = ser->savepointVector().fieldsOf(*sp);
210  array = serialboxArrayOfStringCreate(fieldnameMap.size());
211 
212  int i = 0;
213  for(auto it = fieldnameMap.begin(), end = fieldnameMap.end(); it != end; ++it, ++i)
214  array->data[i] = allocateAndCopyString(it->first);
215 
216  } catch(std::exception& e) {
217  serialboxFatalError(e.what());
218  }
219  return array;
220 }
221 
222 /*===------------------------------------------------------------------------------------------===*\
223  * Register and Query Fields
224 \*===------------------------------------------------------------------------------------------===*/
225 
226 int serialboxSerializerAddField(serialboxSerializer_t* serializer, const char* name,
227  const serialboxFieldMetainfo_t* fieldMetainfo) {
228  Serializer* ser = toSerializer(serializer);
229  const FieldMetainfo* info = toConstFieldMetainfo(fieldMetainfo);
230 
231  try {
232  ser->registerField(name, *info);
233  } catch(std::exception& e) {
234  LOG(warning) << e.what();
235  return 0;
236  }
237  return 1;
238 }
239 
240 int serialboxSerializerHasField(serialboxSerializer_t* serializer, const char* field) {
241  Serializer* ser = toSerializer(serializer);
242  return ser->hasField(field);
243 }
244 
245 int serialboxSerializerAddField2(serialboxSerializer_t* serializer, const char* name, int type,
246  int bytesPerElement, int iSize, int jSize, int kSize, int lSize,
247  int iMinusHalo, int iPlusHalo, int jMinusHalo, int jPlusHalo,
248  int kMinusHalo, int kPlusHalo, int lMinusHalo, int lPlusHalo) {
249  Serializer* ser = toSerializer(serializer);
250 
251  try {
252  serialbox::TypeID typeID = static_cast<serialbox::TypeID>((int)type);
253  std::string typeName = serialbox::TypeUtil::toString(typeID);
254 
255  if(bytesPerElement != serialbox::TypeUtil::sizeOf(typeID))
256  throw serialbox::Exception("inconsistent bytes-per-element: got '%i' but according to passed "
257  "type '%s' expected '%i'",
258  bytesPerElement, typeName, serialbox::TypeUtil::sizeOf(typeID));
259 
260  auto dims = ::make_dims(iSize, jSize, kSize, lSize);
261  int rank = dims.size();
262 
263  MetainfoMap metaInfo;
264  metaInfo.insert("__name", name);
265  metaInfo.insert("__elementtype", typeName);
266  metaInfo.insert("__bytesperelement", bytesPerElement);
267  metaInfo.insert("__rank", rank);
268  metaInfo.insert("__isize", iSize);
269  metaInfo.insert("__jsize", jSize);
270  metaInfo.insert("__ksize", kSize);
271  metaInfo.insert("__lsize", lSize);
272  metaInfo.insert("__iminushalosize", iMinusHalo);
273  metaInfo.insert("__iplushalosize", iPlusHalo);
274  metaInfo.insert("__jminushalosize", jMinusHalo);
275  metaInfo.insert("__jplushalosize", jPlusHalo);
276  metaInfo.insert("__kminushalosize", kMinusHalo);
277  metaInfo.insert("__kplushalosize", kPlusHalo);
278  metaInfo.insert("__lminushalosize", lMinusHalo);
279  metaInfo.insert("__lplushalosize", lPlusHalo);
280 
281  FieldMetainfo fieldMetainfo(typeID, dims, metaInfo);
282 
283  // Field was already registered with the same meta-data
284  if(ser->hasField(name) && (ser->getFieldMetainfoImplOf(name) == fieldMetainfo))
285  return 0;
286 
287  ser->registerField(name, fieldMetainfo);
288  } catch(std::exception& e) {
289  serialboxFatalError(e.what());
290  }
291  return 1;
292 }
293 
296 
297  const Serializer* ser = toConstSerializer(serializer);
298  serialboxArrayOfString_t* array = NULL;
299 
300  try {
301  const auto fieldnameVector = ser->fieldnames();
302  array = serialboxArrayOfStringCreate(fieldnameVector.size());
303 
304  for(std::size_t i = 0; i < fieldnameVector.size(); ++i)
305  array->data[i] = allocateAndCopyString(fieldnameVector[i]);
306 
307  } catch(std::exception& e) {
308  serialboxFatalError(e.what());
309  }
310 
311  return array;
312 }
313 
315 serialboxSerializerGetFieldMetainfo(const serialboxSerializer_t* serializer, const char* name) {
316  const Serializer* ser = toConstSerializer(serializer);
317 
318  auto it = ser->fieldMap().findField(name);
319  if(it != ser->fieldMap().end()) {
320  serialboxFieldMetainfo_t* info = allocate<serialboxFieldMetainfo_t>();
321  info->impl = it->second.get();
322  info->ownsData = 0;
323  return info;
324  }
325  return NULL;
326 }
327 
328 void serialboxSerializerGetFieldMetainfo2(const serialboxSerializer_t* serializer, const char* name,
329  char** storedName, char** elementType,
330  int* bytesPerElement, int* rank, int* iSize, int* jSize,
331  int* kSize, int* lSize, int* iMinusHalo, int* iPlusHalo,
332  int* jMinusHalo, int* jPlusHalo, int* kMinusHalo,
333  int* kPlusHalo, int* lMinusHalo, int* lPlusHalo) {
334 
335  try {
336  serialboxFieldMetainfo_t* fieldMetainfo = serialboxSerializerGetFieldMetainfo(serializer, name);
337  serialboxMetainfo_t* metainfo = serialboxFieldMetainfoGetMetainfo(fieldMetainfo);
338 
339  *storedName = serialboxMetainfoGetString(metainfo, "__name");
340  *elementType = serialboxMetainfoGetString(metainfo, "__elementtype");
341  *bytesPerElement = serialboxMetainfoGetInt32(metainfo, "__bytesperelement");
342  *rank = serialboxMetainfoGetInt32(metainfo, "__rank");
343  *iSize = serialboxMetainfoGetInt32(metainfo, "__isize");
344  *jSize = serialboxMetainfoGetInt32(metainfo, "__jsize");
345  *kSize = serialboxMetainfoGetInt32(metainfo, "__ksize");
346  *lSize = serialboxMetainfoGetInt32(metainfo, "__lsize");
347  *iMinusHalo = serialboxMetainfoGetInt32(metainfo, "__iminushalosize");
348  *jMinusHalo = serialboxMetainfoGetInt32(metainfo, "__jminushalosize");
349  *kMinusHalo = serialboxMetainfoGetInt32(metainfo, "__kminushalosize");
350  *lMinusHalo = serialboxMetainfoGetInt32(metainfo, "__lminushalosize");
351  *iPlusHalo = serialboxMetainfoGetInt32(metainfo, "__iplushalosize");
352  *jPlusHalo = serialboxMetainfoGetInt32(metainfo, "__jplushalosize");
353  *kPlusHalo = serialboxMetainfoGetInt32(metainfo, "__kplushalosize");
354  *lPlusHalo = serialboxMetainfoGetInt32(metainfo, "__lplushalosize");
355  } catch(std::exception& e) {
356  serialboxFatalError(e.what());
357  }
358 }
359 
360 /*===------------------------------------------------------------------------------------------===*\
361  * Writing & Reading
362 \*===------------------------------------------------------------------------------------------===*/
363 
364 namespace internal {
365 
366 serialbox::StorageView makeStorageView(Serializer* ser, const char* name, void* originPtr,
367  const int* strides, int numStrides) {
368 
369  // Check if field exists
370  auto it = ser->fieldMap().findField(name);
371  if(it == ser->fieldMap().end())
372  throw serialbox::Exception("field '%s' is not registered within the Serializer", name);
373 
374  // Get necessary meta-information to construct StorageView
375  const auto& dims = it->second->dims();
376  std::vector<int> stridesVec(strides, strides + numStrides);
377 
378  if(dims.size() != stridesVec.size())
379  throw serialbox::Exception("inconsistent number of dimensions and strides of field '%s'"
380  "\nDimensions as: [ %s ]"
381  "\nStrides as: [ %s ]",
382  name, ::vecToString(dims), ::vecToString(stridesVec));
383 
384  return serialbox::StorageView(originPtr, it->second->type(), dims, stridesVec);
385 }
386 
387 } // namespace internal
388 
389 void serialboxSerializerWrite(serialboxSerializer_t* serializer, const char* name,
390  const serialboxSavepoint_t* savepoint, void* originPtr,
391  const int* strides, int numStrides) {
392  Serializer* ser = toSerializer(serializer);
393  const Savepoint* sp = toConstSavepoint(savepoint);
394 
395  try {
396  serialbox::StorageView storageView(
397  internal::makeStorageView(ser, name, originPtr, strides, numStrides));
398  ser->write(name, *sp, storageView);
399  } catch(std::exception& e) {
400  serialboxFatalError(e.what());
401  }
402 }
403 
404 void serialboxSerializerRead(serialboxSerializer_t* serializer, const char* name,
405  const serialboxSavepoint_t* savepoint, void* originPtr,
406  const int* strides, int numStrides) {
407  Serializer* ser = toSerializer(serializer);
408  const Savepoint* sp = toConstSavepoint(savepoint);
409 
410  try {
411  serialbox::StorageView storageView(
412  internal::makeStorageView(ser, name, originPtr, strides, numStrides));
413  ser->read(name, *sp, storageView);
414  } catch(std::exception& e) {
415  serialboxFatalError(e.what());
416  }
417 }
418 
419 void serialboxSerializerReadSliced(serialboxSerializer_t* serializer, const char* name,
420  const serialboxSavepoint_t* savepoint, void* originPtr,
421  const int* strides, int numStrides, const int* slice) {
422  Serializer* ser = toSerializer(serializer);
423  const Savepoint* sp = toConstSavepoint(savepoint);
424 
425  try {
426  serialbox::StorageView storageView(
427  internal::makeStorageView(ser, name, originPtr, strides, numStrides));
428 
430  for(int i = 0; i < numStrides; ++i)
431  sliceObj.sliceTriples().push_back({slice[3 * i], slice[3 * i + 1], slice[3 * i + 2]});
432  storageView.setSlice(sliceObj);
433 
434  ser->read(name, *sp, storageView);
435  } catch(std::exception& e) {
436  serialboxFatalError(e.what());
437  }
438 }
439 
440 void serialboxSerializerReadAsync(serialboxSerializer_t* serializer, const char* name,
441  const serialboxSavepoint_t* savepoint, void* originPtr,
442  const int* strides, int numStrides) {
443  Serializer* ser = toSerializer(serializer);
444  const Savepoint* sp = toConstSavepoint(savepoint);
445 
446  try {
447  serialbox::StorageView storageView(
448  internal::makeStorageView(ser, name, originPtr, strides, numStrides));
449  ser->readAsync(name, *sp, storageView);
450  } catch(std::exception& e) {
451  serialboxFatalError(e.what());
452  }
453 }
454 
456  Serializer* ser = toSerializer(serializer);
457  try {
458  ser->waitForAll();
459  } catch(std::exception& e) {
460  serialboxFatalError(e.what());
461  }
462 }
463 
464 /*===------------------------------------------------------------------------------------------===*\
465  * Stateless Serialization
466 \*===------------------------------------------------------------------------------------------===*/
467 
468 void serialboxWriteToFile(const char* filename, void* originPtr, int typeID, const int* dims,
469  int numDims, const int* strides, const char* fieldname,
470  const char* archivename) {
471 
472  try {
473  std::vector<int> dimsVec(dims, dims + numDims);
474  std::vector<int> stridesVec(strides, strides + numDims);
475  serialbox::StorageView storageView(originPtr, (serialbox::TypeID)typeID, dimsVec, stridesVec);
476 
477  serialbox::ArchiveFactory::writeToFile(filename, storageView, archivename, fieldname);
478  } catch(std::exception& e) {
479  serialboxFatalError(e.what());
480  }
481 }
482 
483 void serialboxReadFromFile(const char* filename, void* originPtr, int typeID, const int* dims,
484  int numDims, const int* strides, const char* fieldname,
485  const char* archivename) {
486 
487  try {
488  std::vector<int> dimsVec(dims, dims + numDims);
489  std::vector<int> stridesVec(strides, strides + numDims);
490  serialbox::StorageView storageView(originPtr, (serialbox::TypeID)typeID, dimsVec, stridesVec);
491 
492  serialbox::ArchiveFactory::readFromFile(filename, storageView, archivename, fieldname);
493  } catch(std::exception& e) {
494  serialboxFatalError(e.what());
495  }
496 }
void serialboxReadFromFile(const char *filename, void *originPtr, int typeID, const int *dims, int numDims, const int *strides, const char *fieldname, const char *archivename)
Deserialize field name (given by originPtr and strides) directly from file.
Definition: Serializer.cpp:483
void serialboxSerializerDestroy(serialboxSerializer_t *serializer)
Destroy the serializer and deallocate all memory.
Definition: Serializer.cpp:90
int serialboxSerializerGetNumSavepoints(const serialboxSerializer_t *serializer)
Get number of registered savepoints.
Definition: Serializer.cpp:170
void serialboxSerializerDestroySavepointVector(serialboxSavepoint_t **savepointVector, int len)
Deallocate a savepoint vector retrieved via serialboxSerializerGetSavepointVector.
Definition: Serializer.cpp:195
void serialboxSerializerWrite(serialboxSerializer_t *serializer, const char *name, const serialboxSavepoint_t *savepoint, void *originPtr, const int *strides, int numStrides)
Serialize field name (given by originPtr and strides) at savepoint to disk.
Definition: Serializer.cpp:389
void serialboxEnableSerialization(void)
Enabled serialization.
Definition: Serializer.cpp:129
serialboxSavepoint_t ** serialboxSerializerGetSavepointVector(const serialboxSerializer_t *serializer)
Get an array of refrences to the registered savepoints.
Definition: Serializer.cpp:176
#define LOG(severity)
Logging infrastructure.
Definition: Logging.h:102
static int sizeOf(TypeID id)
Get size of the type.
Definition: Type.cpp:73
Represent a mutable view to a multi-dimensional storage.
Definition: StorageView.h:33
char * serialboxSerializerGetDirectory(const serialboxSerializer_t *serializer)
Return the directory of the Serializer.
Definition: Serializer.cpp:108
void setSlice(Slice slice)
Set the slice of the StorageView
Definition: StorageView.cpp:71
void serialboxSerializerGetFieldMetainfo2(const serialboxSerializer_t *serializer, const char *name, char **storedName, char **elementType, int *bytesPerElement, int *rank, int *iSize, int *jSize, int *kSize, int *lSize, int *iMinusHalo, int *iPlusHalo, int *jMinusHalo, int *jPlusHalo, int *kMinusHalo, int *kPlusHalo, int *lMinusHalo, int *lPlusHalo)
Get values of standard meta info pairs of field with name name
Definition: Serializer.cpp:328
serialboxMetainfo_t * serialboxSerializerGetGlobalMetainfo(serialboxSerializer_t *serializer)
Allocate a new serialboxMetainfo_t which maps to the global meta-information of the Serializer...
Definition: Serializer.cpp:144
TypeID
Type-id of types recognized by serialbox.
Definition: Type.h:55
void serialboxSerializerWaitForAll(serialboxSerializer_t *serializer)
Wait for all pending asynchronous read operations and reset the internal queue.
Definition: Serializer.cpp:455
int serialboxSerializationStatus(void)
Indicate whether serialization is enabled [default: enabled].
Definition: Serializer.cpp:127
Refrence to a FieldMetainfoImpl.
Definition: Type.h:99
Refrence to a Metainfo.
Definition: Type.h:91
Array of strings.
Definition: Array.h:80
void serialboxSerializerUpdateMetaData(serialboxSerializer_t *serializer)
Write meta-data to disk.
Definition: Serializer.cpp:118
int serialboxSerializerAddSavepoint(serialboxSerializer_t *serializer, const serialboxSavepoint_t *savepoint)
Register savepoint within the serializer.
Definition: Serializer.cpp:156
static void readFromFile(std::string filename, StorageView &storageView, std::string archiveName, std::string fieldname)
Directly read field (given by storageView) from file.
int serialboxSerializerAddField2(serialboxSerializer_t *serializer, const char *name, int type, int bytesPerElement, int iSize, int jSize, int kSize, int lSize, int iMinusHalo, int iPlusHalo, int jMinusHalo, int jPlusHalo, int kMinusHalo, int kPlusHalo, int lMinusHalo, int lPlusHalo)
Register field within the serializer.
Definition: Serializer.cpp:245
serialboxMetainfo_t * serialboxFieldMetainfoGetMetainfo(serialboxFieldMetainfo_t *fieldMetainfo)
Allocate a new serialboxMetainfo_t which maps to the meta-information of the Field meta-information...
Refrence to a Serializer.
Definition: Type.h:75
char * serialboxSerializerToString(const serialboxSerializer_t *serializer)
Convert serializer to string.
Definition: Serializer.cpp:133
char * serialboxSerializerGetPrefix(const serialboxSerializer_t *serializer)
Return the prefix of all filenames.
Definition: Serializer.cpp:113
serialbox::Exception exception
Exception class which stores a human-readable error description.
Definition: Exception.h:33
void serialboxSerializerRead(serialboxSerializer_t *serializer, const char *name, const serialboxSavepoint_t *savepoint, void *originPtr, const int *strides, int numStrides)
Deserialize field name (given by originPtr and strides) at savepoint from disk.
Definition: Serializer.cpp:404
static std::string toString(TypeID id)
Convert to string.
Definition: Type.cpp:35
void serialboxSerializerReadSliced(serialboxSerializer_t *serializer, const char *name, const serialboxSavepoint_t *savepoint, void *originPtr, const int *strides, int numStrides, const int *slice)
Deserialize sliced field name (given by originPtr, strides and slice) at savepoint from disk...
Definition: Serializer.cpp:419
int serialboxSerializerAddField(serialboxSerializer_t *serializer, const char *name, const serialboxFieldMetainfo_t *fieldMetainfo)
Register field given as fieldMetainfo within the serializer.
Definition: Serializer.cpp:226
int serialboxSerializerHasSavepoint(const serialboxSerializer_t *serializer, const serialboxSavepoint_t *savepoint)
Check if savepoint exists within the serializer.
Definition: Serializer.cpp:163
std::vector< SliceTriple > & sliceTriples() noexcept
Get slice triples.
Definition: Slice.h:106
static void writeToFile(std::string filename, const StorageView &storageView, std::string archiveName, std::string fieldname)
Directly write field (given by storageView) to file.
void serialboxSerializerReadAsync(serialboxSerializer_t *serializer, const char *name, const serialboxSavepoint_t *savepoint, void *originPtr, const int *strides, int numStrides)
Asynchronously deserialize field name (given as storageView) at savepoint from disk using std::async...
Definition: Serializer.cpp:440
serialboxArrayOfString_t * serialboxSerializerGetFieldnames(const serialboxSerializer_t *serializer)
Get an array of C-strings of all names of the registered fields.
Definition: Serializer.cpp:295
void serialboxFatalError(const char *reason)
Report a fatal error.
int serialboxSerializerGetMode(const serialboxSerializer_t *serializer)
Return mode of the Serializer.
Definition: Serializer.cpp:103
serialbox::Slice slice
Specification of the slice indices which is used for partial loading of serialized data...
Definition: Slice.h:43
int serialboxSerializerHasField(serialboxSerializer_t *serializer, const char *field)
Check if field is registered within the serializer.
Definition: Serializer.cpp:240
serialboxSerializer_t * serialboxSerializerCreate(int mode, const char *directory, const char *prefix, const char *archive)
Create a new Serializer.
Definition: Serializer.cpp:62
Refrence to a Savepoint.
Definition: Type.h:83
#define serialbox_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: Unreachable.h:41
void serialboxWriteToFile(const char *filename, void *originPtr, int typeID, const int *dims, int numDims, const int *strides, const char *fieldname, const char *archivename)
Serialize field name (given by originPtr and strides) directly to file.
Definition: Serializer.cpp:468
serialboxFieldMetainfo_t * serialboxSerializerGetFieldMetainfo(const serialboxSerializer_t *serializer, const char *name)
Get FieldMetainfoImpl of field with name name
Definition: Serializer.cpp:315
Specification of the slice indices which is used for partial loading of serialized data...
Definition: Slice.h:53
Exception class which stores a human-readable error description.
Definition: Exception.h:30
serialboxArrayOfString_t * serialboxSerializerGetFieldnamesAtSavepoint(const serialboxSerializer_t *serializer, const serialboxSavepoint_t *savepoint)
Get an array of C-strings of the field names registered at savepoint
Definition: Serializer.cpp:202
void serialboxDisableSerialization(void)
Disable serialization.
Definition: Serializer.cpp:131