CPGen
C++ project generator
Loading...
Searching...
No Matches
Public Member Functions | List of all members
GenerationPipeline Class Reference

Runs all registered emitters and materialises the project on disk. More...

#include <GenerationPipeline.hpp>

Public Member Functions

void addEmitter (std::unique_ptr< Emitter > emitter)
 Register an emitter to be run during execute.
 
void execute (const ResolvedProject &project, const std::filesystem::path &output_dir)
 Run every registered emitter and write the resulting files.
 

Detailed Description

Runs all registered emitters and materialises the project on disk.

Typical usage:

pipeline.addEmitter(std::make_unique<CMakeEmitter>());
pipeline.addEmitter(std::make_unique<ScaffoldEmitter>(template_root));
pipeline.addEmitter(std::make_unique<ToolingEmitter>(template_root));
pipeline.execute(resolved_project, "/tmp/MyProject");
Runs all registered emitters and materialises the project on disk.
Definition GenerationPipeline.hpp:33
void execute(const ResolvedProject &project, const std::filesystem::path &output_dir)
Run every registered emitter and write the resulting files.
Definition GenerationPipeline.cpp:22
void addEmitter(std::unique_ptr< Emitter > emitter)
Register an emitter to be run during execute.
Definition GenerationPipeline.cpp:18

Member Function Documentation

◆ addEmitter()

void GenerationPipeline::addEmitter ( std::unique_ptr< Emitter emitter)

Register an emitter to be run during execute.

Parameters
emitterOwning pointer to the emitter.

◆ execute()

void GenerationPipeline::execute ( const ResolvedProject project,
const std::filesystem::path &  output_dir 
)

Run every registered emitter and write the resulting files.

Creates the output_dir (and any parent directories) if they do not exist, then iterates through all emitters, collects their output, and writes each file.

Parameters
projectThe resolved project to generate.
output_dirAbsolute path to the root directory of the new project.
Exceptions
std::runtime_errorIf a file cannot be written.

The documentation for this class was generated from the following files: