Cache::Item Class Reference

#include <CacheEngine.hpp>

List of all members.


Detailed Description

This is a cache item.

The deletion is done by a pointer to a function that accept void* reference. You can use any of the predefined static member function for this pointer. Defaut is deletion with "delete[] (char*)ptr" like function

Warning:
If you use UZI in a DLL that has been compiled with a different C library than the software, you MUST implement your own deletion function, as it is your responsibility to allocate item's data
An item can be searched in the cache's Holder by URL or by timestamp.


Public Types

typedef void(*) DeleteDataFnc (void *)
 The deletion function pointer signature.
enum  DocumentType {
  Unknown = 0x00000000, XML = 0x00000001, HTML = 0x00000002, JPEGImage = 0x00000003,
  PNGImage = 0x00000004, GIFImage = 0x00000005, Stylesheet = 0x00000006, ScriptFile = 0x00000007
}
 The possible documents type. More...
enum  Status {
  Unset = 0, WaitingFetching = 1, Ready = 2, FetchingError = -1,
  BadURI = -2
}
 The possible item status. More...

Public Member Functions

void deleteData () volatile
 Delete the item data (you should never call this, unless the data is updated).
void deleteData ()
 Delete the item data (you should never call this, unless the data is updated).
bool fetchingError () constvolatile
 Is this item on error ?
bool fetchingError () const
 Does the fetching of this item gave error ?
const void * getData () volatileconst
 Get the data.
const void * getData () const
 Get the data.
const uint32 getDataSize () volatileconst
 Get the data size.
const uint32 getDataSize () const
 Get the data size.
const DocumentType getDocumentType () constvolatile
 Get the data type.
const DocumentType getDocumentType () const
 Get the data type.
const Strings::FastStringgetDocumentURL () constvolatile
 Get the document URL.
const Strings::FastStringgetDocumentURL () const
 Get the document URL.
const Status getStatus () constvolatile
 Get the current status.
const Status getStatus () const
 Get the current status.
const CacheTime getTimestamp () constvolatile
 Get the document timestamp.
const CacheTime getTimestamp () const
 Get the document timestamp.
 Item (const Strings::FastString &_URL, const DocumentType &_type=Unknown, void *_data=0, const uint32 _size=0, const DeleteDataFnc _deleter=&PODBlockDeleter)
 Build an item to store in the cache's Holder.
void setData (const DocumentType _type, void *_data, const uint32 _size, const DeleteDataFnc _deleter=&PODBlockDeleter) volatile
 Set the data, type, and deleter for this item.
void setData (const DocumentType _type, void *_data, const uint32 _size, const DeleteDataFnc _deleter=&PODBlockDeleter)
 Set the data, size, type, and deleter for this item.
void setStatus (const Status _status) volatile
 Set the current status for this item.
void setStatus (const Status _status)
 Set the current status for this item.
void Suicide () volatile
 Make this item commit suicide (the item is deleted).
void Suicide ()
 Make this item commit suicide (the item is deleted).
 ~Item ()
 The only destructor.

Static Public Member Functions

template<typename T>
static void ArrayDeleteDeleter (T *ptr)
 Delete the data with delete[] operator.
template<typename T>
static void DeleteDeleter (T *ptr)
 Delete the data with delete operator.
static void FreeDeleter (void *ptr)
 Delete the data with free function.
static void NoDeleter (void *ptr)
 No deletion.
static CacheTime Now ()
 What time is it now ?
static void PODBlockDeleter (void *ptr)
 Convenience function that delete the allocated block of POD type.

Public Attributes

volatile Lock lock
 The lock when used in threaded environment.


Member Typedef Documentation

typedef void(*) Cache::Item::DeleteDataFnc(void *)

The deletion function pointer signature.


Member Enumeration Documentation

enum Cache::Item::DocumentType

The possible documents type.

Enumerator:
Unknown  The document type is unknown.
XML  The document is an XML stream.
HTML  The document is an HTML stream.
JPEGImage  The document is an image compressed using JPEG codec.
PNGImage  The document is an image compressed using PNG codec.
GIFImage  The document is an image compressed using GIF codec.
Stylesheet  The document is an external stylesheet stream.
ScriptFile  The document is an external script stream.

enum Cache::Item::Status

The possible item status.

Enumerator:
Unset  The item is not set yet.
WaitingFetching  The item is waiting to be fetched.
Ready  The item is ready.
FetchingError  The item fetching returned errors.
BadURI  The item had a bad or unsupported URI.


Constructor & Destructor Documentation

Cache::Item::Item ( const Strings::FastString _URL,
const DocumentType _type = Unknown,
void *  _data = 0,
const uint32  _size = 0,
const DeleteDataFnc  _deleter = &PODBlockDeleter 
) [inline]

Build an item to store in the cache's Holder.

Parameters:
_URL The item universal resource location
_type The document type (can be Unknown if assigned later on)
_data The document data (can be 0 if assigned later on)
_deleter The deleter function pointer (default is PODBlockDeleter)
See also:
Holder

Cache::Item::~Item (  )  [inline]

The only destructor.

For performance reason, this destructor is not virtual, so you can't inherit from this class


Member Function Documentation

template<typename T>
static void Cache::Item::ArrayDeleteDeleter ( T *  ptr  )  [inline, static]

Delete the data with delete[] operator.

Parameters:
ptr A pointer to a T object, allocated with new[]
Warning:
This is not correct C++, however, it's guarranted by standard that sizeof(T*) == sizeof(void*), so it's binary compatible.

void Cache::Item::deleteData (  )  volatile [inline]

Delete the item data (you should never call this, unless the data is updated).

void Cache::Item::deleteData (  )  [inline]

Delete the item data (you should never call this, unless the data is updated).

template<typename T>
static void Cache::Item::DeleteDeleter ( T *  ptr  )  [inline, static]

Delete the data with delete operator.

Parameters:
ptr A pointer to a T object, allocated with new
Warning:
This is not correct C++, however, it's guarranted by standard that sizeof(T*) == sizeof(void*), so it's binary compatible.

bool Cache::Item::fetchingError (  )  const volatile [inline]

Is this item on error ?

bool Cache::Item::fetchingError (  )  const [inline]

Does the fetching of this item gave error ?

static void Cache::Item::FreeDeleter ( void *  ptr  )  [inline, static]

Delete the data with free function.

Parameters:
ptr A pointer to a void *, allocated with malloc

const void* Cache::Item::getData (  )  const volatile [inline]

Get the data.

const void* Cache::Item::getData (  )  const [inline]

Get the data.

const uint32 Cache::Item::getDataSize (  )  const volatile [inline]

Get the data size.

const uint32 Cache::Item::getDataSize (  )  const [inline]

Get the data size.

const DocumentType Cache::Item::getDocumentType (  )  const volatile [inline]

Get the data type.

const DocumentType Cache::Item::getDocumentType (  )  const [inline]

Get the data type.

const Strings::FastString& Cache::Item::getDocumentURL (  )  const volatile [inline]

Get the document URL.

const Strings::FastString& Cache::Item::getDocumentURL (  )  const [inline]

Get the document URL.

const Status Cache::Item::getStatus (  )  const volatile [inline]

Get the current status.

const Status Cache::Item::getStatus (  )  const [inline]

Get the current status.

const CacheTime Cache::Item::getTimestamp (  )  const volatile [inline]

Get the document timestamp.

const CacheTime Cache::Item::getTimestamp (  )  const [inline]

Get the document timestamp.

static void Cache::Item::NoDeleter ( void *  ptr  )  [inline, static]

No deletion.

Warning:
You should never use this, unless the data lives in a memory block that is destroyed after all the cache holder is destroyed

static CacheTime Cache::Item::Now (  )  [inline, static]

What time is it now ?

static void Cache::Item::PODBlockDeleter ( void *  ptr  )  [inline, static]

Convenience function that delete the allocated block of POD type.

void Cache::Item::setData ( const DocumentType  _type,
void *  _data,
const uint32  _size,
const DeleteDataFnc  _deleter = &PODBlockDeleter 
) volatile [inline]

Set the data, type, and deleter for this item.

void Cache::Item::setData ( const DocumentType  _type,
void *  _data,
const uint32  _size,
const DeleteDataFnc  _deleter = &PODBlockDeleter 
) [inline]

Set the data, size, type, and deleter for this item.

void Cache::Item::setStatus ( const Status  _status  )  volatile [inline]

Set the current status for this item.

void Cache::Item::setStatus ( const Status  _status  )  [inline]

Set the current status for this item.

void Cache::Item::Suicide (  )  volatile [inline]

Make this item commit suicide (the item is deleted).

void Cache::Item::Suicide (  )  [inline]

Make this item commit suicide (the item is deleted).


Member Data Documentation

volatile Lock Cache::Item::lock

The lock when used in threaded environment.


The documentation for this class was generated from the following file:

(C) An X-Ryl669 project 2007

This document describes Unlimited Zooming Interface source code. UZI stands for Unlimited Zooming Interface, and source code license is