[core] Templatize class Generator.