00001 // ***************************************************************************** 00002 // oaMapWindow.h 00003 // 00004 // This file contains the definitions for the oaMapWindow and oaMapFileWindow 00005 // classes. These utility classes are used to read data from, and write data 00006 // to, a memory-mapped disk file. 00007 // 00008 // Capabilities supported include: 00009 // 00010 // 1) The oaMapWindow base class implements a memory-mapped window that is 00011 // independent of the underlying backing storage (which may be a regular 00012 // file, a shared memory segment or the OS pagefile). 00013 // 2) The oaMapFileWindow class derives from oaMapWindow, associating the 00014 // window with a oaMapFile as the backing storage. oaMapFileWindow 00015 // belongs to a linked list of all windows for a specific oaMapFile. 00016 // While its memory-mapped window is closed, an existing oaMapFileWindow 00017 // object can switch to map a different oaMapFile. 00018 // 3) The oaMapFileWindow supports byte-swapping in order to support files 00019 // across machine types. 00020 // 3) These classes support files whose size is larger than 32 bits. As part 00021 // of this support, the API allows any 32-bit window of the file to be 00022 // mapped at a time. 00023 // 00024 // ***************************************************************************** 00025 // Except as specified in the OpenAccess terms of use of Cadence or Silicon 00026 // Integration Initiative, this material may not be copied, modified, 00027 // re-published, uploaded, executed, or distributed in any way, in any medium, 00028 // in whole or in part, without prior written permission from Cadence. 00029 // 00030 // Copyright 2002-2005 Cadence Design Systems, Inc. 00031 // All Rights Reserved. 00032 // 00033 // $Author: icftcm $ 00034 // $Revision: #1 $ 00035 // $Date: 2010/08/09 $ 00036 // $State: Exp $ 00037 // ***************************************************************************** 00038 // ***************************************************************************** 00039 00040 00041 00042 #if !defined(oaMapWindow_P) 00043 #define oaMapWindow_P 00044 00045 00046 00047 // ***************************************************************************** 00048 // Nested includes 00049 // ***************************************************************************** 00050 #include "oaPackedData.h" 00051 #include "oaMapFile.h" 00052 00053 00054 00055 // ***************************************************************************** 00056 // Declare and define types in the OpenAccess namespace. 00057 // ***************************************************************************** 00058 BEGIN_OA_NAMESPACE 00059 00060 00061 00062 // ***************************************************************************** 00063 // Forward Public Class Declarations 00064 // ***************************************************************************** 00065 class oaMapFile; 00066 00067 00068 00069 // ***************************************************************************** 00070 // oaMapWindow 00071 // ***************************************************************************** 00072 class OA_BASE_DLL_API oaMapWindow { 00073 public: 00074 oaMapWindow(oaByte *dataIn, 00075 oaUInt4 sizeIn, 00076 oaUInt8 offsetIn); 00077 virtual ~oaMapWindow(); 00078 00079 oaBoolean isMapped() const; 00080 oaBoolean isMapped(oaUInt4 sizeIn, 00081 oaUInt8 offsetIn, 00082 oaUInt4 &loc) const; 00083 00084 oaUInt4 getSize() const; 00085 oaUInt8 getOffset() const; 00086 oaUInt4 getLoc(oaUInt8 offsetIn) const; 00087 00088 oaByte &operator[](oaUInt4 index); 00089 00090 oaByte *getBytes(oaUInt4 loc) const; 00091 00092 const oaPackedData &data() const; 00093 00094 protected: 00095 oaByte *dataP; 00096 oaUInt8 offset; 00097 oaUInt4 size; 00098 00099 oaPackedData packedData; 00100 }; 00101 00102 00103 00104 // ***************************************************************************** 00105 // oaMapFileWindow 00106 // ***************************************************************************** 00107 class OA_BASE_DLL_API oaMapFileWindow : public oaMapWindow { 00108 public: 00109 00110 oaMapFileWindow(oaMapFile &mapFileIn); 00111 oaMapFileWindow(oaByte *dataIn, 00112 oaUInt4 sizeIn, 00113 oaUInt8 offsetIn, 00114 oaMapFile &mapFileIn); 00115 00116 virtual ~oaMapFileWindow(); 00117 00118 void map(oaUInt4 sizeIn = 0, 00119 oaUInt8 offsetIn = 0, 00120 void *mapLoc = NULL); 00121 00122 void unmap(); 00123 00124 oaUInt4 move(oaUInt4 sizeIn, 00125 oaUInt8 offsetIn, 00126 oaBoolean resize = false); 00127 oaUInt4 extend(oaUInt4 sizeIn); 00128 00129 oaMapFile &getMapFile(); 00130 const oaMapFile &getMapFile() const; 00131 oaMapFileWindow *getNext() const; 00132 00133 void setMapFile(oaMapFile &mapFileIn); 00134 void reset(); 00135 00136 void writeSwapCheck(oaUInt4 &loc); 00137 void readSwapCheck(oaUInt4 &loc); 00138 00139 oaBoolean getSwap() const; 00140 00141 protected: 00142 void setNext(oaMapFileWindow *nextIn); 00143 00144 void setSwap(oaBoolean swap); 00145 00146 oaMapFile *mapFile; 00147 oaMapFileWindow *next; 00148 00149 static const oaUInt4 swapTestInt; 00150 00151 friend class oaMapFile; 00152 }; 00153 00154 00155 00156 END_OA_NAMESPACE 00157 00158 #endif
Copyright © 2002 - 2010 Cadence Design Systems, Inc.
All Rights Reserved.