C++ repository templates
Table of Contents
This page is the literate source for the cpp_repository facet of the
codegen template library. Each section documents one template and
holds its source in a mustache block tangled to the sibling
.mustache file consumed by generator.py. The .mustache files are
generated artefacts — edit this document, then run the tangle
(compass build --direct tangle_codegen_templates or
projects/ores.lisp/src/ores-build-codegen-templates.el directly).
Output paths and profile membership come from
facet_catalogue.org.
Summary
Twelve templates — three hpp/cpp pairs in temporal and non-temporal
variants — forming the entity's persistence triplet: the sqlgen
entity struct mirroring the table, the mapper converting domain ↔
entity, and the repository exposing CRUD and temporal queries.
repository and non-temporal-repository profiles.
The cpp_repository facet
The persistence layer of the entity projection (entity lifecycle):
the database round-trip entity ↔ mapper ↔ repository over sqlgen.
Declarations in .hpp, out-of-class implementations in .cpp, with
custom-method paste points from the entity org-model where the
generated default is not enough. The temporal/non-temporal twins are
the Phase-3 unification target.
Mustache incantations
Column loops dispatch on per-field type flags (is_string,
is_boolean, is_timestamp, …) to choose C++ types, defaults and
faker calls; {{^last}} drives comma placement. Custom-method
injection points reference the org entity meta-model's paste markers
(see the meta-model notes). Otherwise the group's standard
constructs.
Archetypes
| Archetype | Description |
|---|---|
| cpp_domain_type_entity.cpp.mustache | Out-of-class implementations for the sqlgen entity. repository profile. |
| cpp_domain_type_entity.hpp.mustache | sqlgen-side struct mirroring the table shape. repository profile. |
| cpp_domain_type_entity_non_temporal.cpp.mustache | Non-temporal twin of the entity impl. non-temporal-repository profile. |
| cpp_domain_type_entity_non_temporal.hpp.mustache | Non-temporal twin of the entity header. non-temporal-repository profile. |
| cpp_domain_type_mapper.cpp.mustache | Domain ↔ entity conversions including timestamp handling. repository profile. |
| cpp_domain_type_mapper.hpp.mustache | Mapper declarations. repository profile. |
| cpp_domain_type_mapper_non_temporal.cpp.mustache | Non-temporal mapper implementation. non-temporal-repository profile. |
| cpp_domain_type_mapper_non_temporal.hpp.mustache | Non-temporal mapper declarations. non-temporal-repository profile. |
| cpp_domain_type_repository.cpp.mustache | CRUD + temporal queries over sqlgen; custom-method paste points. repository profile. |
| cpp_domain_type_repository.hpp.mustache | Repository declarations with custom-member paste points. repository profile. |
| cpp_domain_type_repository_non_temporal.cpp.mustache | Non-temporal repository implementation. non-temporal-repository profile. |
| cpp_domain_type_repository_non_temporal.hpp.mustache | Non-temporal repository declarations. non-temporal-repository profile. |
See also
- (Parent template group doc:
<group>_group.org.) - Codegen template library — the groups overview.
- Facet — the MASD concept these templates project.
- Entity lifecycle — the facet's modeling reference (repository).
- Applied MASD — the facet catalogue and codegen routes.
- facet_catalogue.org — profile → template/output mapping.