View | Details | Raw Unified | Return to issue 72766
Collapse All | Expand All

(-)cppuhelper/inc/cppuhelper/interfacecontainer.h (-1 / +18 lines)
Lines 36-41 Link Here
36
#define _CPPUHELPER_INTERFACECONTAINER_H_
36
#define _CPPUHELPER_INTERFACECONTAINER_H_
37
37
38
#include <hash_map>
38
#include <hash_map>
39
#include <vector>
39
#include <functional>
40
#include <functional>
40
41
41
#ifndef _OSL_MUTEX_HXX_
42
#ifndef _OSL_MUTEX_HXX_
Lines 406-414 public: Link Here
406
407
407
	typedef key keyType;
408
	typedef key keyType;
408
private:
409
private:
409
	::std::hash_map< key , void* , hashImpl , equalImpl > *m_pMap;
410
    typedef ::std::vector< std::pair < key , void* > > InterfaceMap;
411
    InterfaceMap *m_pMap;
410
	::osl::Mutex &	rMutex;
412
	::osl::Mutex &	rMutex;
411
413
414
    inline typename InterfaceMap::iterator find(const key &rKey) const
415
    {
416
        typename InterfaceMap::iterator iter = m_pMap->begin();
417
        typename InterfaceMap::iterator end = m_pMap->end();
418
419
    	while( iter != end )
420
        {
421
            equalImpl equal;
422
            if( equal( iter->first, rKey ) )
423
                break;
424
            iter++;
425
        }
426
        return iter;
427
    }
428
    
412
	inline OMultiTypeInterfaceContainerHelperVar( const OMultiTypeInterfaceContainerHelperVar & ) SAL_THROW( () );
429
	inline OMultiTypeInterfaceContainerHelperVar( const OMultiTypeInterfaceContainerHelperVar & ) SAL_THROW( () );
413
	inline OMultiTypeInterfaceContainerHelperVar & operator = ( const OMultiTypeInterfaceContainerHelperVar & ) SAL_THROW( () );
430
	inline OMultiTypeInterfaceContainerHelperVar & operator = ( const OMultiTypeInterfaceContainerHelperVar & ) SAL_THROW( () );
414
};
431
};
(-)cppuhelper/inc/cppuhelper/interfacecontainer.hxx (-5 / +5 lines)
Lines 38-44 Link Here
38
#include <cppuhelper/interfacecontainer.h>
38
#include <cppuhelper/interfacecontainer.h>
39
39
40
40
41
#define CONT_HASHMAP ::std::hash_map< key , void* , hashImpl , equalImpl >
41
#define CONT_HASHMAP ::std::vector< std::pair < key , void* > >
42
42
43
namespace cppu
43
namespace cppu
44
{     
44
{     
Lines 108-114 OInterfaceContainerHelper * OMultiTypeIn Link Here
108
{
109
{
109
	::osl::MutexGuard aGuard( rMutex );
110
	::osl::MutexGuard aGuard( rMutex );
110
111
111
 	typename CONT_HASHMAP::iterator iter = m_pMap->find( rKey );
112
 	typename CONT_HASHMAP::iterator iter = find( rKey );
112
	if( iter != m_pMap->end() )
113
	if( iter != m_pMap->end() )
113
			return (OInterfaceContainerHelper*) (*iter).second;
114
			return (OInterfaceContainerHelper*) (*iter).second;
114
	return 0;
115
	return 0;
Lines 122-132 sal_Int32 OMultiTypeInterfaceContainerHe Link Here
122
	SAL_THROW( () )
123
	SAL_THROW( () )
123
{
124
{
124
	::osl::MutexGuard aGuard( rMutex );
125
	::osl::MutexGuard aGuard( rMutex );
125
	typename CONT_HASHMAP::iterator iter = m_pMap->find( rKey );
126
	typename CONT_HASHMAP::iterator iter = find( rKey );
126
	if( iter == m_pMap->end() )
127
	if( iter == m_pMap->end() )
127
	{
128
	{
128
		OInterfaceContainerHelper * pLC = new OInterfaceContainerHelper( rMutex );
129
		OInterfaceContainerHelper * pLC = new OInterfaceContainerHelper( rMutex );
129
		(*m_pMap)[rKey] = pLC;
130
        m_pMap->push_back(std::pair<key, void*>(rKey, pLC));
130
		return pLC->addInterface( rListener );
131
		return pLC->addInterface( rListener );
131
	}
132
	}
132
	else
133
	else
Lines 143-149 inline sal_Int32 OMultiTypeInterfaceCont Link Here
143
	::osl::MutexGuard aGuard( rMutex );
145
	::osl::MutexGuard aGuard( rMutex );
144
146
145
	// search container with id nUik
147
	// search container with id nUik
146
	typename CONT_HASHMAP::iterator iter = m_pMap->find( rKey );
148
	typename CONT_HASHMAP::iterator iter = find( rKey );
147
    // container found?
149
    // container found?
148
	if( iter != m_pMap->end() )
150
	if( iter != m_pMap->end() )
149
        return ((OInterfaceContainerHelper*)(*iter).second)->removeInterface( rListener );
151
        return ((OInterfaceContainerHelper*)(*iter).second)->removeInterface( rListener );
(-)cppuhelper/source/interfacecontainer.cxx (-13 / +57 lines)
Lines 389-395 void OInterfaceContainerHelper::clear() Link Here
389
390
390
// specialized class for type
391
// specialized class for type
391
392
392
typedef ::std::hash_map< Type , void* , hashType_Impl , ::std::equal_to< Type > > t_type2ptr;
393
typedef ::std::vector< std::pair < Type , void* > > t_type2ptr;
393
394
394
OMultiTypeInterfaceContainerHelper::OMultiTypeInterfaceContainerHelper( Mutex & rMutex_ )
395
OMultiTypeInterfaceContainerHelper::OMultiTypeInterfaceContainerHelper( Mutex & rMutex_ )
395
    SAL_THROW( () )
396
    SAL_THROW( () )
Lines 445-457 Sequence< Type > OMultiTypeInterfaceCont Link Here
445
	}
446
	}
446
	return ::com::sun::star::uno::Sequence< Type >();
447
	return ::com::sun::star::uno::Sequence< Type >();
447
}
448
}
449
450
static t_type2ptr::iterator findType(t_type2ptr *pMap, const Type & rKey )
451
{
452
	t_type2ptr::iterator iter = pMap->begin();
453
	t_type2ptr::iterator end = pMap->end();
454
455
	while( iter != end )
456
    {
457
        if (iter->first == rKey)
458
            break;
459
        iter++;
460
    }
461
    return iter;
462
}
463
448
OInterfaceContainerHelper * OMultiTypeInterfaceContainerHelper::getContainer( const Type & rKey ) const
464
OInterfaceContainerHelper * OMultiTypeInterfaceContainerHelper::getContainer( const Type & rKey ) const
449
    SAL_THROW( () )
465
    SAL_THROW( () )
450
{
466
{
451
	::osl::MutexGuard aGuard( rMutex );
467
	::osl::MutexGuard aGuard( rMutex );
452
468
453
    t_type2ptr * pMap = (t_type2ptr *)m_pMap;
469
    t_type2ptr * pMap = (t_type2ptr *)m_pMap;
454
 	t_type2ptr::iterator iter = pMap->find( rKey );
470
 	t_type2ptr::iterator iter = findType( pMap, rKey );
455
	if( iter != pMap->end() )
471
	if( iter != pMap->end() )
456
			return (OInterfaceContainerHelper*) (*iter).second;
472
			return (OInterfaceContainerHelper*) (*iter).second;
457
	return 0;
473
	return 0;
Lines 462-472 sal_Int32 OMultiTypeInterfaceContainerHe Link Here
462
{
478
{
463
	::osl::MutexGuard aGuard( rMutex );
479
	::osl::MutexGuard aGuard( rMutex );
464
    t_type2ptr * pMap = (t_type2ptr *)m_pMap;
480
    t_type2ptr * pMap = (t_type2ptr *)m_pMap;
465
	t_type2ptr::iterator iter = pMap->find( rKey );
481
	t_type2ptr::iterator iter = findType( pMap, rKey );
466
	if( iter == pMap->end() )
482
	if( iter == pMap->end() )
467
	{
483
	{
468
		OInterfaceContainerHelper * pLC = new OInterfaceContainerHelper( rMutex );
484
		OInterfaceContainerHelper * pLC = new OInterfaceContainerHelper( rMutex );
469
		(*pMap)[rKey] = pLC;
485
        pMap->push_back(std::pair<Type, void*>(rKey, pLC));
470
		return pLC->addInterface( rListener );
486
		return pLC->addInterface( rListener );
471
	}
487
	}
472
	else
488
	else
Lines 480-486 sal_Int32 OMultiTypeInterfaceContainerHe Link Here
480
496
481
	// search container with id nUik
497
	// search container with id nUik
482
    t_type2ptr * pMap = (t_type2ptr *)m_pMap;
498
    t_type2ptr * pMap = (t_type2ptr *)m_pMap;
483
	t_type2ptr::iterator iter = pMap->find( rKey );
499
	t_type2ptr::iterator iter = findType( pMap, rKey );
484
		// container found?
500
		// container found?
485
	if( iter != pMap->end() )
501
	if( iter != pMap->end() )
486
        return ((OInterfaceContainerHelper*)(*iter).second)->removeInterface( rListener );
502
        return ((OInterfaceContainerHelper*)(*iter).second)->removeInterface( rListener );
Lines 547-563 void OMultiTypeInterfaceContainerHelper: Link Here
547
563
548
// specialized class for long
564
// specialized class for long
549
565
550
typedef ::std::hash_map< sal_Int32 , void* , hashInt32_Impl , equalInt32_Impl > t_long2ptr;
566
typedef ::std::vector< std::pair < sal_Int32 , void* > > t_long2ptr;
567
568
static t_long2ptr::iterator findLong(t_long2ptr *pMap, sal_Int32 nKey )
569
{
570
	t_long2ptr::iterator iter = pMap->begin();
571
	t_long2ptr::iterator end = pMap->end();
572
573
	while( iter != end )
574
    {
575
        if (iter->first == nKey)
576
            break;
577
        iter++;
578
    }
579
    return iter;
580
}
551
581
552
OMultiTypeInterfaceContainerHelperInt32::OMultiTypeInterfaceContainerHelperInt32( Mutex & rMutex_ )
582
OMultiTypeInterfaceContainerHelperInt32::OMultiTypeInterfaceContainerHelperInt32( Mutex & rMutex_ )
553
    SAL_THROW( () )
583
    SAL_THROW( () )
554
    : rMutex( rMutex_ )
584
    : rMutex( rMutex_ )
585
    , m_pMap( NULL )
555
{
586
{
556
	m_pMap = new t_long2ptr();
587
    // delay pMap allocation until necessary, empty containers are common
557
}
588
}
558
OMultiTypeInterfaceContainerHelperInt32::~OMultiTypeInterfaceContainerHelperInt32()
589
OMultiTypeInterfaceContainerHelperInt32::~OMultiTypeInterfaceContainerHelperInt32()
559
    SAL_THROW( () )
590
    SAL_THROW( () )
560
{
591
{
592
    if (!m_pMap)
593
        return;
594
561
    t_long2ptr * pMap = (t_long2ptr *)m_pMap;
595
    t_long2ptr * pMap = (t_long2ptr *)m_pMap;
562
	t_long2ptr::iterator iter = pMap->begin();
596
	t_long2ptr::iterator iter = pMap->begin();
563
	t_long2ptr::iterator end = pMap->end();
597
	t_long2ptr::iterator end = pMap->end();
Lines 577-583 Sequence< sal_Int32 > OMultiTypeInterfac Link Here
577
	t_long2ptr::size_type nSize;
611
	t_long2ptr::size_type nSize;
578
612
579
	::osl::MutexGuard aGuard( rMutex );
613
	::osl::MutexGuard aGuard( rMutex );
580
	nSize = pMap->size();
614
	nSize = pMap ? pMap->size() : 0;
581
	if( nSize )
615
	if( nSize )
582
	{
616
	{
583
		::com::sun::star::uno::Sequence< sal_Int32 > aInterfaceTypes( nSize );
617
		::com::sun::star::uno::Sequence< sal_Int32 > aInterfaceTypes( nSize );
Lines 608-615 OInterfaceContainerHelper * OMultiTypeIn Link Here
608
{
642
{
609
	::osl::MutexGuard aGuard( rMutex );
643
	::osl::MutexGuard aGuard( rMutex );
610
644
645
    if (!m_pMap)
646
        return 0;
611
    t_long2ptr * pMap = (t_long2ptr *)m_pMap;
647
    t_long2ptr * pMap = (t_long2ptr *)m_pMap;
612
 	t_long2ptr::iterator iter = pMap->find( rKey );
648
 	t_long2ptr::iterator iter = findLong( pMap, rKey );
613
	if( iter != pMap->end() )
649
	if( iter != pMap->end() )
614
			return (OInterfaceContainerHelper*) (*iter).second;
650
			return (OInterfaceContainerHelper*) (*iter).second;
615
	return 0;
651
	return 0;
Lines 619-630 sal_Int32 OMultiTypeInterfaceContainerHe Link Here
619
    SAL_THROW( () )
655
    SAL_THROW( () )
620
{
656
{
621
	::osl::MutexGuard aGuard( rMutex );
657
	::osl::MutexGuard aGuard( rMutex );
658
    if (!m_pMap)
659
    	m_pMap = new t_long2ptr();
622
    t_long2ptr * pMap = (t_long2ptr *)m_pMap;
660
    t_long2ptr * pMap = (t_long2ptr *)m_pMap;
623
	t_long2ptr::iterator iter = pMap->find( rKey );
661
	t_long2ptr::iterator iter = findLong( pMap, rKey );
624
	if( iter == pMap->end() )
662
 	if( iter == pMap->end() )
625
	{
663
	{
626
		OInterfaceContainerHelper * pLC = new OInterfaceContainerHelper( rMutex );
664
		OInterfaceContainerHelper * pLC = new OInterfaceContainerHelper( rMutex );
627
		(*pMap)[rKey] = pLC;
665
        pMap->push_back(std::pair< sal_Int32, void* >(rKey, pLC));
628
		return pLC->addInterface( rListener );
666
		return pLC->addInterface( rListener );
629
	}
667
	}
630
	else
668
	else
Lines 636-644 sal_Int32 OMultiTypeInterfaceContainerHe Link Here
636
{
674
{
637
	::osl::MutexGuard aGuard( rMutex );
675
	::osl::MutexGuard aGuard( rMutex );
638
676
677
    if (!m_pMap)
678
        return 0;
639
	// search container with id nUik
679
	// search container with id nUik
640
    t_long2ptr * pMap = (t_long2ptr *)m_pMap;
680
    t_long2ptr * pMap = (t_long2ptr *)m_pMap;
641
	t_long2ptr::iterator iter = pMap->find( rKey );
681
	t_long2ptr::iterator iter = findLong( pMap, rKey );
642
		// container found?
682
		// container found?
643
	if( iter != pMap->end() )
683
	if( iter != pMap->end() )
644
        return ((OInterfaceContainerHelper*)(*iter).second)->removeInterface( rListener );
684
        return ((OInterfaceContainerHelper*)(*iter).second)->removeInterface( rListener );
Lines 653-658 void OMultiTypeInterfaceContainerHelperI Link Here
653
	OInterfaceContainerHelper ** ppListenerContainers = NULL;
693
	OInterfaceContainerHelper ** ppListenerContainers = NULL;
654
	{
694
	{
655
		::osl::MutexGuard aGuard( rMutex );
695
		::osl::MutexGuard aGuard( rMutex );
696
        if (!m_pMap)
697
            return;
698
656
        t_long2ptr * pMap = (t_long2ptr *)m_pMap;
699
        t_long2ptr * pMap = (t_long2ptr *)m_pMap;
657
		nSize = pMap->size();
700
		nSize = pMap->size();
658
		if( nSize )
701
		if( nSize )
Lines 687-692 void OMultiTypeInterfaceContainerHelperI Link Here
687
    SAL_THROW( () )
730
    SAL_THROW( () )
688
{
731
{
689
	::osl::MutexGuard aGuard( rMutex );
732
	::osl::MutexGuard aGuard( rMutex );
733
    if (!m_pMap)
734
        return;
690
    t_long2ptr * pMap = (t_long2ptr *)m_pMap;
735
    t_long2ptr * pMap = (t_long2ptr *)m_pMap;
691
	t_long2ptr::iterator iter = pMap->begin();
736
	t_long2ptr::iterator iter = pMap->begin();
692
	t_long2ptr::iterator end = pMap->end();
737
	t_long2ptr::iterator end = pMap->end();

Return to issue 72766