info/CWS autorecovery : new: SfxModelGuard
[email protected] Thu, 18 Feb 2010 11:23:46 +0100 (CET)
| Newsgroups | gmane.comp.openoffice.announce.interface |
|---|---|
| Message-ID | <10981652.261266488626501.JavaMail.root@so-web5> |
------=_Part_1280_25421524.1266488626500
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Type: info
Title: new: SfxModelGuard
Posted by: [email protected]
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 [email protected]
------=_Part_1280_25421524.1266488626500
Content-Type: text/plain; charset=us-ascii
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
------=_Part_1280_25421524.1266488626500--