X-ray diffraction from thin films: residual stress and texture analysis