Managing IResettable-s

Started by
1 comment, last by jpetrie 14 years, 2 months ago
Okay, I probably doesn't matter much but I'm wondering about what the best way to handle IResettable instances in SlimDX is. At the moment, I have a class which wrap the Device class to automatically detect and recover from device resets. At the minute it provides two events - LostDevice and ResetDevice - which I can subscribe to in order to call the matching methods of my IResettable instances. However, I'm considering just maintaining a list internally which can be added to and removed from as IResettable instances are created and destroyed. It might be easier to code with given that I won't need to have two event handlers to handle this, rather I can just call a method to start managing, and another to stop. Or perhaps there is another way to handle this? What do you think? :p Thanks!
Using Visual C++ 7.0
Advertisement
Doesn't matter? Or should I elaborate? :p
Using Visual C++ 7.0
SlimDX's ObjectTable already has such a list. You could iterate the object table and look for objects implementing the interface if you really want to take that approach (ObjectTable.Objects.Where( o => o is IResettable) or whatever).

If you maintain your own list(s) you'll avoid the cost of the is check and the wasted time iterating over non-resettable objects. The point of the IResettable interface was to allow for these sorts of generic reset handling.

This topic is closed to new replies.

Advertisement