diff --git a/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.cxx b/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.cxx index 713c4c92efec720220d57d6e26ae87daa36fe9f7..af319236f5f199b3018525dc440cdc6bef817d01 100644 --- a/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.cxx +++ b/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.cxx @@ -20,7 +20,6 @@ /*===============================[ Includes ]================================*/ /*===========================================================================*/ #include "otbOGRFieldWrapper.h" -#include <cassert> #include "ogr_feature.h" #include "otbOGRFeatureWrapper.h" #include "otbJoinContainer.h" @@ -106,10 +105,9 @@ otb::ogr::Field::Field(otb::ogr::Feature & feature, size_t index) CheckInvariants(); } -std::ostream & otb::ogr::Field::PrintSelf( +std::ostream & otb::ogr::Field::UncheckedPrintSelf( std::ostream& os, itk::Indent indent) const { - CheckInvariants(); const itk::Indent one_indent = itk::Indent().GetNextIndent(); // os << indent << "|" << one_indent << "+ "; os << indent << this->GetName() << ": "; @@ -141,14 +139,12 @@ std::ostream & otb::ogr::Field::PrintSelf( return os; } -bool otb::ogr::Field::HasBeenSet() const +bool otb::ogr::Field::UncheckedHasBeenSet() const { - CheckInvariants(); return m_Feature->IsFieldSet(m_index); } -void otb::ogr::Field::Unset() const +void otb::ogr::Field::UncheckedUnset() const { - CheckInvariants(); m_Feature->UnsetField(m_index); } diff --git a/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.h b/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.h index f35556adb62e3948027cbf445da520014e044838..4fa1d6b38e389dca26dcdb7767a7091d94ca1355 100644 --- a/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.h +++ b/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.h @@ -123,9 +123,22 @@ public: /** Prints self into stream. */ std::ostream & PrintSelf(std::ostream&os, itk::Indent indent) const; private: + /**\name 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 (<em>Non-Virtual Interface</em>) 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; + //@} + /** * Internal function to check class invariants. - * If any invariant is broken, an assertion ill be fired. + * If any invariant is broken, an assertion will be fired. * \internal * This function is defined inlined in order to be able to inhibit invariants * checking depending on the compilation mode (on \c NDEBUG preprocessor diff --git a/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.txx b/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.txx index bfb8a31e77860fc67ae1036ee71f5f8440163bb1..cda766e6fca56078f45eaf9983980fa996bc9b20 100644 --- a/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.txx +++ b/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.txx @@ -311,4 +311,26 @@ T otb::ogr::Field::GetValue() const return GetterType::call(*m_Feature, m_index); } +inline +std::ostream & otb::ogr::Field::PrintSelf( + std::ostream& os, itk::Indent indent) const +{ + CheckInvariants(); + return UncheckedPrintSelf(os, indent); +} + +inline +bool otb::ogr::Field::HasBeenSet() const +{ + CheckInvariants(); + return UncheckedHasBeenSet(); +} + +inline +void otb::ogr::Field::Unset() const +{ + CheckInvariants(); + UncheckedUnset(); +} + #endif // __otbOGRFieldWrapper_txx