template<class T>
class KLFSyncGuardPtr< T >
Store a guarded pointer, synchronizing other copies of this pointer.
Stores a pointer to any object. Copies may be made of the KLFSyncGuardPtr<T> pointer and used normally. Once you destroy the pointed object using one of these pointers, then set that pointer to NULL and automatically all copies of that pointer will be set to NULL too.
Minimal example:
{
ptr3 = ptr1;
printf(
"Pointer 2 is now %p\n", (
QString*)ptr2);
printf("Pointer 2 = %s\n", qPrintable(*ptr2));
printf(
"Pointer 3 is now %p\n", (
QString*)ptr3);
printf("Pointer 3 = %s\n", qPrintable(*ptr3));
ptr1 = NULL;
printf(
"Pointer 2 is now %p\n", (
QString*)ptr2);
}
printf(
"Pointer 3 is now %p\n", (
QString*)ptr3);
Note that if you assign another KLFSyncGuardPtr-guarded pointed object to a KLFSyncGuardPtr which is already tracking a pointer, then a warning is emitted. This is to avoid design flaws where in that case, the assignment will cause the current KLFSyncGuardPtr to become a copy of the new KLFSyncGuardPtr and all copies of the original pointer will become independant and unaffected. Example:
Use reset() to detach from other copies and start fresh again.
Definition at line 836 of file klfutil.h.