Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/express/checksumHashGenerator.I

Go to the documentation of this file.
00001 // Filename: checksumHashGenerator.I
00002 // Created by:  drose (14May01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: ChecksumHashGenerator::add_int
00022 //       Access: Public
00023 //  Description: Adds another integer to the hash so far.  This
00024 //               function should be overridden in base classes; this
00025 //               is the principle implementation of the HashGenerator.
00026 ////////////////////////////////////////////////////////////////////
00027 INLINE void ChecksumHashGenerator::
00028 add_int(int sum) {
00029   _hash += (size_t)sum;
00030 }
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //     Function: ChecksumHashGenerator::add_bool
00034 //       Access: Public
00035 //  Description: Adds a boolean flag.
00036 ////////////////////////////////////////////////////////////////////
00037 INLINE void ChecksumHashGenerator::
00038 add_bool(bool flag) {
00039   add_int(flag);
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: ChecksumHashGenerator::add_fp
00044 //       Access: Public
00045 //  Description: Adds a floating-point number, first converting it to
00046 //               fixed point by dividing it by the indicated
00047 //               threshold.
00048 ////////////////////////////////////////////////////////////////////
00049 INLINE void ChecksumHashGenerator::
00050 add_fp(float number, float threshold) {
00051   add_int((int)(number / threshold));
00052 }
00053 
00054 ////////////////////////////////////////////////////////////////////
00055 //     Function: ChecksumHashGenerator::add_fp
00056 //       Access: Public
00057 //  Description: Adds a floating-point number, first converting it to
00058 //               fixed point by dividing it by the indicated
00059 //               threshold.
00060 ////////////////////////////////////////////////////////////////////
00061 INLINE void ChecksumHashGenerator::
00062 add_fp(double number, double threshold) {
00063   add_int((int)(number / threshold));
00064 }
00065 
00066 ////////////////////////////////////////////////////////////////////
00067 //     Function: ChecksumHashGenerator::add_pointer
00068 //       Access: Public
00069 //  Description: Adds a pointer, derived simply by casting the pointer
00070 //               to an integer.  This should be good enough even on
00071 //               architectures for which this cast is lossy.
00072 ////////////////////////////////////////////////////////////////////
00073 INLINE void ChecksumHashGenerator::
00074 add_pointer(void *ptr) {
00075   add_int((int)ptr);
00076 }

Generated on Fri May 2 00:38:18 2003 for Panda by doxygen1.3