bitmapcachekey.cpp

Go to the documentation of this file.
00001 // $Id: bitmapcachekey.cpp 1282 2006-06-09 09:46:49Z alex $
00002 // BitmapCacheKey.cpp: implementation of the CBitmapCacheKey class.
00003 //
00005 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00006 ================================XARAHEADERSTART===========================
00007  
00008                Xara LX, a vector drawing and manipulation program.
00009                     Copyright (C) 1993-2006 Xara Group Ltd.
00010        Copyright on certain contributions may be held in joint with their
00011               respective authors. See AUTHORS file for details.
00012 
00013 LICENSE TO USE AND MODIFY SOFTWARE
00014 ----------------------------------
00015 
00016 This file is part of Xara LX.
00017 
00018 Xara LX is free software; you can redistribute it and/or modify it
00019 under the terms of the GNU General Public License version 2 as published
00020 by the Free Software Foundation.
00021 
00022 Xara LX and its component source files are distributed in the hope
00023 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00024 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00025 See the GNU General Public License for more details.
00026 
00027 You should have received a copy of the GNU General Public License along
00028 with Xara LX (see the file GPL in the root directory of the
00029 distribution); if not, write to the Free Software Foundation, Inc., 51
00030 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00031 
00032 
00033 ADDITIONAL RIGHTS
00034 -----------------
00035 
00036 Conditional upon your continuing compliance with the GNU General Public
00037 License described above, Xara Group Ltd grants to you certain additional
00038 rights. 
00039 
00040 The additional rights are to use, modify, and distribute the software
00041 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00042 library and any other such library that any version of Xara LX relased
00043 by Xara Group Ltd requires in order to compile and execute, including
00044 the static linking of that library to XaraLX. In the case of the
00045 "CDraw" library, you may satisfy obligation under the GNU General Public
00046 License to provide source code by providing a binary copy of the library
00047 concerned and a copy of the license accompanying it.
00048 
00049 Nothing in this section restricts any of the rights you have under
00050 the GNU General Public License.
00051 
00052 
00053 SCOPE OF LICENSE
00054 ----------------
00055 
00056 This license applies to this program (XaraLX) and its constituent source
00057 files only, and does not necessarily apply to other Xara products which may
00058 in part share the same code base, and are subject to their own licensing
00059 terms.
00060 
00061 This license does not apply to files in the wxXtra directory, which
00062 are built into a separate library, and are subject to the wxWindows
00063 license contained within that directory in the file "WXXTRA-LICENSE".
00064 
00065 This license does not apply to the binary libraries (if any) within
00066 the "libs" directory, which are subject to a separate license contained
00067 within that directory in the file "LIBS-LICENSE".
00068 
00069 
00070 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00071 ----------------------------------------------
00072 
00073 Subject to the terms of the GNU Public License (see above), you are
00074 free to do whatever you like with your modifications. However, you may
00075 (at your option) wish contribute them to Xara's source tree. You can
00076 find details of how to do this at:
00077   http://www.xaraxtreme.org/developers/
00078 
00079 Prior to contributing your modifications, you will need to complete our
00080 contributor agreement. This can be found at:
00081   http://www.xaraxtreme.org/developers/contribute/
00082 
00083 Please note that Xara will not accept modifications which modify any of
00084 the text between the start and end of this header (marked
00085 XARAHEADERSTART and XARAHEADEREND).
00086 
00087 
00088 MARKS
00089 -----
00090 
00091 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00092 designs are registered or unregistered trademarks, design-marks, and/or
00093 service marks of Xara Group Ltd. All rights in these marks are reserved.
00094 
00095 
00096       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00097                         http://www.xara.com/
00098 
00099 =================================XARAHEADEREND============================
00100  */
00101 
00102 #include "camtypes.h"
00103 
00104 //#include "bitmapcachekey.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 
00107 // Construction/Destruction
00109 
00110 CBitmapCacheKey::CBitmapCacheKey()
00111 {
00112     memset(&pOwner, 0, sizeof(CBitmapCacheKey)-((LPBYTE)&pOwner-(LPBYTE)this));
00113     pOwner = NULL;
00114     dPixelWidth = 0;
00115     nOption = 0;
00116 }
00117 
00118 CBitmapCacheKey::CBitmapCacheKey(LPVOID pNewOwner, double dNewPixelWidth, UINT32 nNewOption)
00119 {
00120     memset(&pOwner, 0, sizeof(CBitmapCacheKey)-((LPBYTE)&pOwner-(LPBYTE)this));
00121     pOwner = pNewOwner;
00122     dPixelWidth = dNewPixelWidth;
00123     nOption = nNewOption;
00124 }
00125 
00126 // Copy constructor
00127 // Required by CTypedPtrMap
00128 CBitmapCacheKey::CBitmapCacheKey(const CBitmapCacheKey& key)
00129 {
00130     memset(&pOwner, 0, sizeof(CBitmapCacheKey)-((LPBYTE)&pOwner-(LPBYTE)this));
00131     pOwner = key.pOwner;
00132     dPixelWidth = key.dPixelWidth;
00133     nOption = key.nOption;
00134 }
00135 
00136 CBitmapCacheKey::~CBitmapCacheKey()
00137 {
00138 
00139 }
00140 
00141 
00142 
00143 
00144 /********************************************************************************************
00145 
00146 >   CBitmapCacheKey::operator==()
00147     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00148     Created:    10/06/2004
00149     Inputs:     -
00150     Outputs:    -
00151     Returns:    TRUE if this key is exactly the same the the specified key
00152     Purpose:    Test whether this object has been constructed correctly
00153                 Required by CTypedPtrMap
00154     Errors:     -
00155     SeeAlso:    -
00156 
00157 ********************************************************************************************/
00158 bool CBitmapCacheKey::operator==(const CBitmapCacheKey& key) const
00159 {
00160     return (pOwner == key.pOwner &&
00161             dPixelWidth == key.dPixelWidth &&
00162             nOption == key.nOption
00163             );
00164 }
00165 
00166 
00167 
00168 
00169 /********************************************************************************************
00170 
00171 >   BOOL CBitmapCacheKey::IsValid() const
00172     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00173     Created:    10/06/2004
00174     Inputs:     -
00175     Outputs:    -
00176     Returns:    TRUE if this key is valid
00177                 FALSE otherwise
00178     Purpose:    Test whether this object has been constructed correctly
00179     Errors:     -
00180     SeeAlso:    -
00181 
00182 ********************************************************************************************/
00183 BOOL CBitmapCacheKey::IsValid() const
00184 {
00185     return (pOwner!=NULL && dPixelWidth!=0);
00186 }
00187 
00188 
00189 
00190 
00191 /********************************************************************************************
00192 
00193 >   UINT32 CBitmapCacheKey::Hash() const
00194     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00195     Created:    10/06/2004
00196     Inputs:     -
00197     Outputs:    -
00198     Returns:    UINT32 containing hashed value of all the bytes in this object
00199     Purpose:    Compute a Hash value to allow this object to be used as the key into
00200                 a Hash Table
00201     Errors:     -
00202     SeeAlso:    -
00203 
00204 ********************************************************************************************/
00205 UINT32 CBitmapCacheKey::Hash() const
00206 {
00207     UINT32 nHash = 0;
00208     //LPBYTE pThis = (LPBYTE)this;
00209     LPBYTE pThis = (LPBYTE)&pOwner;
00210     // Can't use sizeof class because that includes alignment bytes which contain random values
00211     //const INT32 bytesize = sizeof(CBitmapCacheKey);
00212     const size_t bytesize = sizeof(CBitmapCacheKey)-((LPBYTE)&pOwner-(LPBYTE)this);
00213 
00214     for(unsigned i=0; i<bytesize; i++)
00215     {
00216         nHash = (nHash<<5)+nHash + *pThis++;
00217     }
00218 
00219     return nHash;
00220 }
00221 

Generated on Sat Nov 10 03:44:24 2007 for Camelot by  doxygen 1.4.4