{ _savedStatus = _status; }
void restoreState() const
{ _status = _savedStatus; }
+ bool sameState() const
+ {
+ if ( _status.getTransactValue() != _savedStatus.getTransactValue()
+ && !_status.isBySolver() )
+ return false;
+ if ( _status.isLicenceConfirmed() != _savedStatus.isLicenceConfirmed() )
+ return false;
+ return true;
+ }
private:
- mutable ResStatus _savedStatus;
+ mutable ResStatus _savedStatus;
//@}
public:
void PoolItem_Ref::restoreState() const
{ _pimpl->restoreState(); }
+ bool PoolItem_Ref::sameState() const
+ { _pimpl->sameState(); }
+
/******************************************************************
**
** FUNCTION NAME : operator<<
friend class PoolItemSaver;
void saveState() const;
void restoreState() const;
+ bool sameState() const;
//@}
};
///////////////////////////////////////////////////////////////////
std::for_each( pool_r.byKindBegin(kind_r), pool_r.byKindEnd(kind_r),
std::mem_fun_ref(&PoolItem::restoreState) );
}
+
+ bool diffState( ResPool_Ref pool_r, const ResObject::Kind & kind_r ) const
+ {
+ // return whether some PoolItem::sameState reported \c false.
+ return( invokeOnEach( pool_r.byKindBegin(kind_r), pool_r.byKindEnd(kind_r),
+ std::mem_fun_ref(&PoolItem::sameState) ) < 0 );
+ }
};
struct SelPoolHelper
void restoreState( const ResObject::Kind & kind_r ) const
{ PoolItemSaver().restoreState( _pool, kind_r ); }
+ bool diffState( const ResObject::Kind & kind_r ) const
+ { return PoolItemSaver().diffState( _pool, kind_r ); }
+
private:
ResPool_Ref _pool;
mutable SelectablePool _selPool;
void ResPoolProxy::restoreState( const ResObject::Kind & kind_r ) const
{ _pimpl->restoreState( kind_r ); }
+ bool ResPoolProxy::diffState( const ResObject::Kind & kind_r ) const
+ { _pimpl->diffState( kind_r ); }
+
/******************************************************************
**
** FUNCTION NAME : operator<<
public:
/** \name Save and restore state per kind of resolvable.
- * Simple version, no savety net.
+ * Simple version, no savety net. So don't restore or diff,
+ * if you didn't save before.
+ *
+ * Diff returns true, if current stat differs from the saved
+ * state.
*/
//@{
void saveState( const ResObject::Kind & kind_r ) const;
template<class _Res>
void restoreState() const
{ return restoreState( ResTraits<_Res>::kind ); }
+
+ bool diffState( const ResObject::Kind & kind_r ) const;
+
+ template<class _Res>
+ bool diffState() const
+ { return diffState( ResTraits<_Res>::kind ); }
//@}
private: