ATLAS Offline Software
Loading...
Searching...
No Matches
IdHashTableHelper< N, ID, HASH > Class Template Reference

Helper base class for instantiation of templated class IdentifierHashTable. More...

#include <IdHashTableHelper.h>

Collaboration diagram for IdHashTableHelper< N, ID, HASH >:

Public Types

enum  { NFIELDS = N , NMAX =UINT_MAX }
 N is the number of fields to use from the identifier. More...
typedef ID IdentifierType
 define type IdentifierType
typedef HASH HashType
 define type HashType
typedef HASH ValueType
 needed for MultiDimArray<> instantiation

Public Member Functions

 IdHashTableHelper ()
 Default constructor.
 IdHashTableHelper (const IdentifierType &id)
 Constructor to initialise identifier.
 IdHashTableHelper (int fields[N])
 Constructor to initialise fields.
virtual ~IdHashTableHelper ()
 virtual destructor needed because of derivation
const IdentifierTypegetId () const
 Get the identifier.
void setId (const IdentifierType &id)
 Set (only) the identifier.
int operator[] (unsigned int fieldIndex) const
 Return the value encoded in field.
void setField (int index, int value)
 Set field at index to value.
void setFields (int fields[N])
 Set fields from array.

Static Public Member Functions

static void setDefaults (const IdentifierType &defId, const HashType &defHash)
 Set the default (invalid) values for identifier and hash.
static bool isValid (const IdentifierType &)
static HashType defaultHash ()
 Returns default (=invalid) hash.
static IdentifierType defaultIdentifier ()
 Return default (=invalid) identifier.
static ValueType defaultValue ()
 Return default hash.

Private Attributes

IdentifierType m_id
int m_fields [N]

Static Private Attributes

static IdentifierType s_defaultId
static HashType s_defaultHash

Detailed Description

template<unsigned int N, class ID, class HASH>
class IdHashTableHelper< N, ID, HASH >

Helper base class for instantiation of templated class IdentifierHashTable.

Definition at line 24 of file IdHashTableHelper.h.

Member Typedef Documentation

◆ HashType

template<unsigned int N, class ID, class HASH>
typedef HASH IdHashTableHelper< N, ID, HASH >::HashType

define type HashType

Definition at line 35 of file IdHashTableHelper.h.

◆ IdentifierType

template<unsigned int N, class ID, class HASH>
typedef ID IdHashTableHelper< N, ID, HASH >::IdentifierType

define type IdentifierType

Definition at line 33 of file IdHashTableHelper.h.

◆ ValueType

template<unsigned int N, class ID, class HASH>
typedef HASH IdHashTableHelper< N, ID, HASH >::ValueType

needed for MultiDimArray<> instantiation

Definition at line 37 of file IdHashTableHelper.h.

Member Enumeration Documentation

◆ anonymous enum

template<unsigned int N, class ID, class HASH>
anonymous enum

N is the number of fields to use from the identifier.

NMAX is just to make sure we get unsigned int type of enum.

Enumerator
NFIELDS 
NMAX 

Definition at line 31 of file IdHashTableHelper.h.

31{ NFIELDS = N, NMAX=UINT_MAX };
Helper base class for instantiation of templated class IdentifierHashTable.

Constructor & Destructor Documentation

◆ IdHashTableHelper() [1/3]

template<unsigned int N, class ID, class HASH>
IdHashTableHelper< N, ID, HASH >::IdHashTableHelper ( )
inline

Default constructor.

Identifier and fields are set to invalid.

Definition at line 87 of file IdHashTableHelper.h.

87 {
88 for ( unsigned int i = 0; i < N; ++i ) m_fields[i] = INT_MAX;
89}

◆ IdHashTableHelper() [2/3]

template<unsigned int N, class ID, class HASH>
IdHashTableHelper< N, ID, HASH >::IdHashTableHelper ( const IdentifierType & id)
explicit

Constructor to initialise identifier.

Fields are set to invalid.

◆ IdHashTableHelper() [3/3]

template<unsigned int N, class ID, class HASH>
IdHashTableHelper< N, ID, HASH >::IdHashTableHelper ( int fields[N])
inlineexplicit

Constructor to initialise fields.

Identifier is invalid.

Definition at line 101 of file IdHashTableHelper.h.

101 {
102 for ( unsigned int i = 0; i < N; ++i ) m_fields[i] = fields[i];
103}

◆ ~IdHashTableHelper()

template<unsigned int N, class ID, class HASH>
IdHashTableHelper< N, ID, HASH >::~IdHashTableHelper ( )
inlinevirtual

virtual destructor needed because of derivation

Definition at line 106 of file IdHashTableHelper.h.

106 {
107 // nothing to do
108}

Member Function Documentation

◆ defaultHash()

template<unsigned int N, class ID, class HASH>
IdHashTableHelper< N, ID, HASH >::HashType IdHashTableHelper< N, ID, HASH >::defaultHash ( )
inlinestatic

Returns default (=invalid) hash.

Definition at line 147 of file IdHashTableHelper.h.

147 {
148 return s_defaultHash;
149}
static HashType s_defaultHash

◆ defaultIdentifier()

template<unsigned int N, class ID, class HASH>
IdHashTableHelper< N, ID, HASH >::IdentifierType IdHashTableHelper< N, ID, HASH >::defaultIdentifier ( )
inlinestatic

Return default (=invalid) identifier.

Definition at line 153 of file IdHashTableHelper.h.

153 {
154 return s_defaultId;
155}
static IdentifierType s_defaultId

◆ defaultValue()

template<unsigned int N, class ID, class HASH>
IdHashTableHelper< N, ID, HASH >::ValueType IdHashTableHelper< N, ID, HASH >::defaultValue ( )
inlinestatic

Return default hash.

Needed for class MultiDimArray.

Definition at line 159 of file IdHashTableHelper.h.

159 {
160 return defaultHash();
161}
static HashType defaultHash()
Returns default (=invalid) hash.

◆ getId()

template<unsigned int N, class ID, class HASH>
const IdHashTableHelper< N, ID, HASH >::IdentifierType & IdHashTableHelper< N, ID, HASH >::getId ( ) const
inline

Get the identifier.

Definition at line 117 of file IdHashTableHelper.h.

117 {
118 return m_id;
119}
IdentifierType m_id

◆ isValid()

template<unsigned int N, class ID, class HASH>
bool IdHashTableHelper< N, ID, HASH >::isValid ( const IdentifierType & id)
inlinestatic

Definition at line 164 of file IdHashTableHelper.h.

164 {
165 return id != s_defaultId;
166}

◆ operator[]()

template<unsigned int N, class ID, class HASH>
int IdHashTableHelper< N, ID, HASH >::operator[] ( unsigned int fieldIndex) const
inline

Return the value encoded in field.

No range check!

Definition at line 111 of file IdHashTableHelper.h.

111 {
112 return m_fields[index];
113}

◆ setDefaults()

template<unsigned int N, class ID, class HASH>
void IdHashTableHelper< N, ID, HASH >::setDefaults ( const IdentifierType & defId,
const HashType & defHash )
inlinestatic

Set the default (invalid) values for identifier and hash.

Must be called (once per type T) if the default constructors of HashType or IdentifierType do not give a well defined (invalid!) value. This is typically the case for built-in types.

Definition at line 138 of file IdHashTableHelper.h.

140 {
143}

◆ setField()

template<unsigned int N, class ID, class HASH>
void IdHashTableHelper< N, ID, HASH >::setField ( int index,
int value )
inline

Set field at index to value.

No range check!

Definition at line 128 of file IdHashTableHelper.h.

128 {
130}

◆ setFields()

template<unsigned int N, class ID, class HASH>
void IdHashTableHelper< N, ID, HASH >::setFields ( int fields[N])
inline

Set fields from array.

Definition at line 133 of file IdHashTableHelper.h.

133 {
134 for ( unsigned int i = 0; i < N; ++i ) m_fields[i] = fields[i];
135}

◆ setId()

template<unsigned int N, class ID, class HASH>
void IdHashTableHelper< N, ID, HASH >::setId ( const IdentifierType & id)
inline

Set (only) the identifier.

Definition at line 123 of file IdHashTableHelper.h.

123 {
124 m_id = id;
125}

Member Data Documentation

◆ m_fields

template<unsigned int N, class ID, class HASH>
int IdHashTableHelper< N, ID, HASH >::m_fields[N]
private

Definition at line 78 of file IdHashTableHelper.h.

◆ m_id

template<unsigned int N, class ID, class HASH>
IdentifierType IdHashTableHelper< N, ID, HASH >::m_id
private

Definition at line 77 of file IdHashTableHelper.h.

◆ s_defaultHash

template<unsigned int N, class ID, class HASH>
HashType IdHashTableHelper< N, ID, HASH >::s_defaultHash
staticprivate

Definition at line 83 of file IdHashTableHelper.h.

◆ s_defaultId

template<unsigned int N, class ID, class HASH>
IdentifierType IdHashTableHelper< N, ID, HASH >::s_defaultId
staticprivate

Definition at line 82 of file IdHashTableHelper.h.


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