Optical readout of single spins for quantum computing and magnetic sensing