update dev300-m58
[ooovba.git] / xmloff / inc / unointerfacetouniqueidentifiermapper.hxx
blobce0ce796e3d215e35fd6ed18bc2b89be99d6dc25
1 #ifndef __COMPHELPER_UNOINTERFACETOUNIQUEIDENTIFIERMAPPER__
2 #define __COMPHELPER_UNOINTERFACETOUNIQUEIDENTIFIERMAPPER__
4 #include <map>
5 #include <rtl/ustring.hxx>
6 #include <com/sun/star/uno/XInterface.hpp>
8 namespace comphelper
11 typedef ::std::map< rtl::OUString, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > IdMap_t;
13 class UnoInterfaceToUniqueIdentifierMapper
15 public:
16 UnoInterfaceToUniqueIdentifierMapper();
18 /** returns a unique identifier for the given uno object. IF a uno object is
19 registered more than once, the returned identifier is always the same.
21 const rtl::OUString& registerReference( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rInterface );
23 /** registers the given uno object with the given identifier.
25 @returns
26 false, if the given identifier already exists and is not associated with the given interface
28 bool registerReference( const rtl::OUString& rIdentifier, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rInterface );
30 /** @returns
31 the identifier for the given uno object. If this uno object is not already
32 registered, an empty string is returned
34 const rtl::OUString& getIdentifier( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rInterface ) const;
36 /** @returns
37 the uno object that is registered with the given identifier. If no uno object
38 is registered with the given identifier, an empty reference is returned.
40 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& getReference( const rtl::OUString& rIdentifier ) const;
42 private:
43 bool findReference( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rInterface, IdMap_t::const_iterator& rIter ) const;
44 bool findIdentifier( const rtl::OUString& rIdentifier, IdMap_t::const_iterator& rIter ) const;
46 IdMap_t maEntries;
47 sal_Int32 mnNextId;
52 #endif