How to write isotropic source using c++ code?

i want to write a source, neutron and gamma are included, and
two particles emit isotropically, how to write isotropic source using
c++ code?

See examples/extended/eventgenerator/particleGun or userPrimaryGenerator
Also, there is isotropic source in electromagnetic/TestEm4 or hadronic/Hadr06, and probably several others examples …

i find the source code of isotropic source in in electromagnetic/TestEm4, thanks!