libpcidsk
|
00001 /****************************************************************************** 00002 * 00003 * Purpose: PCIDSK Vector Segment public interface. Declaration. 00004 * 00005 ****************************************************************************** 00006 * Copyright (c) 2009 00007 * PCI Geomatics, 50 West Wilmot Street, Richmond Hill, Ont, Canada 00008 * 00009 * Permission is hereby granted, free of charge, to any person obtaining a 00010 * copy of this software and associated documentation files (the "Software"), 00011 * to deal in the Software without restriction, including without limitation 00012 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00013 * and/or sell copies of the Software, and to permit persons to whom the 00014 * Software is furnished to do so, subject to the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be included 00017 * in all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00020 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00022 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00024 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00025 * DEALINGS IN THE SOFTWARE. 00026 ****************************************************************************/ 00027 00028 #ifndef __INCLUDE_PCIDSK_VECTORSEGMENT_H 00029 #define __INCLUDE_PCIDSK_VECTORSEGMENT_H 00030 00031 #include <string> 00032 #include <vector> 00033 #include <iterator> 00034 #include "pcidsk_shape.h" 00035 00036 namespace PCIDSK 00037 { 00038 class ShapeIterator; 00039 00040 /************************************************************************/ 00041 /* PCIDSKVectorSegment */ 00042 /************************************************************************/ 00043 00078 class PCIDSK_DLL PCIDSKVectorSegment 00079 { 00080 public: 00081 virtual ~PCIDSKVectorSegment() {} 00082 00093 virtual std::string GetRst() = 0; 00094 00095 00105 virtual int GetFieldCount() = 0; 00106 00113 virtual std::string GetFieldName(int field_index) = 0; 00114 00121 virtual std::string GetFieldDescription(int field_index) = 0; 00122 00129 virtual ShapeFieldType GetFieldType(int field_index) = 0; 00130 00137 virtual std::string GetFieldFormat(int field_index) = 0; 00138 00145 virtual ShapeField GetFieldDefault(int field_index) = 0; 00146 00151 virtual ShapeIterator begin() = 0; 00152 00157 virtual ShapeIterator end() = 0; 00158 00163 virtual ShapeId FindFirst() = 0; 00164 00170 virtual ShapeId FindNext(ShapeId id) = 0; 00171 00177 virtual void GetVertices( ShapeId id, 00178 std::vector<ShapeVertex>& list ) = 0; 00179 00185 virtual void GetFields( ShapeId id, 00186 std::vector<ShapeField>& list ) = 0; 00187 }; 00188 00189 /************************************************************************/ 00190 /* ShapeIterator */ 00191 /************************************************************************/ 00192 00194 00195 class ShapeIterator : public std::iterator<std::input_iterator_tag, ShapeId> 00196 { 00197 ShapeId id; 00198 PCIDSKVectorSegment *seg; 00199 00200 public: 00201 ShapeIterator(PCIDSKVectorSegment *seg_in) 00202 : seg(seg_in) { id = seg->FindFirst(); } 00203 ShapeIterator(PCIDSKVectorSegment *seg_in, ShapeId id_in ) 00204 : id(id_in), seg(seg_in) {} 00205 ShapeIterator(const ShapeIterator& mit) : id(mit.id), seg(mit.seg) {} 00206 ShapeIterator& operator++() { id=seg->FindNext(id); return *this;} 00207 ShapeIterator& operator++(int) { id=seg->FindNext(id); return *this;} 00208 bool operator==(const ShapeIterator& rhs) {return id == rhs.id;} 00209 bool operator!=(const ShapeIterator& rhs) {return id != rhs.id;} 00210 ShapeId& operator*() {return id;} 00211 }; 00212 00213 } // end namespace PCIDSK 00214 00215 #endif // __INCLUDE_PCIDSK_VECTORSEGMENT_H