diff -r 000000000000 -r e6b17d312c8b ximpfw/core/srcfrontend/srcmanager/ximpundotask.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ximpfw/core/srcfrontend/srcmanager/ximpundotask.inl Thu Dec 17 08:54:49 2009 +0200 @@ -0,0 +1,182 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: UndoTask related helpers. +* +*/ + +#include "ximppanics.h" + + +// ============================ MEMBER FUNCTIONS ============================= + +// --------------------------------------------------------------------------- +// CXIMPUndoPtrArrayEntryAdd::NewLC() +// --------------------------------------------------------------------------- +// +template< class T > +CXIMPUndoPtrArrayEntryAdd* CXIMPUndoPtrArrayEntryAdd::NewLC() + { + CXIMPUndoPtrArrayEntryAdd* self = new (ELeave) CXIMPUndoPtrArrayEntryAdd; + CleanupStack::PushL( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CXIMPUndoPtrArrayEntryAdd::~CXIMPUndoPtrArrayEntryAdd() +// --------------------------------------------------------------------------- +// +template< class T > +CXIMPUndoPtrArrayEntryAdd::~CXIMPUndoPtrArrayEntryAdd() + { + if( iObjArray ) + { + TInt index = iObjArray->Find( iObj ); + if( index != KErrNotFound ) + { + iObjArray->Remove( index ); + } + + delete iObj; + } + } + + +// --------------------------------------------------------------------------- +// CXIMPUndoPtrArrayEntryAdd::CXIMPUndoPtrArrayEntryAdd() +// --------------------------------------------------------------------------- +// +template< class T > +CXIMPUndoPtrArrayEntryAdd::CXIMPUndoPtrArrayEntryAdd() + { + } + + +// --------------------------------------------------------------------------- +// CXIMPUndoPtrArrayEntryAdd::InitToRemoveAndDestroyOnUndo() +// --------------------------------------------------------------------------- +// +template< class T > +void CXIMPUndoPtrArrayEntryAdd::InitToRemoveAndDestroyOnUndo( + T& aObj, + RPointerArray< T >& aObjArray ) + { + __ASSERT_ALWAYS( !iObjArray, + User::Panic( NXIMPPrivPanic::KCategory, + NXIMPPrivPanic::EPtrArrayEntryAddUndoInitialized ) ); + + iObjArray = &aObjArray; + iObj = &aObj; + } + + +// --------------------------------------------------------------------------- +// CXIMPUndoPtrArrayEntryAdd::CancelUndo() +// --------------------------------------------------------------------------- +// +template< class T > +void CXIMPUndoPtrArrayEntryAdd::CancelUndo() + { + iObjArray = NULL; + iObj = NULL; + } + + + + +// ============================ MEMBER FUNCTIONS ============================= + +// --------------------------------------------------------------------------- +// CXIMPUndoPtrArrayEntryReplace::NewLC() +// --------------------------------------------------------------------------- +// +template< class T > +CXIMPUndoPtrArrayEntryReplace* CXIMPUndoPtrArrayEntryReplace::NewLC() + { + CXIMPUndoPtrArrayEntryReplace* self = + new (ELeave) CXIMPUndoPtrArrayEntryReplace; + CleanupStack::PushL( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CXIMPUndoPtrArrayEntryReplace::~CXIMPUndoPtrArrayEntryReplace() +// --------------------------------------------------------------------------- +// +template< class T > +CXIMPUndoPtrArrayEntryReplace::~CXIMPUndoPtrArrayEntryReplace() + { + if( iObjArray ) + { + const TInt index = iObjArray->Find( iTarget ); + if( index != KErrNotFound ) + { + (*iObjArray)[ index ] = iSource; + delete iTarget; + } + else + { + delete iSource; + } + } + } + + +// --------------------------------------------------------------------------- +// CXIMPUndoPtrArrayEntryReplace::CXIMPUndoPtrArrayEntryReplace() +// --------------------------------------------------------------------------- +// +template< class T > +CXIMPUndoPtrArrayEntryReplace::CXIMPUndoPtrArrayEntryReplace() + { + } + + +// --------------------------------------------------------------------------- +// CXIMPUndoPtrArrayEntryReplace::InitToReplaceOnUndo() +// --------------------------------------------------------------------------- +// +template< class T > +void CXIMPUndoPtrArrayEntryReplace::InitToReplaceOnUndo( + T& aTarget, + RPointerArray< T >& aObjArray, + T& aSource ) + { + __ASSERT_ALWAYS( !iObjArray, + User::Panic( NXIMPPrivPanic::KCategory, + NXIMPPrivPanic::EPtrArrayEntryReplaceUndoInitialized ) ); + + iObjArray = &aObjArray; + iTarget = &aTarget; + iSource = &aSource; + } + + +// --------------------------------------------------------------------------- +// CXIMPUndoPtrArrayEntryReplace::CancelUndo() +// --------------------------------------------------------------------------- +// +template< class T > +void CXIMPUndoPtrArrayEntryReplace::CancelUndo() + { + iObjArray = NULL; + iTarget = NULL; + + delete iSource; + iSource = NULL; + } + + +