I'm trying to have a collection class similar to %Library.RelationshipObject in that it manages saving and deleting the objects in the collection. I'd like the flexibility to do this with my own objects, so I don't want to use the relationship keywords or subclass the %Library.RelationshipObject class.
I can't call my own Save() and Delete() methods on the parent object holding this collection, and have it call my collection class (and just have my classes call Save() instead of %Save()) because swizzling may call %Save() directly.
What I'm trying is to use the %OnAddToSaveSet method on my collection class and on my parent classes. The parent classes put my collection class in the save set when the parent classes %OnAddToSaveSet is called. The collection class calls saves and deletes the items in the collection as appropriate.
It seems that the right way to do this in my collection class is to Add the collection items to be saved into the save set using their %OnAddToSaveSet() method, and to delete the items that need deleting by using %Delete(), then setting
%objTX(5,+oref) = oref
for each of the deleted items.
Is this the right way to do it? Have I missed anything? Is this supported? Can I change anything unsupported to something better supported?