cpl_virtualmem.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  * $Id: cpl_virtualmem.h 27044 2014-03-16 23:41:27Z rouault $
00003  *
00004  * Name:     cpl_virtualmem.h
00005  * Project:  CPL - Common Portability Library
00006  * Purpose:  Virtual memory
00007  * Author:   Even Rouault, <even dot rouault at mines dash paris dot org>
00008  *
00009  **********************************************************************
00010  * Copyright (c) 2014, Even Rouault <even dot rouault at mines-paris dot org>
00011  *
00012  * Permission is hereby granted, free of charge, to any person obtaining a
00013  * copy of this software and associated documentation files (the "Software"),
00014  * to deal in the Software without restriction, including without limitation
00015  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00016  * and/or sell copies of the Software, and to permit persons to whom the
00017  * Software is furnished to do so, subject to the following conditions:
00018  * 
00019  * The above copyright notice and this permission notice shall be included
00020  * in all copies or substantial portions of the Software.
00021  * 
00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00023  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00024  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00025  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00026  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00027  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
00028  * DEALINGS IN THE SOFTWARE.
00029  ****************************************************************************/
00030 
00031 #ifndef _CPL_VIRTUAL_MEM_INCLUDED
00032 #define _CPL_VIRTUAL_MEM_INCLUDED
00033 
00034 #include "cpl_port.h"
00035 #include "cpl_vsi.h"
00036 
00037 CPL_C_START
00038 
00060 typedef struct CPLVirtualMem CPLVirtualMem;
00061 
00072 typedef void (*CPLVirtualMemCachePageCbk)(CPLVirtualMem* ctxt,
00073                                     size_t nOffset,
00074                                     void* pPageToFill,
00075                                     size_t nToFill,
00076                                     void* pUserData);
00077 
00088 typedef void (*CPLVirtualMemUnCachePageCbk)(CPLVirtualMem* ctxt,
00089                                       size_t nOffset,
00090                                       const void* pPageToBeEvicted,
00091                                       size_t nToBeEvicted,
00092                                       void* pUserData);
00093 
00097 typedef void (*CPLVirtualMemFreeUserData)(void* pUserData);
00098 
00100 typedef enum
00101 {
00104     VIRTUALMEM_READONLY,
00107     VIRTUALMEM_READONLY_ENFORCED,
00110     VIRTUALMEM_READWRITE
00111 } CPLVirtualMemAccessMode;
00112 
00113 
00120 size_t CPL_DLL CPLGetPageSize(void);
00121 
00166 CPLVirtualMem CPL_DLL *CPLVirtualMemNew(size_t nSize,
00167                                         size_t nCacheSize,
00168                                         size_t nPageSizeHint,
00169                                         int bSingleThreadUsage,
00170                                         CPLVirtualMemAccessMode eAccessMode,
00171                                         CPLVirtualMemCachePageCbk pfnCachePage,
00172                                         CPLVirtualMemUnCachePageCbk pfnUnCachePage,
00173                                         CPLVirtualMemFreeUserData pfnFreeUserData,
00174                                         void *pCbkUserData);
00175 
00176 
00182 int CPL_DLL CPLIsVirtualMemFileMapAvailable(void);
00183 
00209 CPLVirtualMem CPL_DLL *CPLVirtualMemFileMapNew( VSILFILE* fp,
00210                                                 vsi_l_offset nOffset,
00211                                                 vsi_l_offset nLength,
00212                                                 CPLVirtualMemAccessMode eAccessMode,
00213                                                 CPLVirtualMemFreeUserData pfnFreeUserData,
00214                                                 void *pCbkUserData );
00215 
00235 CPLVirtualMem CPL_DLL *CPLVirtualMemDerivedNew(CPLVirtualMem* pVMemBase,
00236                                                vsi_l_offset nOffset,
00237                                                vsi_l_offset nSize,
00238                                                CPLVirtualMemFreeUserData pfnFreeUserData,
00239                                                void *pCbkUserData);
00240 
00252 void CPL_DLL CPLVirtualMemFree(CPLVirtualMem* ctxt);
00253 
00269 void CPL_DLL *CPLVirtualMemGetAddr(CPLVirtualMem* ctxt);
00270 
00278 size_t CPL_DLL CPLVirtualMemGetSize(CPLVirtualMem* ctxt);
00279 
00287 int CPL_DLL CPLVirtualMemIsFileMapping(CPLVirtualMem* ctxt);
00288 
00296 CPLVirtualMemAccessMode CPL_DLL CPLVirtualMemGetAccessMode(CPLVirtualMem* ctxt);
00297 
00308 size_t CPL_DLL CPLVirtualMemGetPageSize(CPLVirtualMem* ctxt);
00309 
00327 int CPL_DLL CPLVirtualMemIsAccessThreadSafe(CPLVirtualMem* ctxt);
00328 
00341 void CPL_DLL CPLVirtualMemDeclareThread(CPLVirtualMem* ctxt);
00342 
00355 void CPL_DLL CPLVirtualMemUnDeclareThread(CPLVirtualMem* ctxt);
00356 
00374 void CPL_DLL CPLVirtualMemPin(CPLVirtualMem* ctxt,
00375                               void* pAddr, size_t nSize, int bWriteOp);
00376 
00384 void CPL_DLL CPLVirtualMemManagerTerminate(void);
00385 
00386 
00387 CPL_C_END
00388 
00389 #endif /* _CPL_VIRTUAL_MEM_INCLUDED */

Generated for GDAL by doxygen 1.7.1.