template getterLazy(string writeAccess, varType, string name, string genFunc = "")
enum getterLazy =
"\n" ~ ((genFunc == "") ? "static if(!is(typeof(_" ~ name ~ "_gen)==function))\n" ~ ` static assert(false, "'getterLazy!(` ~ fixAATypeName(varType.stringof) ~ `, \"` ~ name ~ `\")' requires function '` ~ fixAATypeName(varType.stringof) ~ ` _` ~ name ~ `_gen()' to be defined");` ~ "\n" : "") ~ writeAccess ~ " " ~ varType.stringof ~ " _" ~ name ~ ";\n" ~ writeAccess ~ " bool _" ~ name ~ "_cached = false;\n" ~ "@property public " ~ varType.stringof ~ " " ~ name ~ "() {\n" ~ " if(!_" ~ name ~ "_cached) {\n" ~ " _" ~ name ~ "_cached = true;\n" ~ " _" ~ name ~ " = _" ~ name ~ "_gen();\n" ~ " }\n" ~ " return _" ~ name ~ ";\n" ~ "}\n" ~ ((genFunc == "") ? "" : writeAccess ~ " " ~ varType.stringof ~ " _" ~ name ~ "_gen()\n" ~ "{\n" ~ genFunc ~ "}\n");