ircproxy  The Ultimate Cyborg

Index< INDEX_POOL_TYPE > Class Template Reference

#include <Index.h>

List of all members.


Detailed Description

template<typename INDEX_POOL_TYPE>
class Index< INDEX_POOL_TYPE >

Index generator for instances of type INDEX_POOL_TYPE.

Definition at line 21 of file Index.h.


Public Member Functions

int index (void) const
 Return a small integer, unique for the instance and constant throughout it's life time.

Static Public Member Functions

static int size (void)
 Return the size of a vector that would be needed for the largest index currently in use.

Static Public Attributes

static int const max_index = 8 * sizeof(long)
 The maximum number of allowed INDEX_POOL_TYPE instances.

Protected Member Functions

 Index (void)
 Construct an Index base class, automatically setting M_index to a free index.
 ~Index (void)
 Destructor. Frees up the index for reuse.

Private Attributes

int const M_index
 The index of this instance.

Static Private Attributes

static long S_index_pool = ~0
 A mask to keep track of used indices (a set bit marks a FREE index).

Constructor & Destructor Documentation

template<typename INDEX_POOL_TYPE>
Index< INDEX_POOL_TYPE >::Index ( void   )  [inline, protected]

Construct an Index base class, automatically setting M_index to a free index.

Definition at line 31 of file Index.h.

00031 : M_index(ffsl(S_index_pool) - 1) { ASSERT(M_index != -1); S_index_pool &= ~(1UL << M_index); }

template<typename INDEX_POOL_TYPE>
Index< INDEX_POOL_TYPE >::~Index ( void   )  [inline, protected]

Destructor. Frees up the index for reuse.

Definition at line 33 of file Index.h.

00033 { S_index_pool |= (1 << M_index); }


Member Function Documentation

template<typename INDEX_POOL_TYPE>
int Index< INDEX_POOL_TYPE >::index ( void   )  const [inline]

Return a small integer, unique for the instance and constant throughout it's life time.

Definition at line 37 of file Index.h.

00037 { return M_index; }

template<typename INDEX_POOL_TYPE>
static int Index< INDEX_POOL_TYPE >::size ( void   )  [inline, static]

Return the size of a vector that would be needed for the largest index currently in use.

Definition at line 40 of file Index.h.

00040 { int r = 0; unsigned long i = (~static_cast<unsigned long>(S_index_pool)) << 1; while(i >>= 1) ++r; return r; }


Member Data Documentation

template<typename INDEX_POOL_TYPE>
int const Index< INDEX_POOL_TYPE >::max_index = 8 * sizeof(long) [static]

The maximum number of allowed INDEX_POOL_TYPE instances.

Definition at line 23 of file Index.h.

template<typename INDEX_POOL_TYPE>
long Index< INDEX_POOL_TYPE >::S_index_pool = ~0 [inline, static, private]

A mask to keep track of used indices (a set bit marks a FREE index).

Definition at line 26 of file Index.h.

Referenced by Index< ServerSession >::Index(), Index< ServerSession >::size(), and Index< ServerSession >::~Index().

template<typename INDEX_POOL_TYPE>
int const Index< INDEX_POOL_TYPE >::M_index [private]

The index of this instance.

Definition at line 27 of file Index.h.

Referenced by Index< ServerSession >::index(), Index< ServerSession >::Index(), and Index< ServerSession >::~Index().


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

Copyright © 2005-2007 Carlo Wood.  All rights reserved.