diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-03-18 16:14:58 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-03-19 23:41:09 +0100 |
commit | 3170b41ddcc69a2f65d8ae48352a183937badce9 (patch) | |
tree | 6f7e61d433ed18ca469dc964082591d2c10eff40 | |
parent | 6c58493295547a83aecfc5d69b17316e980f8548 (diff) |
rename SwClientIter to sw::ClientIteratorBase
Change-Id: I31ddba4e4b0020ed8187d67eb69353f81da8bd1c
-rw-r--r-- | sw/inc/calbck.hxx | 104 | ||||
-rw-r--r-- | sw/source/core/attr/calbck.cxx | 12 |
2 files changed, 59 insertions, 57 deletions
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx index e4b93c8fa899..d3080c7e0757 100644 --- a/sw/inc/calbck.hxx +++ b/sw/inc/calbck.hxx @@ -64,11 +64,11 @@ class SfxHint; class SwModify; class SwClient; -class SwClientIter; template<typename E, typename S> class SwIterator; namespace sw { + class ClientIteratorBase; struct LegacyModifyHint SAL_FINAL: SfxHint { LegacyModifyHint(const SfxPoolItem* pOld, const SfxPoolItem* pNew) : m_pOld(pOld), m_pNew(pNew) {}; @@ -80,7 +80,7 @@ namespace sw { friend class ::SwModify; friend class ::SwClient; - friend class ::SwClientIter; + friend class ::sw::ClientIteratorBase; private: WriterListener* m_pLeft; WriterListener* m_pRight; ///< double-linked list of other clients @@ -99,7 +99,7 @@ class SW_DLLPUBLIC SwClient : ::sw::WriterListener { // avoids making the details of the linked list and the callback method public friend class SwModify; - friend class SwClientIter; + friend class sw::ClientIteratorBase; SwModify *pRegisteredIn; ///< event source @@ -243,60 +243,62 @@ protected: { if(m_pToTell) m_pToTell->SwClientNotifyCall(rModify, rHint); } }; -class SwClientIter SAL_FINAL : public sw::Ring<SwClientIter> +namespace sw { - friend SwModify; - //friend SwClient* SwModify::Remove(SwClient*); - template<typename E, typename S> friend class SwIterator; ///< for typed interation - - const SwModify& m_rRoot; - - // the current object in an iteration - SwClient* m_pCurrent; - - SwClientIter( const SwModify& rModify ) - : m_rRoot(rModify) - { - MoveTo(our_pClientIters); - our_pClientIters = this; - m_pCurrent = m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends()); - } - // in case the current object is already removed, the next object in the list - // is marked down to become the current object in the next step - // this is necessary because iteration requires access to members of the current object - SwClient* m_pPosition; - SwClient* GetLeftOfPos() { return static_cast<SwClient*>(m_pPosition->m_pLeft); } - SwClient* GetRighOfPos() { return static_cast<SwClient*>(m_pPosition->m_pRight); } - SwClient* GoStart() - { - if((m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends()))) - while( m_pPosition->m_pLeft ) - m_pPosition = static_cast<SwClient*>(m_pPosition->m_pLeft); - return m_pCurrent = m_pPosition; - } - const SwModify& GetModify() const { return m_rRoot; } - - static SW_DLLPUBLIC SwClientIter* our_pClientIters; - -public: - ~SwClientIter() SAL_OVERRIDE + class ClientIteratorBase SAL_FINAL : public sw::Ring< ::sw::ClientIteratorBase > { - assert(our_pClientIters); - if(our_pClientIters == this) - our_pClientIters = unique() ? nullptr : GetNextInRing(); - MoveTo(nullptr); - } - // return "true" if an object was removed from a client chain in iteration - // adding objects to a client chain in iteration is forbidden - // SwModify::Add() asserts this - bool IsChanged() const { return m_pPosition != m_pCurrent; } -}; + friend SwModify; + template<typename E, typename S> friend class ::SwIterator; ///< for typed interation + + const SwModify& m_rRoot; + + // the current object in an iteration + SwClient* m_pCurrent; + + ClientIteratorBase( const SwModify& rModify ) + : m_rRoot(rModify) + { + MoveTo(our_pClientIters); + our_pClientIters = this; + m_pCurrent = m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends()); + } + // in case the current object is already removed, the next object in the list + // is marked down to become the current object in the next step + // this is necessary because iteration requires access to members of the current object + SwClient* m_pPosition; + SwClient* GetLeftOfPos() { return static_cast<SwClient*>(m_pPosition->m_pLeft); } + SwClient* GetRighOfPos() { return static_cast<SwClient*>(m_pPosition->m_pRight); } + SwClient* GoStart() + { + if((m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends()))) + while( m_pPosition->m_pLeft ) + m_pPosition = static_cast<SwClient*>(m_pPosition->m_pLeft); + return m_pCurrent = m_pPosition; + } + const SwModify& GetModify() const { return m_rRoot; } + + static SW_DLLPUBLIC ClientIteratorBase* our_pClientIters; + + public: + ~ClientIteratorBase() SAL_OVERRIDE + { + assert(our_pClientIters); + if(our_pClientIters == this) + our_pClientIters = unique() ? nullptr : GetNextInRing(); + MoveTo(nullptr); + } + // return "true" if an object was removed from a client chain in iteration + // adding objects to a client chain in iteration is forbidden + // SwModify::Add() asserts this + bool IsChanged() const { return m_pPosition != m_pCurrent; } + }; +} template< typename TElementType, typename TSource > class SwIterator SAL_FINAL { static_assert(std::is_base_of<SwClient,TElementType>::value, "TElementType needs to be derived from SwClient"); static_assert(std::is_base_of<SwModify,TSource>::value, "TSource needs to be derived from SwModify"); - SwClientIter aClientIter; + sw::ClientIteratorBase aClientIter; public: SwIterator( const TSource& rSrc ) : aClientIter(rSrc) {} @@ -341,7 +343,7 @@ public: template< typename TSource > class SwIterator<SwClient, TSource> { static_assert(std::is_base_of<SwModify,TSource>::value, "TSource needs to be derived from SwModify"); - SwClientIter aClientIter; + sw::ClientIteratorBase aClientIter; public: SwIterator( const TSource& rSrc ) : aClientIter(rSrc) {} SwClient* First() diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx index e4eb51372739..86f2d7459ec1 100644 --- a/sw/source/core/attr/calbck.cxx +++ b/sw/source/core/attr/calbck.cxx @@ -148,9 +148,9 @@ void SwModify::Add( SwClient* pDepend ) if(pDepend->pRegisteredIn != this ) { #if OSL_DEBUG_LEVEL > 0 - if(SwClientIter::our_pClientIters) + if(sw::ClientIteratorBase::our_pClientIters) { - for(auto& rIter : SwClientIter::our_pClientIters->GetRingContainer()) + for(auto& rIter : sw::ClientIteratorBase::our_pClientIters->GetRingContainer()) { OSL_ENSURE( &rIter.GetModify() != pRoot, "Client added to active ClientIter" ); } @@ -201,10 +201,10 @@ SwClient* SwModify::Remove( SwClient* pDepend ) if( pR ) pR->m_pLeft = pL; - // update ClientIters - if(SwClientIter::our_pClientIters) + // update ClientIterators + if(sw::ClientIteratorBase::our_pClientIters) { - for(auto& rIter : SwClientIter::our_pClientIters->GetRingContainer()) + for(auto& rIter : sw::ClientIteratorBase::our_pClientIters->GetRingContainer()) { if( rIter.m_pCurrent == pDepend || rIter.m_pPosition == pDepend ) { @@ -259,5 +259,5 @@ void SwModify::CheckCaching( const sal_uInt16 nWhich ) } } -SwClientIter* SwClientIter::our_pClientIters = nullptr; +sw::ClientIteratorBase* sw::ClientIteratorBase::our_pClientIters = nullptr; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |