37#include <boost/archive/binary_iarchive.hpp>
38#include <boost/archive/binary_oarchive.hpp>
39#include <boost/archive/text_iarchive.hpp>
40#include <boost/archive/text_oarchive.hpp>
45#include "ArchiveLocationInfo.hpp"
46#include "ArchiveOpener.hpp"
48#include "OutputFileHandler.hpp"
49#include "ProcessSpecificArchive.hpp"
56template <
class InputArchive>
60 friend class TestArchivingHelperClasses;
71 const std::string& rFileNameBase,
81 std::stringstream common_path;
85 mpCommonStream =
new std::ifstream(common_path.str().c_str(), std::ios::binary);
89 EXCEPTION(
"Cannot load main archive file: " + common_path.str());
96 catch (boost::archive::archive_exception& boost_exception)
98 if (boost_exception.code == boost::archive::archive_exception::unsupported_version)
103 EXCEPTION(
"Could not open Boost archive '" + common_path.str() +
"' because it was written by a more recent Boost. Check process-specific archives too");
108 throw boost_exception;
113 mpPrivateStream =
new std::ifstream(private_path.c_str(), std::ios::binary);
119 EXCEPTION(
"Cannot load secondary archive file: " + private_path);
162template <
class OutputArchive>
166 friend class TestArchivingHelperClasses;
177 const std::string& rFileNameBase,
187 EXCEPTION(
"Specifying the secondary archive file ID doesn't make sense when writing.");
198 std::stringstream common_path;
204 mpCommonStream =
new std::ofstream(common_path.str().c_str(), std::ios::binary | std::ios::trunc);
208 EXCEPTION(
"Failed to open main archive file for writing: " + common_path.str());
215 mpCommonStream =
new std::ofstream(
"NUL", std::ios::binary | std::ios::trunc);
217 mpCommonStream =
new std::ofstream(
"/dev/null", std::ios::binary | std::ios::trunc);
223 EXCEPTION(
"Failed to open dummy archive file '/dev/null' for writing");
230 mpPrivateStream =
new std::ofstream(private_path.c_str(), std::ios::binary | std::ios::trunc);
236 EXCEPTION(
"Failed to open secondary archive file for writing: " + private_path);
#define EXCEPTION(message)
static std::string GetProcessUniqueFilePath(const std::string &rFileName, unsigned procId=PetscTools::GetMyRank())
static bool GetIsDirRelativeToChasteTestOutput()
static std::string GetArchiveDirectory()
static void SetArchiveDirectory(const FileFinder &rDirectory)
static std::string GetArchiveRelativePath()
ArchiveOpener(const FileFinder &rDirectory, const std::string &rFileNameBase, unsigned procId)
OutputArchive * GetCommonArchive()
std::ofstream * mpPrivateStream
std::ofstream * mpCommonStream
OutputArchive * mpPrivateArchive
OutputArchive * mpCommonArchive
std::ofstream * mpCommonStream
Archive * mpCommonArchive
std::ofstream * mpPrivateStream
Archive * mpPrivateArchive
static void Set(Archive *pArchive)