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

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

#include <otbOGRFieldWrapper.h>

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

Public Member Functions

 Field (Feature &feature, vcl_size_t index)
 
void Assign (Field const &f)
 
FieldDefn const & GetDefinition () const
 Field definition accessor. More...
 
std::string GetName () const
 Field name accessor. More...
 
OGRFieldType GetType () const
 Field type accessor. More...
 
template<typename T >
GetValue () const
 
bool HasBeenSet () const
 Tells whether the field value has been set. More...
 
OGRField & ogr () const
 
OGRField & ogr ()
  More...
 
std::ostream & PrintSelf (std::ostream &os, itk::Indent indent) const
 
template<typename T >
void SetValue (T const &value)
 
void Unset () const
 Unsets the value of the field. More...
 

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
 Definition of the field. More...
 
boost::shared_ptr< OGRFeature > & m_Feature
 Link to the actual OGRFeature in charge of the fields. More...
 
vcl_size_t 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 91 of file otbOGRFieldWrapper.h.

Constructor & Destructor Documentation

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

Constructor.

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

Definition at line 111 of file otbOGRFieldWrapper.cxx.

References CheckInvariants().

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 434 of file otbOGRFieldWrapper.txx.

References CheckInvariants(), 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 366 of file otbOGRFieldWrapper.txx.

Referenced by Assign(), and Field().

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

Field definition accessor.

Definition at line 102 of file otbOGRFieldWrapper.h.

References m_Definition.

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

Field name accessor.

Definition at line 108 of file otbOGRFieldWrapper.h.

References otb::ogr::FieldDefn::GetName(), and m_Definition.

Referenced by printField().

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

Field type accessor.

Definition at line 105 of file otbOGRFieldWrapper.h.

References otb::ogr::FieldDefn::GetType(), and m_Definition.

Referenced by Assign().

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 396 of file otbOGRFieldWrapper.txx.

References otb::ogr::internal::BOOST_STATIC_ASSERT().

Referenced by PushVisitor::operator()(), 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 420 of file otbOGRFieldWrapper.txx.

Referenced by UncheckedAssign().

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 circonstance try to delete the OGRField obtained this way.

Definition at line 448 of file otbOGRFieldWrapper.txx.

Referenced by UncheckedAssign().

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 circonstance try to delete the OGRField obtained this way.

Definition at line 454 of file otbOGRFieldWrapper.txx.

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

Prints self into stream.

Definition at line 412 of file otbOGRFieldWrapper.txx.

Referenced by otb::ogr::Feature::UncheckedPrintSelf().

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 375 of file otbOGRFieldWrapper.txx.

References otb::ogr::internal::BOOST_MPL_ASSERT_NOT().

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

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

Definition at line 163 of file otbOGRFieldWrapper.cxx.

References HasBeenSet(), and ogr().

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

Definition at line 153 of file otbOGRFieldWrapper.cxx.

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

Definition at line 119 of file otbOGRFieldWrapper.cxx.

References itk::Indent::GetNextIndent(), and otb::Join().

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

Definition at line 158 of file otbOGRFieldWrapper.cxx.

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

Unsets the value of the field.

Definition at line 427 of file otbOGRFieldWrapper.txx.

Member Data Documentation

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

Definition of the field.

Definition at line 192 of file otbOGRFieldWrapper.h.

Referenced by GetDefinition(), GetName(), and GetType().

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

Link to the actual OGRFeature in charge of the fields.

Definition at line 194 of file otbOGRFieldWrapper.h.

vcl_size_t otb::ogr::Field::m_index
private

Index of the field according to the feature definition.

Definition at line 200 of file otbOGRFieldWrapper.h.


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

Generated at Sun May 19 2013 04:29:45 for Orfeo Toolbox with doxygen 1.8.3.1