TextGen developer guide

April 16, 2026 · View on GitHub

For developers who want to read or extend the library itself.

Reading order

  1. Architecture overview — how the patterns fit together and how a call flows from TextGenerator::generate() to final text
  2. Class index — one-line purpose for every class, grouped by role (Glyph, Dictionary, TextFormatter, Story, …)
  3. GlyphsDocument / Paragraph / Sentence / Phrase Composite hierarchy
  4. DictionariesDictionary interface and backends
  5. Text formatters — Visitor hierarchy (plain / HTML / CSS / speech / debug)
  6. StoriesStory base class, StoryFactory, and how per-parameter stories dispatch to generators
  7. Narrative helpersCloudinessForecast, PrecipitationForecast, FogForecast, ThunderForecast, WindForecast, WeatherForecastStory
  8. Mask sources — geographic filtering (coast / inland / halves)
  9. Acceptors — value filtering for analyser reductions
  10. Analysis functionsMean, Maximum, Trend, …
  11. Testing — how to write and run a generator unit test

Conventions used in the code

  • Capital-letter file = a class (Document.cpp, WeatherFact.cpp, HeaderFactory.cpp). Class-file layout follows the SmartMet convention: Foo.h / Foo.cpp hold class TextGen::Foo.
  • Lowercase file = a generator entry point — one per named story (wind_overview.cpp, temperature_max36hours.cpp). These implement a single method of the owning Story class (usually WindStory::overview(), TemperatureStory::max36hours(), …) and are split out purely because they are too large to share a translation unit.
  • Everything lives in namespace TextGen.
  • Internal headers are #include "X.h". SmartMet library headers use angle brackets: #include <calculator/Settings.h>.

Dependencies

  • calculator — forecast analysis primitives (AnalysisSources, Settings, WeatherPeriod, HourPeriodGenerator, …)
  • macgyver — utilities (Exception, caching, charset, datetime)
  • newbase — QueryData / NFmi* types
  • Boost (locale, thread), fmt, libpqxx, mysqlpp, ICU, GDAL

See also

  • User guide — configuration layout, per-story reference, and status tags