diff -r 000000000000 -r c40eb8fe8501 wlan_bearer/wlanldd/wlan_common/umac_common/inc/umaccarraypolicy.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlan_bearer/wlanldd/wlan_common/umac_common/inc/umaccarraypolicy.h Tue Feb 02 02:03:13 2010 +0200 @@ -0,0 +1,115 @@ +/* +* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: Policies for constant size arrays class template +* (see umaccarray.h). +* +*/ + +/* +* %version: 10 % +*/ + +#ifndef _POLICYCARRAY_H +#define _POLICYCARRAY_H + +/* + * + * Copy ctor and assignment operator policies 4 Carray + * + * @usage examples: + * + * Carray > obj; + * Carray > obj2; + * obj[0] = new int(1); + * obj[1] = new int(2); + * // test deep copy + * Carray > obj6(obj); + * // test deep assignment + * obj2 = obj6; + * + * Carray obj3; + * Carray obj4; + * obj3[0] = 1; + * obj3[1] = 2; + * // test shallow copy + * Carray obj5(obj3); + * // test shallow assignment + * obj4 = obj3; + * + * Carray > obj7; + * Carray > obj9; + * obj7[0] = new clonable(1); + * obj7[1] = new clonable(2); + * // test clone copy + * Carray > obj8(obj7); + * // test clone assignment + * obj9 = obj7; + * + * Carray > obj10; + * Carray > obj11; + * // does not compile as it should not + * obj10 = obj11; + */ + +#include "algorithm.h" + +// normal shallow copy +template +struct ShallowCopy +{ +typedef T* iterator; + + static void Copy(iterator srcbegin, iterator srcend, iterator trgbegin) + { + copy(srcbegin, srcend, trgbegin); + } +}; + +// calls Clone() 4 copy +template +struct CloneCopy +{ +typedef T** iterator; + + static void Copy(iterator srcbegin, iterator srcend, iterator trgbegin) + { + while(srcbegin != srcend) + { + *trgbegin = (*srcbegin)->Clone(); + + ++srcbegin; + ++trgbegin; + } + } +}; + +// just what name states copying and assignment are not allowed +template +struct NoCopy {}; + +// global new and delete operators +struct OpNewAlloc +{ + static void* operator new(size_t size) + { + return ::operator new(size); + } + + static void operator delete(void* p , size_t /*size*/) + { + ::operator delete(p); + } +}; + +#endif //_POLICYCARRAY_H