www.mooseframework.org
Backup.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 }
23 
24 void
25 dataLoad(std::istream & stream, Backup & backup, void * context)
26 {
27  mooseAssert(backup.header, "Not set");
28  mooseAssert(backup.data, "Not set");
29 
30  dataLoad(stream, *backup.header, context);
31  dataLoad(stream, *backup.data, context);
32 }
33 
34 void
35 dataStore(std::ostream & stream, std::unique_ptr<Backup> & backup, void * context)
36 {
37  bool has_value = backup != nullptr;
38  dataStore(stream, has_value, nullptr);
39  if (has_value)
40  dataStore(stream, *backup, context);
41 }
42 
43 void
44 dataLoad(std::istream & stream, std::unique_ptr<Backup> & backup, void * context)
45 {
46  bool has_value;
47  dataLoad(stream, has_value, nullptr);
48  if (has_value)
49  {
50  backup = std::make_unique<Backup>();
51  dataLoad(stream, *backup, context);
52  }
53 }
Helper class to hold streams for Backup and Restore operations.
Definition: Backup.h:18
void dataStore(std::ostream &stream, Backup &backup, void *context)
Definition: Backup.C:15
std::unique_ptr< std::stringstream > data
Definition: Backup.h:21
void dataLoad(std::istream &stream, Backup &backup, void *context)
Definition: Backup.C:25
std::unique_ptr< std::stringstream > header
Definition: Backup.h:20