From: <sv...@ww...> - 2005-03-12 06:14:07
|
Author: mkrose Date: 2005-03-11 22:13:59 -0800 (Fri, 11 Mar 2005) New Revision: 1494 Modified: trunk/CSP/CSPSim/CHANGES.current trunk/CSP/CSPSim/Include/Bus.h Log: Add a new data channel method for setting and pushing a value in one call. Also add a method for safely reading an invalid channel. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1494 Modified: trunk/CSP/CSPSim/CHANGES.current =================================================================== --- trunk/CSP/CSPSim/CHANGES.current 2005-03-12 06:11:26 UTC (rev 1493) +++ trunk/CSP/CSPSim/CHANGES.current 2005-03-12 06:13:59 UTC (rev 1494) @@ -4,15 +4,18 @@ 2005-03-11: onsight * Fix an exception in the DataRecorder. + * Add a new data channel method for setting and pushing a value in one + call. Also add a method for safely reading an invalid channel. + 2005-03-05: onsight * Fix a couple minor warnings under gcc. 2005-03-05: delta * Extended Animation class with a direct children of AnimationPathCallback. It should allow to export (simple) animations from max thanks to osgExp. - Necessary changes to handle this new class have been committed in - ObjectModel. Due to the changes in the animation classes, a few xml files - have been updated. F16DJ model.osg has been slightly updated too. + Necessary changes to handle this new class have been committed in + ObjectModel. Due to the changes in the animation classes, a few xml files + have been updated. F16DJ model.osg has been slightly updated too. It's a work in progress! * Added toggles for refuelling doors and canopy (only f16dj). Hot keys added Modified: trunk/CSP/CSPSim/Include/Bus.h =================================================================== --- trunk/CSP/CSPSim/Include/Bus.h 2005-03-12 06:11:26 UTC (rev 1493) +++ trunk/CSP/CSPSim/Include/Bus.h 2005-03-12 06:13:59 UTC (rev 1494) @@ -385,6 +385,15 @@ } } + /** Set the channel value and signal the change to listeners. + * + * Should only be called for push channels (asserts false otherwise). + */ + void push(const T& value) { + m_Value = value; + push(); + } + /** * Get the current value of this channel as a non-const reference. * @@ -654,6 +663,19 @@ return channel; } + /** Convenience function for accessing a data channel that may be null. + * (The channel reference must have already been already been retrieved + * from the bus.) + * + * @param channel A data channel that may be null. + * @param fallback The value to return if the channel is null. + * @returns The channel value or the fallback. + */ + template <typename T> + static T readChannel(typename DataChannel<T>::CRef &channel, T const &fallback) { + return channel.isNull() ? fallback : channel->value(); + } + /** Get the bus status value. * * Bus degradation is not currently implemented. |