This generalizes the logic from QgsLayoutManager, so that additional
manager classes handling other object types can be added without
incurring a lot of near-duplicate code.
This is a step toward allowing storage of elevation profiles
within projects.