/usr/include/crystalspace-2.0/iutil/cache.h is in libcrystalspace-dev 2.0+dfsg-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | /*
Copyright (C) 2002 by Jorrit Tyberghein
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CS_IUTIL_CACHE_H__
#define __CS_IUTIL_CACHE_H__
#include "csutil/ref.h"
#include "csutil/scf_interface.h"
struct iDataBuffer;
/**\file
* Cache manager interface
*/
/**
* A generic cache system. A client can use this to cache data
* that was hard to calculate. The data is not converted in any
* way so it is the responsability of the client to correct platform
* depending issues like endianess and structure padding.
* <p>
* Every item in a cache has a 'type', a 'scope', and a unique id.
* The 'type' can be something like 'lightmap', 'octree', ...
* The 'scope' can be something like 'myRegion_mySector', ...
* The 'id' is a unique ID for the cached item in the given type
* and scope. ~0 can be taken for the cases "no ID" or "ID unused".
* Avoid using '/' and '\' characters in both type and scope as this
* may cause conflicts with the given cache (if it caches on a file
* system for example).
* <p>
* Note that both 'type' and 'scope' can be made default using
* SetCurrentType() and SetCurrentScope(). If those are set then
* you can use 0 for type and/or scope in CacheData() and
* ReadCache(). If you don't use 0 then the given value will
* override the default values.
*/
struct iCacheManager : public virtual iBase
{
SCF_INTERFACE(iCacheManager, 2,0,0);
/**
* Force the cache manager to be read-only. This will prevent
* updates of the cache but CacheData() will still return true
* to indicate success.
*/
virtual void SetReadOnly (bool ro) = 0;
/**
* Is the cache manager read-only?
*/
virtual bool IsReadOnly () const = 0;
/**
* Set current type. This will be used in CacheData() and
* ReadCache() when the given 'type' there is 0.
*/
virtual void SetCurrentType (const char* type) = 0;
/**
* Get current type or 0 if none set.
*/
virtual const char* GetCurrentType () const = 0;
/**
* Set current scope. This will be used in CacheData() and
* ReadCache() when the given 'scope' there is 0.
*/
virtual void SetCurrentScope (const char* scope) = 0;
/**
* Get current scope or 0 if none set.
*/
virtual const char* GetCurrentScope () const = 0;
/**
* Cache some data. Returns true if this succeeded.
*/
virtual bool CacheData (const void* data, size_t size,
const char* type, const char* scope, uint32 id) = 0;
/**
* Retrieve some data from the cache. Returns 0 if the
* data could not be found in the cache.
* \remark Returned buffer is NOT null-terminated.
* \remark Don't modify returned buffer!
*/
virtual csPtr<iDataBuffer> ReadCache (
const char* type, const char* scope, uint32 id) = 0;
/**
* Clear items from the cache. There are four ways to call
* this function:
* - 0, 0, 0: clear entire cache.
* - 'type', 0, 0: clear everything of this type.
* - 'type', 'scope', 0: clear everything of this type and scope.
* - 'type', 'scope', id: clear the specific item.
*
* Returns true if items were deleted. Returns false if item was not
* found or deletion is not possible.
*/
virtual bool ClearCache (const char* type = 0, const char* scope = 0,
const uint32* id = 0) = 0;
/**
* Ensure that the cached data is written on whatever medium is
* behind the cache.
*/
virtual void Flush () = 0;
};
#endif // __CS_IUTIL_CACHE_H__
|