16 #ifndef __OMNETPP_CHASHER_H 
   17 #define __OMNETPP_CHASHER_H 
   23 #include "simkerneldefs.h" 
   25 #include "cexception.h" 
   45     void merge(uint32_t x) {
 
   47         value = ((value << 1) | (value >> 31)) ^ x;
 
   50     void merge2(uint64_t x) {
 
   52         merge((uint32_t)(x>>32));
 
   59     cHasher() {ASSERT(
sizeof(uint32_t)==4); ASSERT(
sizeof(
double)==8); value = 0;}
 
   63     void reset() {value = 0;}
 
   64     void add(
char d)           {merge((uint32_t)d);}
 
   65     void add(
short d)          {merge((uint32_t)d);}
 
   66     void add(
int d)            {merge((uint32_t)d);}
 
   67     void add(
long d)           {int64_t tmp=d; merge2((uint64_t)tmp);}
 
   68     void add(
long long d)      {merge2((uint64_t)d);}
 
   69     void add(
unsigned char d)  {merge((uint32_t)d);}
 
   70     void add(
unsigned short d) {merge((uint32_t)d);}
 
   71     void add(
unsigned int d)   {merge((uint32_t)d);}
 
   72     void add(
unsigned long d)  {uint64_t tmp=d; merge2(tmp);}
 
   73     void add(
unsigned long long d)  {merge2(d);}
 
   75         if (std::isnan(d)) d = NAN;  
 
   77         union _ {
double _; uint64_t i;};
 
   78         merge2(((
union _ *)&d)->i);  
 
   81     void add(
const char *s)    {
if (s) add(s, strlen(s)+1); 
else add(0);}
 
   82     void add(
const std::string& s) {add(s.c_str(), s.size()+1);}
 
   83     void add(
const void *p, 
size_t length);
 
   85     cHasher& operator<<(
const T& x) {add(x); 
return *
this;} 
 
  100     uint32_t parse(
const char *hash) 
const;
 
  105     bool equals(
const char *hash) 
const;
 
  110     std::string str() 
const;