40#include "../../misc/demangleName.hpp"
41#include "commonReaderWriterBase.hpp"
54 template<
typename T_Type>
57 using Tape =
typename Type::Tape;
60 using Real =
typename Type::Real;
69 std::vector<Identifier>
const& out)
79 FILE* fileHandleCreator =
nullptr;
81 this->
openFile(fileHandleCreator, handleCreatorFileName,
"w");
83 std::string functionName = this->
modifyFileName(
"CreateEvalHandles");
84 std::string fileHeader =
85 "#include <codi.hpp>\n\n"
86 "template <typename Tape>\n"
87 "std::vector<typename Tape::EvalHandle> " +
90 " std::vector<typename Tape::EvalHandle> evalHandles;\n"
94 fileHeader += demangleName<Tape>() +
";\n\n";
96 fileHeader +=
" evalHandles.resize(" + std::to_string(
evalHandleCount) +
");\n";
99 std::string frontOfStmt =
" evalHandles[";
100 std::string backOfStmt =
"] = Tape::StatementEvaluator::template createHandle<";
103 std::string fileFooter =
"return evalHandles;\n}";
106 fprintf(fileHandleCreator,
"%s", fileHeader.c_str());
110 fprintf(fileHandleCreator,
"%s%zu%s%s>();\n", frontOfStmt.c_str(), handleCounter, backOfStmt.c_str(),
114 fprintf(fileHandleCreator,
"\n %s", fileFooter.c_str());
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
CoDiPack - Code Differentiation Package.
Definition codi.hpp:91
This class is a common base for all the writers and produces a IO file that contains the input and ou...
Definition commonReaderWriterBase.hpp:84
std::string modifyFileName(std::string const &suffix)
Remove the file extension and replace it with a new suffix.
Definition commonReaderWriterBase.hpp:59
void openFile(FILE *&fileHandle, std::string const &name, std::string const &mode)
Definition commonReaderWriterBase.hpp:67
This base class is used to implement the automatic generation of the .hpp file that restores the eval...
Definition primalBaseReaderWriter.hpp:55
void generateHandleCreatorFile()
This method is used to generate an .hpp file which creates the necessary EvalHandles in the reading p...
Definition primalBaseReaderWriter.hpp:78
typename Type::Identifier Identifier
See TapeWriterInterface.
Definition primalBaseReaderWriter.hpp:59
PrimalBaseTapeWriter(std::string const &name, std::vector< Identifier > const &in, std::vector< Identifier > const &out)
Constructor.
Definition primalBaseReaderWriter.hpp:68
std::vector< std::string > evalHandleStatements
The unique evalHandleStatements.
Definition primalBaseReaderWriter.hpp:65
size_t evalHandleCount
Count the number of unique evalHandles.
Definition primalBaseReaderWriter.hpp:64
size_t getEvalHandleIndex(EvalHandle const evalHandle, std::string const &evalStatement)
Get the index for an evalHandle.
Definition primalBaseReaderWriter.hpp:118
typename Type::Real Real
See TapeWriterInterface.
Definition primalBaseReaderWriter.hpp:60
typename Type::Tape Tape
See TapeWriterInterface.
Definition primalBaseReaderWriter.hpp:57
T_Type Type
See TapeWriterInterface.
Definition primalBaseReaderWriter.hpp:56
std::map< EvalHandle, size_t > existingEvalHandles
Contains the existing handles and the assigned index.
Definition primalBaseReaderWriter.hpp:63
typename Tape::EvalHandle EvalHandle
See TapeWriterInterface.
Definition primalBaseReaderWriter.hpp:61