Panda3D
checksumHashGenerator.I
1 // Filename: checksumHashGenerator.I
2 // Created by: drose (14May01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: ChecksumHashGenerator::add_int
18 // Access: Public
19 // Description: Adds another integer to the hash so far. This
20 // function should be overridden in base classes; this
21 // is the principle implementation of the HashGenerator.
22 ////////////////////////////////////////////////////////////////////
23 INLINE void ChecksumHashGenerator::
24 add_int(long sum) {
25  _hash += (size_t)sum;
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: ChecksumHashGenerator::add_bool
30 // Access: Public
31 // Description: Adds a boolean flag.
32 ////////////////////////////////////////////////////////////////////
33 INLINE void ChecksumHashGenerator::
34 add_bool(bool flag) {
35  add_int(flag);
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: ChecksumHashGenerator::add_fp
40 // Access: Public
41 // Description: Adds a floating-point number, first converting it to
42 // fixed point by dividing it by the indicated
43 // threshold.
44 ////////////////////////////////////////////////////////////////////
45 INLINE void ChecksumHashGenerator::
46 add_fp(float number, float threshold) {
47  add_int((long)(number / threshold));
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: ChecksumHashGenerator::add_fp
52 // Access: Public
53 // Description: Adds a floating-point number, first converting it to
54 // fixed point by dividing it by the indicated
55 // threshold.
56 ////////////////////////////////////////////////////////////////////
57 INLINE void ChecksumHashGenerator::
58 add_fp(double number, double threshold) {
59  add_int((long)(number / threshold));
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: ChecksumHashGenerator::add_pointer
64 // Access: Public
65 // Description: Adds a pointer, derived simply by casting the pointer
66 // to an integer. This should be good enough even on
67 // architectures for which this cast is lossy.
68 ////////////////////////////////////////////////////////////////////
69 INLINE void ChecksumHashGenerator::
70 add_pointer(void *ptr) {
71  add_int((long)ptr);
72 }
void add_fp(float num, float threshold)
Adds a floating-point number, first converting it to fixed point by dividing it by the indicated thre...
void add_bool(bool flag)
Adds a boolean flag.
void add_pointer(void *ptr)
Adds a pointer, derived simply by casting the pointer to an integer.
void add_int(long num)
Adds another integer to the hash so far.