creates an iheritable class to automatically save and restore object state