small template based factory class to create objects by id or class name