add template generation code to the h and cpp file.