An elementary framework for persistent homology