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(); |