The Gaudi Framework  master (37c0b60a)
Containers::key_traits< KEY > Struct Template Reference

Key traits class. More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/KeyedTraits.h>

Public Types

typedef KEY key_type
 Declaration of key-type. More...
 
typedef KeyedObject< key_typeobj_type
 Declaration of keyed object type. More...
 

Static Public Member Functions

static key_type makeKey (long k)
 Create key from its full integer representation. More...
 
static key_type makeKey (int k)
 
static long identifier (const key_type &k)
 Full unhashed key identifier. More...
 
static long hash (const key_type &key_value)
 Hash function for this key. More...
 
static void setKey (obj_type *v, const key_type &k)
 Set object key when inserted into the container. More...
 
static bool checkKey (obj_type *v, const key_type &k)
 Check the validity of the object's key. More...
 
static long addRef (obj_type *v)
 Add reference counter to object when inserted into the container. More...
 
static long release (obj_type *v)
 Release reference to object. More...
 

Detailed Description

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

Key traits class.

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 47 of file KeyedTraits.h.

Member Typedef Documentation

◆ key_type

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

Declaration of key-type.

Definition at line 82 of file KeyedTraits.h.

◆ obj_type

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

Declaration of keyed object type.

Definition at line 84 of file KeyedTraits.h.

Member Function Documentation

◆ addRef()

template<class KEY >
static long Containers::key_traits< KEY >::addRef ( obj_type v)
inlinestatic

Add reference counter to object when inserted into the container.

Definition at line 111 of file KeyedTraits.h.

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

◆ checkKey()

template<class KEY >
static bool Containers::key_traits< KEY >::checkKey ( obj_type v,
const key_type k 
)
inlinestatic

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 103 of file KeyedTraits.h.

103  {
104 #ifdef CHECK_KEYED_CONTAINER
105  return ( v ) ? ( hash( v->key() ) == hash( k ) ) : false;
106 #else
107  return true;
108 #endif
109  }

◆ hash()

template<class KEY >
static long Containers::key_traits< KEY >::hash ( const key_type key_value)
inlinestatic

Hash function for this key.

Definition at line 94 of file KeyedTraits.h.

94 { return key_value; }

◆ identifier()

template<class KEY >
static long Containers::key_traits< KEY >::identifier ( const key_type k)
inlinestatic

Full unhashed key identifier.

Definition at line 92 of file KeyedTraits.h.

92 { return k; }

◆ makeKey() [1/2]

template<class KEY >
static key_type Containers::key_traits< KEY >::makeKey ( int  k)
inlinestatic

Definition at line 90 of file KeyedTraits.h.

90 { return key_type( k ); }

◆ makeKey() [2/2]

template<class KEY >
static key_type Containers::key_traits< KEY >::makeKey ( long  k)
inlinestatic

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 89 of file KeyedTraits.h.

89 { return key_type( k ); }

◆ release()

template<class KEY >
static long Containers::key_traits< KEY >::release ( obj_type v)
inlinestatic

Release reference to object.

Definition at line 113 of file KeyedTraits.h.

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

◆ setKey()

template<class KEY >
static void Containers::key_traits< KEY >::setKey ( obj_type v,
const key_type k 
)
inlinestatic

Set object key when inserted into the container.

Definition at line 96 of file KeyedTraits.h.

96  {
97  if ( v ) v->setKey( k );
98  }

The documentation for this struct was generated from the following file:
Containers::key_traits::key_type
KEY key_type
Declaration of key-type.
Definition: KeyedTraits.h:82
Properties.v
v
Definition: Properties.py:122
Containers::key_traits::hash
static long hash(const key_type &key_value)
Hash function for this key.
Definition: KeyedTraits.h:94