- ///////////////////////////////////////////////////////////////////
-
- struct ResPoolProxy::ScopedSaveState
- {
- NON_COPYABLE_BUT_MOVE( ScopedSaveState );
-
- ScopedSaveState( const ResPoolProxy & pool_r )
- : _pimpl( new Impl( pool_r ) )
- { _pimpl->saveState(); }
-
- ScopedSaveState( const ResPoolProxy & pool_r, const ResKind & kind_r )
- : _pimpl( new Impl( pool_r, kind_r ) )
- { _pimpl->saveState(); }
-
- ~ScopedSaveState()
- { if ( _pimpl ) _pimpl->restoreState(); }
-
- void acceptState()
- { _pimpl.reset(); }
-
- private:
- struct Impl
- {
- Impl( const ResPoolProxy & pool_r )
- : _pool( pool_r )
- {}
- Impl( const ResPoolProxy & pool_r, const ResKind & kind_r )
- : _pool( pool_r ), _kind( new ResKind( kind_r ) )
- {}
- void saveState()
- { if ( _kind ) _pool.saveState( *_kind ); else _pool.saveState(); }
- void restoreState()
- { if ( _kind ) _pool.restoreState( *_kind ); else _pool.restoreState(); }
- ResPoolProxy _pool;
- scoped_ptr<ResKind> _kind;
-
- };
- std::unique_ptr<Impl> _pimpl;
- };
-
- inline ResPoolProxy::ScopedSaveState ResPoolProxy::scopedSaveState() const
- { return ScopedSaveState( *this ); }
-
- inline ResPoolProxy::ScopedSaveState ResPoolProxy::scopedSaveState( const ResKind & kind_r ) const
- { return ScopedSaveState( *this, kind_r ); }
-