Orfeo Toolbox  3.16
otbOGRFeatureWrapper.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbOGRFeatureWrapper_txx
19 #define __otbOGRFeatureWrapper_txx
20 
21 /*===========================================================================*/
22 /*===============================[ Includes ]================================*/
23 /*===========================================================================*/
24 #include <cassert>
25 #include <boost/version.hpp>
26 #if BOOST_VERSION >= 104800
27 # include <boost/move/move.hpp> // since 1.48
28 #else
29 # include <boost/interprocess/detail/move.hpp>
30 #endif
31 
32 namespace otb
33 {
34 #if BOOST_VERSION >= 104800
35 using boost::move;
36 #else
37 using boost::interprocess::move;
38 #endif
39 }
40 
41 /*===========================================================================*/
42 /*================================[ Feature ]================================*/
43 /*===========================================================================*/
44 inline
46 {
48  return UncheckedClone();
49 }
50 
51 inline
52 void otb::ogr::Feature::SetFrom(Feature const& rhs, bool mustForgive)
53 {
54  CheckInvariants();
55  UncheckedSetFrom(rhs, mustForgive);
56 }
57 
58 inline
59 void otb::ogr::Feature::SetFrom(Feature const& rhs, int * map, bool mustForgive)
60 {
61  CheckInvariants();
62  UncheckedSetFrom(rhs, map, mustForgive);
63 }
64 
65 /*===========================================================================*/
66 /*================================[ Fields ]=================================*/
67 /*===========================================================================*/
68 inline
70 {
71  assert(index < GetSize() && "out of range field-index."); // also calls CheckInvariants();
72  return UncheckedGetElement(index);
73 }
74 
75 inline
77 {
78  return const_cast<Feature*>(this)->operator[](index);
79 }
80 
81 inline
83 {
84  CheckInvariants();
85  return UncheckedGetElement(name);
86 }
87 
88 inline
89 otb::ogr::Field const otb::ogr::Feature::operator[](std::string const& name) const
90 {
91  return const_cast<Feature*>(this)->operator[](name);
92 }
93 
94 inline
96 {
97  assert(index < GetSize() && "out of range field-index."); // also calls CheckInvariants();
98  return UncheckedGetFieldDefn(index);
99 }
100 
101 inline
103 {
104  CheckInvariants();
105  return UncheckedGetFieldDefn(name);
106 }
107 
108 inline
109 int otb::ogr::Feature::GetFieldIndex(std::string const& name) const
110 {
111  CheckInvariants();
112  return UncheckedGetFieldIndex(name);
113 }
114 
115 /*===========================================================================*/
116 /*==============================[ Properties ]===============================*/
117 /*===========================================================================*/
118 inline
120 {
121  CheckInvariants();
122  return UncheckedGetFID();
123 }
124 
125 inline
127 {
128  CheckInvariants();
129  UncheckedSetFID(fid);
130 }
131 
132 inline
133 OGRFeatureDefn& otb::ogr::Feature::GetDefn() const
134 {
135  CheckInvariants();
136  return UncheckedGetDefn();
137 }
138 
139 /*===========================================================================*/
140 /*==============================[ Geometries ]===============================*/
141 /*===========================================================================*/
142 inline
144 {
145  CheckInvariants();
146  OGRGeometry * g = geometry.get();
147  UncheckedSetGeometryDirectly(otb::move(geometry));
148  assert(m_Feature->GetGeometryRef() == g && "The new geometry hasn't been set as expected");
149  assert(! geometry && "UniqueGeometryPtr hasn't released its pointer");
150 }
151 
152 inline
154 {
155  CheckInvariants();
156  UniqueGeometryPtr res = UncheckedStealGeometry();
157  assert(! m_Feature->GetGeometryRef() && "Geometry hasn't been properly stolen");
158  return otb::move(res);
159 }
160 
161 inline
162 void otb::ogr::Feature::SetGeometry(OGRGeometry const* geometry)
163 {
164  CheckInvariants();
165  UncheckedSetGeometry(geometry);
166 }
167 
168 inline
169 OGRGeometry const* otb::ogr::Feature::GetGeometry() const
170 {
171  CheckInvariants();
172  return UncheckedGetGeometry();
173 }
174 
175 /*===========================================================================*/
176 /*=================================[ Misc ]==================================*/
177 /*===========================================================================*/
178 inline
179 OGRFeature & otb::ogr::Feature::ogr() const
180 { // not returning a OGRFeature const& because OGR is not const-correct
181  CheckInvariants();
182  return *m_Feature;
183 }
184 
185 inline
187 {
188  CheckInvariants();
189  return *m_Feature;
190 }
191 
192 inline
193 void otb::ogr::Feature::PrintSelf(std::ostream & os, itk::Indent indent) const
194 {
195  CheckInvariants();
196  UncheckedPrintSelf(os, indent);
197 }
198 
199 
200 inline
202 {
203  assert(m_Feature && "OGRFeature can't be null");
204 }
205 
206 #endif // __otbOGRFeatureWrapper_txx

Generated at Sun May 19 2013 00:42:31 for Orfeo Toolbox with doxygen 1.8.3.1