40#include "graphWriters.hpp"
41#include "jacobianBinaryReaderWriter.hpp"
42#include "jacobianTextReaderWriter.hpp"
43#include "mathRepWriter.hpp"
44#include "primalBinaryReaderWriter.hpp"
45#include "primalTextReaderWriter.hpp"
46#include "tapeReaderWriterInterface.hpp"
52 template<
typename T,
typename... Args>
54 return std::unique_ptr<T>(
new T(std::forward<Args>(args)...));
68 template<
typename T_Type>
69 std::unique_ptr<TapeWriterInterface<T_Type>>
createWriter(
const std::string& fileName,
70 std::vector<typename T_Type::Identifier>& inputVariables,
71 std::vector<typename T_Type::Identifier>& outputVariables,
73 using Type =
CODI_DD(T_Type, CODI_DEFAULT_LHS_EXPRESSION);
74 using Tape =
typename Type::Tape;
76 std::unique_ptr<TapeWriterInterface<T_Type>> writer =
nullptr;
79 switch (selectedType) {
81 if (IsPrimalValueTape) {
90 case FileType::Binary:
91 if (IsPrimalValueTape) {
99 if (IsPrimalValueTape) {
108 if (IsPrimalValueTape) {
111 CODI_EXCEPTION(
"The MathRepWriter is not supported for Jacobian tapes.");
116 CODI_EXCEPTION(
"A valid file format was not selected.");
131 template<
typename T_Type>
132 std::unique_ptr<TapeReaderInterface<T_Type>>
readTapeFile(std::string
const& fileName) {
136 std::unique_ptr<TapeReaderInterface<T_Type>> reader =
nullptr;
137 std::string fileExtension;
139 size_t dotPosition = fileName.find_last_of(
".");
140 if (dotPosition != std::string::npos) {
141 fileExtension = fileName.substr(dotPosition + 1);
144 if (fileExtension ==
"txt") {
146 }
else if (fileExtension ==
"dat") {
149 CODI_EXCEPTION(
"The given file type is not supported.");
151 reader->readFile(fileName);
165 template<
typename T_Type>
167 std::string
const& fileName, std::vector<typename T_Type::Tape::EvalHandle>
const& evalHandles) {
171 std::unique_ptr<TapeReaderInterface<T_Type>> reader =
nullptr;
172 std::string fileExtension;
174 size_t dotPosition = fileName.find_last_of(
".");
175 if (dotPosition != std::string::npos) {
176 fileExtension = fileName.substr(dotPosition + 1);
179 if (fileExtension ==
"txt") {
181 }
else if (fileExtension ==
"dat") {
184 CODI_EXCEPTION(
"The given file type is not supported.");
187 reader->readFile(fileName);
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:96
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
std::unique_ptr< TapeWriterInterface< T_Type > > createWriter(const std::string &fileName, std::vector< typename T_Type::Identifier > &inputVariables, std::vector< typename T_Type::Identifier > &outputVariables, FileType selectedType)
The createWriter() function is used to generate an automatic writer using the FileType and the TapeTr...
Definition readerWriterHelpers.hpp:69
std::unique_ptr< TapeReaderInterface< T_Type > > readTapeFile(std::string const &fileName)
Uses the fileName to read and restore a Jacobian tape. The file extension is used to determine wether...
Definition readerWriterHelpers.hpp:132
FileType
Used to select the type of writer that should be generated.
Definition tapeReaderWriterInterface.hpp:47
std::unique_ptr< T > make_unique_helper(Args &&... args)
Helper for creating a unique pointer. (std::make_unique is not available in C++11....
Definition readerWriterHelpers.hpp:53
If the tape inherits from PrimalValueBaseTape.
Definition tapeTraits.hpp:95