OTB  9.0.0
Orfeo Toolbox
List of all members
otb::ogr::Field Class Reference

#include <otbOGRFieldWrapper.h>

+ Collaboration diagram for otb::ogr::Field:

Public Member Functions

 Field (Feature &feature, int index)
 
FieldDefn const & GetDefinition () const
 
OGRFieldType GetType () const
 
std::string GetName () const
 
bool HasBeenSet () const
 
void Unset () const
 
template<typename T >
void SetValue (T const &value)
 
template<typename T >
GetValue () const
 
std::ostream & PrintSelf (std::ostream &os, itk::Indent indent) const
 
void Assign (Field const &f)
 
OGRField & ogr ()
 
OGRField & ogr () const
 

Unchecked definitions

All the definitions that follow do the real work. However, they are not the exposed public functions. The design of this class follows the principle behind the NVI (Non-Virtual Interface) pattern:

  • The public functions are inlined and check invariants and preconditions,
  • While the private functions do the work.
FieldDefn m_Definition
 
std::shared_ptr< OGRFeature > & m_Feature
 
int m_index
 
bool UncheckedHasBeenSet () const
 
void UncheckedUnset () const
 
std::ostream & UncheckedPrintSelf (std::ostream &os, itk::Indent indent) const
 
void UncheckedAssign (Field const &f)
 
void CheckInvariants () const
 

Detailed Description

Encapsulation of OGRField Instances of Field are expected to be built from an existing Feature with which they'll share their owning OGRFeature.

A Field instance works as a proxy. Copying a field will only have it share the actual OGRField between several instances. In order to copy a field value from another field, use Field::assign().

Invariant
m_Feature shall be valid (i.e. not wrapping a null OGRFeature).
m_index < m_Feature->GetFieldCount().
m_Feature->GetFieldDefnRef(m_index) != 0.
See also
OGRField
Since
OTB v 3.14.0

Definition at line 117 of file otbOGRFieldWrapper.h.

Constructor & Destructor Documentation

◆ Field()

otb::ogr::Field::Field ( Feature feature,
int  index 
)

Constructor.

Parameters
[in,out]featureFeature from which the field is.
[in]indexIndex of the field in the Feature.
Exceptions
None

Member Function Documentation

◆ Assign()

void otb::ogr::Field::Assign ( Field const &  f)
inline

Copies a field. As Field is a proxy type, this function is the only possible way to copy a field.

First, the field must be defined with a definition, then it could be set from another field value.

Field srcField = srcFeature[42];
Feature dstFeature(layerDefinition);
Field dst(dstFeature, 12);
dstField.Assign(srcField);

Definition at line 495 of file otbOGRFieldWrapper.hxx.

References CheckInvariants(), and GetType().

◆ CheckInvariants()

void otb::ogr::Field::CheckInvariants ( ) const
inlineprivate

Internal function to check class invariants. If any invariant is broken, an assertion will be fired.

Definition at line 435 of file otbOGRFieldWrapper.hxx.

References m_Feature, and m_index.

Referenced by Assign().

◆ GetDefinition()

FieldDefn const& otb::ogr::Field::GetDefinition ( ) const
inline

Field definition accessor.

Definition at line 129 of file otbOGRFieldWrapper.h.

◆ GetName()

std::string otb::ogr::Field::GetName ( ) const
inline

Field name accessor.

Definition at line 139 of file otbOGRFieldWrapper.h.

◆ GetType()

OGRFieldType otb::ogr::Field::GetType ( ) const
inline

Field type accessor.

Definition at line 134 of file otbOGRFieldWrapper.h.

Referenced by Assign(), and otb::OGRLayerStreamStitchingFilter< TInputImage >::ProcessStreamingLine().

◆ GetValue()

template<typename T >
T otb::ogr::Field::GetValue
inline

Value getter.

Template Parameters
Texpected type for the stored value.
Exceptions
None
Precondition
T must match the field's type.
The field must have set.

Definition at line 463 of file otbOGRFieldWrapper.hxx.

Referenced by otb::OGRLayerStreamStitchingFilter< TInputImage >::ProcessStreamingLine(), and otb::PersistentImageToOGRLayerSegmentationFilter< TImageType, TSegmentationFilter >::ProcessTile().

◆ HasBeenSet()

bool otb::ogr::Field::HasBeenSet ( ) const
inline

Tells whether the field value has been set.

Definition at line 483 of file otbOGRFieldWrapper.hxx.

◆ ogr() [1/2]

OGRField & otb::ogr::Field::ogr ( )
inline

Access to the raw underlying OGR data. This function provides an abstraction leak in case deeper control on the underlying OGRFeature is required.

Warning
You must under no circumstance try to delete the OGRField obtained this way.

Definition at line 508 of file otbOGRFieldWrapper.hxx.

◆ ogr() [2/2]

OGRField& otb::ogr::Field::ogr ( ) const

Access to the raw underlying OGR data. This function provides an abstraction leak in case deeper control on the underlying OGRFeature is required.

Warning
You must under no circumstance try to delete the OGRField obtained this way.

◆ PrintSelf()

std::ostream & otb::ogr::Field::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const
inline

Prints self into stream.

Definition at line 477 of file otbOGRFieldWrapper.hxx.

◆ SetValue()

template<typename T >
void otb::ogr::Field::SetValue ( T const &  value)
inline

Value setter.

Parameters
[in]valueNew value for the field.
Exceptions
None
Precondition
value's kind must match the field's type.

Definition at line 443 of file otbOGRFieldWrapper.hxx.

Referenced by otb::PersistentImageToOGRLayerSegmentationFilter< TImageType, TSegmentationFilter >::ProcessTile().

◆ UncheckedAssign()

void otb::ogr::Field::UncheckedAssign ( Field const &  f)
private

Definition of the field.

◆ UncheckedHasBeenSet()

bool otb::ogr::Field::UncheckedHasBeenSet ( ) const
private

Definition of the field.

◆ UncheckedPrintSelf()

std::ostream& otb::ogr::Field::UncheckedPrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const
private

Definition of the field.

◆ UncheckedUnset()

void otb::ogr::Field::UncheckedUnset ( ) const
private

Definition of the field.

◆ Unset()

void otb::ogr::Field::Unset ( ) const
inline

Unsets the value of the field.

Definition at line 489 of file otbOGRFieldWrapper.hxx.

Member Data Documentation

◆ m_Definition

FieldDefn otb::ogr::Field::m_Definition
private

Definition of the field.

Definition at line 231 of file otbOGRFieldWrapper.h.

◆ m_Feature

std::shared_ptr<OGRFeature>& otb::ogr::Field::m_Feature
private

Link to the actual OGRFeature in charge of the fields.

Definition at line 233 of file otbOGRFieldWrapper.h.

Referenced by CheckInvariants().

◆ m_index

int otb::ogr::Field::m_index
private

Index of the field according to the feature definition.

Definition at line 240 of file otbOGRFieldWrapper.h.

Referenced by CheckInvariants().


The documentation for this class was generated from the following files:
otb::ogr::Field::Field
Field(Feature &feature, int index)