fast way to find references

hi!

i have a collada file and several graphical nodes in an application, representing collada data. each node has a data member that is a pointer to the object in the Collada DOM, so for example an image has a domImage *ptr to the according image in the library_images.
now i want to be able to delete nodes. deleting the library entries is easy, but i still need to delete all references to the element. is there a fast way in Collada DOM to get to the according places in the file? the types i need to delete are domImage, domEffect, domMaterial and DomGeometry. I hope deleting one of those doesn’t mean parsing the whole file…

thanks!

If I understand you correctly you are asking if there is a way to delete a pointer and then have all the other spots that have a copy of that pointer to not be a dangling pointer? That sounds like the Observer pattern is needed. The DOM doesn’t do this for you.

Or are you asking (strictly in COLLADA DOM) a way to delete an element and then get all of the URI references to remove them too? The DOM doesn’t have any finctionality for that either. That is a very fragile operation. What do you do to the elements that referenced that now removed element? What if the “url” attribute is required? just removing it would cause invalid documents. What about documents that aren’t loaded in memory that reference that element? There will be no way for those documents to know that the element was removed.

But if you aren’t worried about the fragility of that operation, and don’t care about external referrencing, then the observer pattern would be best. If you aren’t familiar with the pattern check here for more details. In a nutshell you have an object that is able to be watched and one that is able to watch objects. As you are creating your application nodes, register as observers the watched object (ie, domImage) with the watcher (the node where your domImage is used) and when the domImage gets deleted it notifies the node where it is used.

-Andy

#Or are you asking (strictly in COLLADA DOM) a way to delete an element and #then get all of the URI references to remove them too?

yes that’s exactely it.

#But if you aren’t worried about the fragility of that operation, and don’t care #about external referrencing, then the observer pattern would be best.

we don’t do external referencing in our content pipeline, so that’s fine. moreover the application is written in Qt4.2, so that makes it really easy for the observer pattern. i will go with that.
thanks!