https://mooseframework.inl.gov
Backup.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "Backup.h"
11 
12 #include "DataIO.h"
13 
14 void
15 dataStore(std::ostream & stream, Backup & backup, void * context)
16 {
17  mooseAssert(backup.header, "Not set");
18  mooseAssert(backup.data, "Not set");
19 
20  dataStore(stream, *backup.header, context);
21  dataStore(stream, *backup.data, context);
22  dataStore(stream, backup.mesh_files, context);
23 }
24 
25 void
26 dataLoad(std::istream & stream, Backup & backup, void * context)
27 {
28  mooseAssert(backup.header, "Not set");
29  mooseAssert(backup.data, "Not set");
30 
31  dataLoad(stream, *backup.header, context);
32  dataLoad(stream, *backup.data, context);
33  dataLoad(stream, backup.mesh_files, context);
34 }
35 
36 void
37 dataStore(std::ostream & stream, std::unique_ptr<Backup> & backup, void * context)
38 {
39  bool has_value = backup != nullptr;
40  dataStore(stream, has_value, nullptr);
41  if (has_value)
42  dataStore(stream, *backup, context);
43 }
44 
45 void
46 dataLoad(std::istream & stream, std::unique_ptr<Backup> & backup, void * context)
47 {
48  bool has_value;
49  dataLoad(stream, has_value, nullptr);
50  if (has_value)
51  {
52  backup = std::make_unique<Backup>();
53  dataLoad(stream, *backup, context);
54  }
55 }
Helper class to hold streams for Backup and Restore operations.
Definition: Backup.h:25
void dataStore(std::ostream &stream, Backup &backup, void *context)
Definition: Backup.C:15
std::unique_ptr< std::stringstream > data
Restartable data payload stream.
Definition: Backup.h:30
void dataLoad(std::istream &stream, Backup &backup, void *context)
Definition: Backup.C:26
std::vector< std::pair< std::string, std::string > > mesh_files
Pairs of checkpoint-relative entry names and binary payloads.
Definition: Backup.h:32
std::unique_ptr< std::stringstream > header
Restartable data header stream.
Definition: Backup.h:28