OTB  6.7.0
Orfeo Toolbox
Public Member Functions | Private Member Functions | Private Attributes | List of all members
otb::ogr::Field Class Reference

#include <otbOGRFieldWrapper.h>

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

Public Member Functions

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

Private Member Functions

void CheckInvariants () 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.
bool UncheckedHasBeenSet () const
 
void UncheckedUnset () const
 
std::ostream & UncheckedPrintSelf (std::ostream &os, itk::Indent indent) const
 
void UncheckedAssign (Field const &f)
 

Private Attributes

FieldDefn m_Definition
 
boost::shared_ptr< OGRFeature > & m_Feature
 
int m_index
 

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 108 of file otbOGRFieldWrapper.h.

Constructor & Destructor Documentation

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

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 494 of file otbOGRFieldWrapper.hxx.

References CheckInvariants(), otb::Wrapper::MetaDataHelper::GetType(), and GetType().

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 426 of file otbOGRFieldWrapper.hxx.

References m_Feature, and m_index.

Referenced by Assign().

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

Field definition accessor.

Definition at line 120 of file otbOGRFieldWrapper.h.

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

Field name accessor.

Definition at line 126 of file otbOGRFieldWrapper.h.

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

Field type accessor.

Definition at line 123 of file otbOGRFieldWrapper.h.

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

template<typename T >
T otb::ogr::Field::GetValue ( void  ) const
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 456 of file otbOGRFieldWrapper.hxx.

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

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

Tells whether the field value has been set.

Definition at line 480 of file otbOGRFieldWrapper.hxx.

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.

OGRField & otb::ogr::Field::ogr ( ) const
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 517 of file otbOGRFieldWrapper.hxx.

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

Prints self into stream.

Definition at line 472 of file otbOGRFieldWrapper.hxx.

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 435 of file otbOGRFieldWrapper.hxx.

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

void otb::ogr::Field::UncheckedAssign ( Field const &  f)
private
bool otb::ogr::Field::UncheckedHasBeenSet ( ) const
private
std::ostream& otb::ogr::Field::UncheckedPrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const
private
void otb::ogr::Field::UncheckedUnset ( ) const
private
void otb::ogr::Field::Unset ( ) const
inline

Unsets the value of the field.

Definition at line 487 of file otbOGRFieldWrapper.hxx.

Member Data Documentation

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

Definition of the field.

Definition at line 214 of file otbOGRFieldWrapper.h.

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

Link to the actual OGRFeature in charge of the fields.

Definition at line 216 of file otbOGRFieldWrapper.h.

Referenced by CheckInvariants().

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

Index of the field according to the feature definition.

Definition at line 223 of file otbOGRFieldWrapper.h.

Referenced by CheckInvariants().


The documentation for this class was generated from the following files: