1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <sal/config.h>
24 #include <osl/mutex.hxx>
25 #include <com/sun/star/lang/EventObject.hpp>
26 #include <comphelper/comphelperdllapi.h>
27 #include <comphelper/interfacecontainer2.hxx>
32 namespace com::sun::star::uno
39 /** This is a copy of cppu::OMultiTypeInterfaceContainerHelper2 in include/cppuhelper/interfacecontainer.h,
40 except that it uses comphelper::OInterfaceContainerHelper2, which is more efficient.
42 class COMPHELPER_DLLPUBLIC OMultiTypeInterfaceContainerHelper2
46 Create a container of interface containers.
48 @param rMutex the mutex to protect multi thread access.
49 The lifetime must be longer than the lifetime
52 OMultiTypeInterfaceContainerHelper2(::osl::Mutex
& rMutex
);
54 Delete all containers.
56 ~OMultiTypeInterfaceContainerHelper2();
59 Return all id's under which at least one interface is added.
61 std::vector
<css::uno::Type
> getContainedTypes() const;
64 Return the container created under this key.
65 @return the container created under this key. If the container
66 was not created, null was returned.
68 OInterfaceContainerHelper2
* getContainer(const css::uno::Type
& rKey
) const;
70 /** Inserts an element into the container with the specified key.
71 The position is not specified, thus it is not specified in which order events are fired.
74 If you add the same interface more than once, then it will be added to the elements list
75 more than once and thus if you want to remove that interface from the list, you have to call
76 removeInterface() the same number of times.
77 In the latter case, you will also get events fired more than once (if the interface is a
81 the id of the container
83 interface to be added; it is allowed, to insert null or
84 the same interface more than once
86 the new count of elements in the container
88 sal_Int32
addInterface(const css::uno::Type
& rKey
,
89 const css::uno::Reference
<css::uno::XInterface
>& r
);
91 /** Removes an element from the container with the specified key.
92 It uses interface equality to remove the interface.
95 the id of the container
97 interface to be removed
99 the new count of elements in the container
101 sal_Int32
removeInterface(const css::uno::Type
& rKey
,
102 const css::uno::Reference
<css::uno::XInterface
>& rxIFace
);
105 Call disposing on all object in the container that
106 support XEventListener. Then clear the container.
108 void disposeAndClear(const css::lang::EventObject
& rEvt
);
110 Remove all elements of all containers. Does not delete the container.
114 typedef css::uno::Type keyType
;
117 typedef std::vector
<std::pair
<css::uno::Type
, std::unique_ptr
<OInterfaceContainerHelper2
>>>
120 t_type2ptr::iterator
findType(const css::uno::Type
& rKey
);
121 t_type2ptr::const_iterator
findType(const css::uno::Type
& rKey
) const;
124 ::osl::Mutex
& rMutex
;
126 OMultiTypeInterfaceContainerHelper2(const OMultiTypeInterfaceContainerHelper2
&) = delete;
127 OMultiTypeInterfaceContainerHelper2
& operator=(const OMultiTypeInterfaceContainerHelper2
&)
131 } // namespace comphelper
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */