Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67659 - sandbox/gil/boost/gil/extension/io2/detail
From: dsaritz_at_[hidden]
Date: 2011-01-04 17:27:15


Author: psiha
Date: 2011-01-04 17:27:03 EST (Tue, 04 Jan 2011)
New Revision: 67659
URL: http://svn.boost.org/trac/boost/changeset/67659

Log:
Added debugging facilities to the cumulative_result class and moved it to the detail/shared.hpp header.
Text files modified:
   sandbox/gil/boost/gil/extension/io2/detail/libx_shared.hpp | 35 -------------------------
   sandbox/gil/boost/gil/extension/io2/detail/shared.hpp | 56 ++++++++++++++++++++++++++++++++++++++++
   2 files changed, 56 insertions(+), 35 deletions(-)

Modified: sandbox/gil/boost/gil/extension/io2/detail/libx_shared.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/detail/libx_shared.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/detail/libx_shared.hpp 2011-01-04 17:27:03 EST (Tue, 04 Jan 2011)
@@ -252,41 +252,6 @@
     {}
 };
 
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \class cumulative_result
-///
-////////////////////////////////////////////////////////////////////////////////
-
-class cumulative_result
-{
-public:
- cumulative_result() : result_( true ) {}
-
- void accumulate( bool const new_result )
- {
- result_ &= new_result;
- // Catch the error early when debugging...
- BOOST_ASSERT( result_ );
- }
-
- template <typename T1, typename T2>
- void accumulate_equal ( T1 const new_result, T2 const desired_result ) { accumulate( new_result == desired_result ); }
- template <typename T>
- void accumulate_different( T const new_result, T const undesired_result ) { accumulate( new_result != undesired_result ); }
- template <typename T1, typename T2>
- void accumulate_greater ( T1 const new_result, T2 const threshold ) { accumulate( new_result > threshold ); }
-
- void throw_if_error( char const * const description ) const { io_error_if_not( result_, description ); }
-
- bool & get() { return result_; }
-
-private:
- bool result_;
-};
-
-
 //------------------------------------------------------------------------------
 } // namespace detail
 //------------------------------------------------------------------------------

Modified: sandbox/gil/boost/gil/extension/io2/detail/shared.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/detail/shared.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/detail/shared.hpp 2011-01-04 17:27:03 EST (Tue, 04 Jan 2011)
@@ -42,6 +42,62 @@
     #define BOOST_GIL_CAN_THROW
 #endif
 
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \class cumulative_result
+///
+////////////////////////////////////////////////////////////////////////////////
+
+class cumulative_result
+{
+public:
+ cumulative_result() : result_( true ) { mark_as_inspected(); }
+
+ void accumulate( bool const new_result )
+ {
+ // Catch the error early when debugging...
+ BOOST_ASSERT( new_result );
+ result_ &= new_result;
+ mark_as_dirty();
+ }
+
+ template <typename T1, typename T2>
+ void accumulate_equal ( T1 const new_result, T2 const desired_result ) { accumulate( new_result == desired_result ); }
+ template <typename T>
+ void accumulate_different( T const new_result, T const undesired_result ) { accumulate( new_result != undesired_result ); }
+ template <typename T1, typename T2>
+ void accumulate_greater ( T1 const new_result, T2 const threshold ) { accumulate( new_result > threshold ); }
+
+ bool failed() const
+ {
+ mark_as_inspected();
+ return !result_;
+ }
+
+ void throw_if_error( char const * const description ) const
+ {
+ mark_as_inspected();
+ io_error_if_not( result_, description );
+ }
+
+private:
+ bool result_;
+
+ // correct usage debugging section
+#ifdef _DEBUG
+public:
+ ~cumulative_result() { BOOST_ASSERT( inspected_ ); }
+private:
+ void mark_as_dirty () const { inspected_ = false; }
+ void mark_as_inspected() const { inspected_ = true ; }
+ mutable bool inspected_;
+#else
+ void mark_as_dirty () const {}
+ void mark_as_inspected() const {}
+#endif // _DEBUG
+};
+
 //------------------------------------------------------------------------------
 } // namespace detail
 //------------------------------------------------------------------------------


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk