diff -r e70851cd9e5e -r a3f46bb01be2 holdingarea/libEGL/src/EGLUtils.cpp --- a/holdingarea/libEGL/src/EGLUtils.cpp Thu Sep 16 12:43:44 2010 +0100 +++ b/holdingarea/libEGL/src/EGLUtils.cpp Mon Sep 20 14:29:05 2010 +0100 @@ -1,158 +1,158 @@ -/* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and /or associated documentation files - * (the "Materials "), to deal in the Materials without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Materials, - * and to permit persons to whom the Materials are furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR - * THE USE OR OTHER DEALINGS IN THE MATERIALS. - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: - * - */ - -#include "EGLUtils.h" -#include "EGLSurface.h" -#include "EGLContext.h" -#include "EGLImage.h" -#include "EGLThread.h" -#include "EGLProcess.h" -#include "EGLConfig.h" -#include "EGLDisplay.h" - -template -void AddObject( std::vector& vector, T*& object ) - { - if( !object ) return; - try - { - vector.push_back(object); - } - catch( std::bad_alloc ) - { - delete object; - object = NULL; - } - } - -template -T* FindObjectByPointer( const std::vector& vector, void* item, int* index ) - { - T* ret = NULL; - for( typename std::vector::size_type i = 0; i < vector.size(); i++ ) - { - if( vector[i] == item ) - { - ret = vector[i]; - if( index ) *index = i; - break; - } - } - return ret; - } - -template -T* FindObjectById( const std::vector& vector, EGLint id, int* index ) - { - T* ret = NULL; - for( typename std::vector::size_type i = 0; i < vector.size(); i++ ) - { - if( vector[i]->Id() == id ) - { - ret = vector[i]; - if( index ) *index = i; - break; - } - } - return ret; - } - -template -void DeleteObjectByPointer( std::vector& vector, void* item ) - { - int index; - T* object = FindObjectByPointer( vector, item, &index ); - if( object ) - { - delete object; - vector.erase( vector.begin() + index ); - } - } - -template -void DeleteObjectById( std::vector& vector, EGLint id ) - { - int index; - T* object = FindObjectById(vector, id, &index ); - if( object && object->Id() == id ) - { - delete object; - vector.erase( vector.begin() + index ); - } - } - -template -void DestroyPointerVector( std::vector& vector ) - { - for(typename std::vector::iterator iter = vector.begin(); iter != vector.end(); iter++) - { - delete (*iter); - } - vector.clear(); - } - -// CEGLSurface -template void AddObject( std::vector& vector, class CEGLSurface*& object ); -template class CEGLSurface* FindObjectByPointer( const std::vector& vector, void* item, int* index ); -template void DeleteObjectByPointer( std::vector& vector, void* item ); -template void DestroyPointerVector( std::vector& vector ); - -// CEGLContext -template void AddObject( std::vector& vector, class CEGLContext*& object ); -template void DeleteObjectByPointer( std::vector& vector, void* item ); -template void DestroyPointerVector( std::vector& vector ); - -// CEGLImage -template void AddObject( std::vector& vector, class CEGLImage*& object ); -template void DeleteObjectByPointer( std::vector& vector, void* item ); -template void DestroyPointerVector( std::vector& vector ); - -// CEGLThread -template void AddObject( std::vector& vector, class CEGLThread*& object ); -template void DeleteObjectById( std::vector& vector, EGLint id ); -template void DestroyPointerVector( std::vector& vector ); -template class CEGLThread* FindObjectById( const std::vector& vector, EGLint id, int* index ); - -// CEGLProcess -template void AddObject( std::vector& vector, class CEGLProcess*& object ); -template void DestroyPointerVector( std::vector& vector ); -template void DeleteObjectById( std::vector& vector, EGLint id ); - -// CEGLDisplay -template void AddObject( std::vector& vector, class CEGLDisplay*& object ); -template class CEGLDisplay* FindObjectByPointer( const std::vector& vector, void* item, int* index ); -template void DeleteObjectByPointer( std::vector& vector, void* item ); -template void DestroyPointerVector( std::vector& vector ); - -// CEGLConfig -template void AddObject( std::vector& vector, class CEGLConfig*& object ); -template class CEGLConfig* FindObjectByPointer( const std::vector& vector, void* item, int* index ); -template class CEGLConfig* FindObjectById( const std::vector& vector, EGLint id, int* index ); -template void DestroyPointerVector( std::vector& vector ); +/* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and /or associated documentation files + * (the "Materials "), to deal in the Materials without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Materials, + * and to permit persons to whom the Materials are furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR + * THE USE OR OTHER DEALINGS IN THE MATERIALS. + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * + */ + +#include "EGLUtils.h" +#include "EGLSurface.h" +#include "EGLContext.h" +#include "EGLImage.h" +#include "EGLThread.h" +#include "EGLProcess.h" +#include "EGLConfig.h" +#include "EGLDisplay.h" + +template +void AddObject( std::vector& vector, T*& object ) + { + if( !object ) return; + try + { + vector.push_back(object); + } + catch( std::bad_alloc ) + { + delete object; + object = NULL; + } + } + +template +T* FindObjectByPointer( const std::vector& vector, void* item, int* index ) + { + T* ret = NULL; + for( typename std::vector::size_type i = 0; i < vector.size(); i++ ) + { + if( vector[i] == item ) + { + ret = vector[i]; + if( index ) *index = i; + break; + } + } + return ret; + } + +template +T* FindObjectById( const std::vector& vector, EGLint id, int* index ) + { + T* ret = NULL; + for( typename std::vector::size_type i = 0; i < vector.size(); i++ ) + { + if( vector[i]->Id() == id ) + { + ret = vector[i]; + if( index ) *index = i; + break; + } + } + return ret; + } + +template +void DeleteObjectByPointer( std::vector& vector, void* item ) + { + int index; + T* object = FindObjectByPointer( vector, item, &index ); + if( object ) + { + delete object; + vector.erase( vector.begin() + index ); + } + } + +template +void DeleteObjectById( std::vector& vector, EGLint id ) + { + int index; + T* object = FindObjectById(vector, id, &index ); + if( object && object->Id() == id ) + { + delete object; + vector.erase( vector.begin() + index ); + } + } + +template +void DestroyPointerVector( std::vector& vector ) + { + for(typename std::vector::iterator iter = vector.begin(); iter != vector.end(); iter++) + { + delete (*iter); + } + vector.clear(); + } + +// CEGLSurface +template void AddObject( std::vector& vector, class CEGLSurface*& object ); +template class CEGLSurface* FindObjectByPointer( const std::vector& vector, void* item, int* index ); +template void DeleteObjectByPointer( std::vector& vector, void* item ); +template void DestroyPointerVector( std::vector& vector ); + +// CEGLContext +template void AddObject( std::vector& vector, class CEGLContext*& object ); +template void DeleteObjectByPointer( std::vector& vector, void* item ); +template void DestroyPointerVector( std::vector& vector ); + +// CEGLImage +template void AddObject( std::vector& vector, class CEGLImage*& object ); +template void DeleteObjectByPointer( std::vector& vector, void* item ); +template void DestroyPointerVector( std::vector& vector ); + +// CEGLThread +template void AddObject( std::vector& vector, class CEGLThread*& object ); +template void DeleteObjectById( std::vector& vector, EGLint id ); +template void DestroyPointerVector( std::vector& vector ); +template class CEGLThread* FindObjectById( const std::vector& vector, EGLint id, int* index ); + +// CEGLProcess +template void AddObject( std::vector& vector, class CEGLProcess*& object ); +template void DestroyPointerVector( std::vector& vector ); +template void DeleteObjectById( std::vector& vector, EGLint id ); + +// CEGLDisplay +template void AddObject( std::vector& vector, class CEGLDisplay*& object ); +template class CEGLDisplay* FindObjectByPointer( const std::vector& vector, void* item, int* index ); +template void DeleteObjectByPointer( std::vector& vector, void* item ); +template void DestroyPointerVector( std::vector& vector ); + +// CEGLConfig +template void AddObject( std::vector& vector, class CEGLConfig*& object ); +template class CEGLConfig* FindObjectByPointer( const std::vector& vector, void* item, int* index ); +template class CEGLConfig* FindObjectById( const std::vector& vector, EGLint id, int* index ); +template void DestroyPointerVector( std::vector& vector );