class LCleanedupGuard |
A class that provides CleanupStack-based local-scope automatic cleanup using a TCleanupOperation on the destruction of the LManagedGuard object.
This class can only be used to define a local stack scoped cleanup, never an object scoped cleanup to guard object destruction. See below for an explanation and links to management classes suitable for use in different contexts.
The guarding local variable goes out of scope normally
The guarding local variable goes out of scope due to an untrapped leave causing the scope to be exited non-locally
The constructors of this class may leave.
Automatic cleanup may be disabled at any time by calling Dismiss(), while cleanup may be forced at any time by calling Execute().
// block scope example { RCleanable obj; LCleanedupGuard cleanGuard(RCleanable::Cleanup, &obj); obj.DoSomethingL(); // leave-safe if (Finished()) return; // RCleanable::Cleanup is invoked automatically when exiting from scope obj.DoSomethingElseL(); // leave-safe // RCleanable::Cleanup is invoked automatically when exiting from scope }
Behind the scenes, this class template is implemented in terms of the thread-local CleanupStack, restricting its use to local stack scope. This use of the CleanupStack ensures a consistent cleanup order between functions that call one another, even if they use different cleanup idioms.
LManagedGuard which has the same interface, but does not use the cleanup stack and is suitable for use as the data member of a class to guard object destruction.
Public Member Functions | |
---|---|
LCleanedupGuard(TCleanupOperation, TAny *) | |
~LCleanedupGuard() | |
void | Cleanup(TAny *) |
void | Dismiss() |
void | Execute() |
Private Member Functions | |
---|---|
LCleanedupGuard(const LCleanedupGuard &) | |
LCleanedupGuard & | operator=(const LCleanedupGuard &) |
Private Attributes | |
---|---|
TCleanupOperation | iCleanupOperation |
TAny * | iData |
LCleanedupGuard | ( | TCleanupOperation | aCleanupOperation, |
TAny * | aData = 0 | ||
) | [inline] |
Constructor. Creates a LCleanedupGuard object that, when enabled, automatically invokes upon destruction a cleanup operation specified by the aCleanupOperation parameter with the pointer to data specified by the aData parameter.
TCleanupOperation aCleanupOperation | A cleanup operation. |
TAny * aData = 0 | Pointer to data to be passed to the cleanup operation |
LCleanedupGuard | ( | const LCleanedupGuard & | ) | [private] |
const LCleanedupGuard & |
LCleanedupGuard & | operator= | ( | const LCleanedupGuard & | ) | [private] |
const LCleanedupGuard & |
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.