Filter Library Camera Interface Physics

CHashBuilder Class Reference
[Dialog Related]

#include <ToolHashBuilder.h>

List of all members.


Detailed Description

This class can incrementally build a hash value from fundamental types. It is used to determine if settings on a dialog changed or have remained as they where with respect to a previously taken snapshot.

Example.

 char   character = 'a';
 int    integer   =  0;
 char*  string    = "";

 typedef CHashBuilder::ValueType HashType;

 HashType LastHash = 0;

 HashType ComputeHash()
 {
    CHashBuilder NewHash;

    return NewHash = character, integer, string;
 }

 bool SomethingChanged()
 {
    return ComputeHash() != LastHash;
 }

 void MyInitialize()
 {
    LastHash = ComputeHash();
 }

 void MyAction()
 {
    if ( SomethingChanged() )
    {
       // act on changes and save new hash value

       LastHash = ComputeHash();
    }
    else
    {
       ; // no action required
    }
 }

Class CHashBuilder was inspired on the article "A Checksum Algorithm" by Joseph M. Newcomer [CHECKSUM].

Class CHashBuilder uses the hash function by P.J. Weinberger from the dragon book [Aho et al., 1986].

Definition at line 85 of file ToolHashBuilder.h.

Public Types

typedef CHashBuilder Self
 this type.
typedef unsigned char uchar
 unsigned character type;
typedef unsigned int uint
 unsigned integer type.
typedef unsigned long ulong
 unsigned long integer type.
typedef ulong ValueType
 the hash type.

Public Member Functions

Operators
Selfoperator= (char c)
 assign a character.
Selfoperator= (int i)
 assign an integer.
Selfoperator= (long int i)
 assign a long integer.
Selfoperator= (unsigned char c)
 assign an unsigned character.
Selfoperator= (uint i)
 assign an unsigned integer.
Selfoperator= (ulong i)
 assign an unsigned long integer.
Selfoperator= (float f)
 assign a float.
Selfoperator= (double d)
 assign a double.
Selfoperator= (const char *s)
 assign a C-string.
Selfoperator, (char chr)
 add a character.
Selfoperator, (uchar chr)
 add a unsigned character.
Selfoperator, (int i)
 add an integer.
Selfoperator, (uint i)
 add an unsigned integer.
Selfoperator, (long i)
 add a long integer.
Selfoperator, (ulong i)
 add an unsigned long integer.
Selfoperator, (float f)
 add a float.
Selfoperator, (double d)
 add a double.
Selfoperator, (const char *s)
 add a C-string.
 operator ValueType () const
 convert to ValueType, return hash value; alias for GetHash().
Accessors
ValueType GetHash () const
 the current hash value.
Mutators
void Clear ()
 clear the hash value.
SelfAdd (unsigned char chr)
 add an unsigned character to the hash (P.J.
SelfAdd (char chr)
 add a character to the hash.
SelfAdd (int i)
 add an integer to the hash.
SelfAdd (uint i)
 add an unsigned integer to the hash.
SelfAdd (long i)
 add a long to the hash.
SelfAdd (ulong i)
 add an unsigned long to the hash.
SelfAdd (float f)
 add a float to the hash.
SelfAdd (double d)
 add a float to the hash.
SelfAdd (const char *string)
 add a C-string to the hash.

Private Attributes

ValueType m_hash


Member Function Documentation

Self& CHashBuilder::Add ( unsigned char  chr  )  [inline]

Weinberger's hash, hash_pjw).

Definition at line 390 of file ToolHashBuilder.h.

References m_hash.

Referenced by Add(), CHashBuilder(), operator,(), and operator=().


The documentation for this class was generated from the following file:
Camera Filter Library documentation © 2004-2007 by Leiden Probe Microscopy