| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# Containers::key_traits< KEY > Struct Template Reference

Definition of the key traits class. More...

`#include <KeyedTraits.h>`

List of all members.

## Public Types
typedef KEY | key_type
| Declaration of key-type.
typedef KeyedObject< key_type > | obj_type
| Declaration of keyed object type.
## Static Public Member Functions
static key_type | makeKey (long k)
| Create key from its full integer representation.
static key_type | makeKey (int k)
static long | identifier (const key_type &k)
| Full unhashed key identifier.
static long | hash (const key_type &key_value)
| Hash function for this key.
static void | setKey (obj_type *v, const key_type &k)
| Set object key when inserted into the container.
static bool | checkKey (obj_type *v, const key_type &k)
| Check the validity of the object's key.
static long | addRef (obj_type *v)
| Add reference counter to object when inserted into the container.
static long | release (obj_type *v)
| Release reference to object.

## Detailed Description

### template<class KEY>
struct Containers::key_traits< KEY >

Definition of the key traits class.

This is the default class for keys. This implementation works "as is" for integer, long etc. keys.

For all other types of keys, this class must be either partially or completely specialized.

Author:
  M.Frank CERN/LHCb

Version:
  1.0

Definition at line 64 of file KeyedTraits.h.

## Member Typedef Documentation

template<class KEY>

typedef KEY Containers::key_traits< KEY >::key_type

Declaration of key-type.

Definition at line 66 of file KeyedTraits.h.

template<class KEY>

typedef KeyedObject<key_type> Containers::key_traits< KEY >::obj_type

Declaration of keyed object type.

Definition at line 68 of file KeyedTraits.h.

## Member Function Documentation

template<class KEY>

static key_type Containers::key_traits< KEY >::makeKey | ( | long | k | ) | `[inline, static]`

Create key from its full integer representation.

Not implementing on specialization may inhibit the creation of keys, i.e. then a key must be supplied at insertion time.

Definition at line 73 of file KeyedTraits.h.

    00073 {return key_type(k); }

template<class KEY>

static key_type Containers::key_traits< KEY >::makeKey | ( | int | k | ) | `[inline, static]`

Definition at line 74 of file KeyedTraits.h.

    00074 {return key_type(k); }

template<class KEY>

static long Containers::key_traits< KEY >::identifier | ( | const key_type & | k | ) | `[inline, static]`

Full unhashed key identifier.

Definition at line 76 of file KeyedTraits.h.

    00076 {return k;           }

template<class KEY>

static long Containers::key_traits< KEY >::hash | ( | const key_type & | key_value | ) | `[inline, static]`

Hash function for this key.

Definition at line 78 of file KeyedTraits.h.

    00078 {return key_value;   }

template<class KEY>

static void Containers::key_traits< KEY >::setKey | ( | obj_type * | v,
|  | const key_type & | k |
| ) |  |  | `[inline, static]`

Set object key when inserted into the container.

Definition at line 80 of file KeyedTraits.h.

    00080 {if(v)v->setKey(k);  }

template<class KEY>

static bool Containers::key_traits< KEY >::checkKey | ( | obj_type * | v,
|  | const key_type & | k |
| ) |  |  | `[inline, static]`

Check the validity of the object's key.

Select if key-checks should be performed by switching on/off the macro CHECK_KEYED_CONTAINER.

Definition at line 85 of file KeyedTraits.h.

    00085                                                         {
    00086 #ifdef CHECK_KEYED_CONTAINER
    00087       return (v) ? (hash(v->key())==hash(k)) : false;
    00088 #else
    00089       return true;
    00090 #endif
    00091     }

template<class KEY>

static long Containers::key_traits< KEY >::addRef | ( | obj_type * | v | ) | `[inline, static]`

Add reference counter to object when inserted into the container.

Definition at line 93 of file KeyedTraits.h.

    00093 {   return (v) ? v->addRef()  : 0; }

template<class KEY>

static long Containers::key_traits< KEY >::release | ( | obj_type * | v | ) | `[inline, static]`

Release reference to object.

Definition at line 95 of file KeyedTraits.h.

    00095 {   return (v) ? v->release() : 0; }

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiKernel/GaudiKernel/KeyedTraits.h