1 /****************************************************************************** 2 * 3 * Purpose: Declaration of the VecSegIndex class. 4 * 5 * This class is used to manage a vector segment data block index. There 6 * will be two instances created, one for the record data (sec_record) and 7 * one for the vertices (sec_vert). This class is exclusively a private 8 * helper class for VecSegHeader. 9 * 10 ****************************************************************************** 11 * Copyright (c) 2009 12 * PCI Geomatics, 50 West Wilmot Street, Richmond Hill, Ont, Canada 13 * 14 * Permission is hereby granted, free of charge, to any person obtaining a 15 * copy of this software and associated documentation files (the "Software"), 16 * to deal in the Software without restriction, including without limitation 17 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 18 * and/or sell copies of the Software, and to permit persons to whom the 19 * Software is furnished to do so, subject to the following conditions: 20 * 21 * The above copyright notice and this permission notice shall be included 22 * in all copies or substantial portions of the Software. 23 * 24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 25 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 * DEALINGS IN THE SOFTWARE. 31 ****************************************************************************/ 32 33 #ifndef __INCLUDE_SEGMENT_VECSEGDATAINDEX_H 34 #define __INCLUDE_SEGMENT_VECSEGDATAINDEX_H 35 36 #include "pcidsk_config.h" 37 #include "pcidsk_types.h" 38 #include "pcidsk_vectorsegment.h" 39 40 #include <map> 41 #include <vector> 42 43 namespace PCIDSK 44 { 45 class VecSegDataIndex 46 { 47 friend class CPCIDSKVectorSegment; 48 friend class VecSegHeader; 49 50 public: 51 VecSegDataIndex(); 52 ~VecSegDataIndex(); 53 54 void Initialize( CPCIDSKVectorSegment *seg, 55 int section ); 56 57 uint32 SerializedSize(); 58 59 void SetDirty(); 60 void Flush(); 61 62 const std::vector<uint32> *GetIndex(); 63 void AddBlockToIndex( uint32 block ); 64 void VacateBlockRange( uint32 start, uint32 count ); 65 66 uint32 GetSectionEnd(); 67 void SetSectionEnd( uint32 new_size ); 68 69 private: 70 CPCIDSKVectorSegment *vs; 71 72 int section; 73 74 uint32 offset_on_disk_within_section; 75 uint32 size_on_disk; 76 77 bool block_initialized; 78 uint32 block_count; 79 uint32 bytes; 80 std::vector<uint32> block_index; 81 bool dirty; 82 }; 83 } // end namespace PCIDSK 84 85 #endif // __INCLUDE_SEGMENT_VECSEGDATAINDEX_H 86