Type: info Title: new: SfxModelGuard Posted by: frank.schoenh...@sun.com Affected: - TaskId: i65597 <http://www.openoffice.org/issues/show_bug.cgi?id=65597> Effective from: CWS autorecovery CWS: <http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Path=DEV300/autorecovery> CWS status: new
*Summary* -------- class SfxModelGuard { enum AllowedModelState { E_INITIALIZING, E_FULLY_ALIVE }; SfxModelGuard( SfxBaseModel&, AllowedModelState = E_FULLY_ALIVE ); } *Description* ------------- SfxModelGuard is a helper class implementing the pattern found in nearly every method of SfxBaseModel and derived classes: - lock SolarMutex - check for being disposed, throw if so (- check for being uninitialized, i.e. not XLoadable::load'ed or XLoadable::initNew'ed, throw if so) Those 5 or so lines now boil down to SfxModelGuard aGuard( *this ); All methods in the base class implementation have been adjusted, derived classes are encouraged to migrate their code, too :) The few cases where methods need to be called during initialization phase (i.e. during loading or recovering the document, or during initNew) can use the E_INITIALIZING parameter to prevent the initialization check. The few cases where methods should not throw a DisposedException, but silently return, in case the instance is already disposed, still need to use the manual approach (after checking that a silent return is really the thing to do). Send feedback to interface-announce@openoffice.org
--------------------------------------------------------------------- To unsubscribe, e-mail: interface-announce-unsubscr...@openoffice.org For additional commands, e-mail: interface-announce-h...@openoffice.org