Panda3D
 All Classes Functions Variables Enumerations
checksumHashGenerator.I
00001 // Filename: checksumHashGenerator.I
00002 // Created by:  drose (14May01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: ChecksumHashGenerator::add_int
00018 //       Access: Public
00019 //  Description: Adds another integer to the hash so far.  This
00020 //               function should be overridden in base classes; this
00021 //               is the principle implementation of the HashGenerator.
00022 ////////////////////////////////////////////////////////////////////
00023 INLINE void ChecksumHashGenerator::
00024 add_int(long sum) {
00025   _hash += (size_t)sum;
00026 }
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //     Function: ChecksumHashGenerator::add_bool
00030 //       Access: Public
00031 //  Description: Adds a boolean flag.
00032 ////////////////////////////////////////////////////////////////////
00033 INLINE void ChecksumHashGenerator::
00034 add_bool(bool flag) {
00035   add_int(flag);
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: ChecksumHashGenerator::add_fp
00040 //       Access: Public
00041 //  Description: Adds a floating-point number, first converting it to
00042 //               fixed point by dividing it by the indicated
00043 //               threshold.
00044 ////////////////////////////////////////////////////////////////////
00045 INLINE void ChecksumHashGenerator::
00046 add_fp(float number, float threshold) {
00047   add_int((long)(number / threshold));
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: ChecksumHashGenerator::add_fp
00052 //       Access: Public
00053 //  Description: Adds a floating-point number, first converting it to
00054 //               fixed point by dividing it by the indicated
00055 //               threshold.
00056 ////////////////////////////////////////////////////////////////////
00057 INLINE void ChecksumHashGenerator::
00058 add_fp(double number, double threshold) {
00059   add_int((long)(number / threshold));
00060 }
00061 
00062 ////////////////////////////////////////////////////////////////////
00063 //     Function: ChecksumHashGenerator::add_pointer
00064 //       Access: Public
00065 //  Description: Adds a pointer, derived simply by casting the pointer
00066 //               to an integer.  This should be good enough even on
00067 //               architectures for which this cast is lossy.
00068 ////////////////////////////////////////////////////////////////////
00069 INLINE void ChecksumHashGenerator::
00070 add_pointer(void *ptr) {
00071   add_int((long)ptr);
00072 }
 All Classes Functions Variables Enumerations