summaryrefslogtreecommitdiff
path: root/comphelper/source/container
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-10-06 11:58:03 +0200
committerNoel Grandin <noel@peralex.com>2015-10-07 08:27:25 +0200
commite7311cbaba988f96104dcbd96151436a6873e356 (patch)
treee363b0f5e0b5fe98c57abf757c61b9483d4bb441 /comphelper/source/container
parent05e61719e2f4456fab8f5f9875fd96c70c07c4cd (diff)
loplugin:mergeclasses
Change-Id: Ia3b63df5e8752690e3350f8a13445a096a839952
Diffstat (limited to 'comphelper/source/container')
-rw-r--r--comphelper/source/container/enumerablemap.cxx55
1 files changed, 18 insertions, 37 deletions
diff --git a/comphelper/source/container/enumerablemap.cxx b/comphelper/source/container/enumerablemap.cxx
index 5b5f3a197a44..0f9f679e04ca 100644
--- a/comphelper/source/container/enumerablemap.cxx
+++ b/comphelper/source/container/enumerablemap.cxx
@@ -83,8 +83,7 @@ namespace comphelper
using ::com::sun::star::lang::WrappedTargetException;
using ::com::sun::star::lang::DisposedException;
- class IMapModificationListener;
- typedef ::std::vector< IMapModificationListener* > MapListeners;
+ class MapEnumerator;
typedef ::std::map< Any, Any, LessPredicateAdapter > KeyedValues;
struct MapData
@@ -94,7 +93,7 @@ namespace comphelper
::std::unique_ptr< KeyedValues > m_pValues;
::std::shared_ptr< IKeyPredicateLess > m_pKeyCompare;
bool m_bMutable;
- MapListeners m_aModListeners;
+ ::std::vector< MapEnumerator* > m_aModListeners;
MapData()
:m_bMutable( true )
@@ -115,36 +114,21 @@ namespace comphelper
};
- /** implemented by components who want to be notified of modifications in the MapData they work with
- */
- class SAL_NO_VTABLE IMapModificationListener
- {
- public:
- /// called when the map was modified
- virtual void mapModified() = 0;
- virtual ~IMapModificationListener()
- {
- }
- };
-
- static void lcl_registerMapModificationListener( MapData& _mapData, IMapModificationListener& _listener )
+ static void lcl_registerMapModificationListener( MapData& _mapData, MapEnumerator& _listener )
{
#if OSL_DEBUG_LEVEL > 0
- for ( MapListeners::const_iterator lookup = _mapData.m_aModListeners.begin();
- lookup != _mapData.m_aModListeners.end();
- ++lookup
- )
+ for ( const MapEnumerator* lookup : _mapData.m_aModListeners )
{
- OSL_ENSURE( *lookup != &_listener, "lcl_registerMapModificationListener: this listener is already registered!" );
+ OSL_ENSURE( lookup != &_listener, "lcl_registerMapModificationListener: this listener is already registered!" );
}
#endif
_mapData.m_aModListeners.push_back( &_listener );
}
- static void lcl_revokeMapModificationListener( MapData& _mapData, IMapModificationListener& _listener )
+ static void lcl_revokeMapModificationListener( MapData& _mapData, MapEnumerator& _listener )
{
- for ( MapListeners::iterator lookup = _mapData.m_aModListeners.begin();
+ for ( ::std::vector< MapEnumerator* >::iterator lookup = _mapData.m_aModListeners.begin();
lookup != _mapData.m_aModListeners.end();
++lookup
)
@@ -159,16 +143,7 @@ namespace comphelper
}
- static void lcl_notifyMapDataListeners_nothrow( const MapData& _mapData )
- {
- for ( MapListeners::const_iterator loop = _mapData.m_aModListeners.begin();
- loop != _mapData.m_aModListeners.end();
- ++loop
- )
- {
- (*loop)->mapModified();
- }
- }
+ static void lcl_notifyMapDataListeners_nothrow( const MapData& _mapData );
// EnumerableMap
@@ -242,8 +217,7 @@ namespace comphelper
};
- class MapEnumerator:
- public IMapModificationListener, private boost::noncopyable
+ class MapEnumerator: private boost::noncopyable
{
public:
MapEnumerator( ::cppu::OWeakObject& _rParent, MapData& _mapData, const EnumerationType _type )
@@ -274,8 +248,8 @@ namespace comphelper
bool hasMoreElements();
Any nextElement();
- // IMapModificationListener
- virtual void mapModified() SAL_OVERRIDE;
+ /// called when the map was modified
+ void mapModified();
private:
::cppu::OWeakObject& m_rParent;
@@ -285,6 +259,13 @@ namespace comphelper
bool m_disposed;
};
+ static void lcl_notifyMapDataListeners_nothrow( const MapData& _mapData )
+ {
+ for ( MapEnumerator* loop : _mapData.m_aModListeners )
+ {
+ loop->mapModified();
+ }
+ }
typedef ::cppu::WeakImplHelper < XEnumeration
> MapEnumeration_Base;