I am about to check in a significant improvement to yesterday's property-change listeners, once I've finished recompiling and testing them (probably before 2130Z). The interface now looks like this:
class SGPropertyChangeListener { public: virtual ~SGPropertyChangeListener (); virtual void valueChanged (SGPropertyNode * node); virtual void childAdded (SGPropertyNode * parent, SGPropertyNode * child); virtual void childRemoved (SGPropertyNode * parent, SGPropertyNode * child); protected: friend class SGPropertyNode; virtual void register_property (SGPropertyNode * node); virtual void unregister_property (SGPropertyNode * node); private: vector<SGPropertyNode *> _properties; }; There are separate notifications for a change value, and added child, and a removed child, so that user code can take appropriate actions. The protected methods are callbacks from SGPropertyNode::addChangeListener to allow two-way pointers; the destructor will remove all listener references so that there won't be dangling pointers when the object that's listening disappears. It's fairly clever, so I'm worried whether it will work. SGPropertyNode now has three separate methods for firing change events: SGPropertyNode::fireValueChanged () SGPropertyNode::fireChildAdded (SGPropertyNode * child) SGPropertyNode::fireChildRemoved (SGPropertyNode * child) The child-added and child-removed events will *always* be fired automatically. The value-changed events will be fired automatically unless the property is tied, in which case the controlling code must invoke it specifically (or not). I think that this is enough for anything we'll need to do. I know that this kind of thing can get a lot more complicated, but I'll resist that until it's proven that we cannot do without it. TODO: 1. Write good, up-to-date documentation and a programmer's tutorial for the property manager. 2. Write a comprehensive test suite for the property manager, since it's vital to FlightGear's good behaviour and is easy to test in batch mode. If there are any volunteers for either of these, I will be very grateful; otherwise, I'll try to get to them as time is available. Thanks, and all the best, David -- David Megginson, [EMAIL PROTECTED], http://www.megginson.com/ _______________________________________________ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel