Refactor gravity example

This change makes the likelihood and the qoi sublass the appropriate queso base classes.  The functionality is the same but the style is more oriented towards C++, rather than the C-style-like passing around of function pointers to queso classes.

@nicholasmalaya Fancy giving this one a once-over?
This is much better!