diff options
Diffstat (limited to 'cppuhelper/source/servicemanager.hxx')
-rw-r--r-- | cppuhelper/source/servicemanager.hxx | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/cppuhelper/source/servicemanager.hxx b/cppuhelper/source/servicemanager.hxx index d086a8d65ead..af80be25a183 100644 --- a/cppuhelper/source/servicemanager.hxx +++ b/cppuhelper/source/servicemanager.hxx @@ -12,9 +12,12 @@ #include <sal/config.h> #include <cassert> -#include <unordered_map> +#include <functional> #include <memory> +#include <mutex> #include <string_view> +#include <unordered_map> +#include <utility> #include <vector> #include <com/sun/star/beans/XPropertySet.hpp> @@ -27,9 +30,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/uno/Reference.hxx> -#include <cppuhelper/basemutex.hxx> -#include <cppuhelper/compbase.hxx> -#include <osl/mutex.hxx> +#include <compbase2.hxx> #include <rtl/ustring.hxx> namespace com::sun::star::lang { @@ -52,7 +53,7 @@ typedef css::uno::XInterface * ImplementationConstructorFn( typedef std::function<css::uno::XInterface * (css::uno::XComponentContext *, css::uno::Sequence<css::uno::Any> const&)> WrapperConstructorFn; -typedef cppu::WeakComponentImplHelper< +typedef WeakComponentImplHelper2< css::lang::XServiceInfo, css::lang::XMultiServiceFactory, css::lang::XMultiComponentFactory, css::container::XSet, css::container::XContentEnumerationAccess, css::beans::XPropertySet, @@ -60,8 +61,7 @@ typedef cppu::WeakComponentImplHelper< css::lang::XInitialization> ServiceManagerBase; -class ServiceManager: - private cppu::BaseMutex, public ServiceManagerBase +class ServiceManager : public ServiceManagerBase { public: struct Data { @@ -71,32 +71,30 @@ public: struct Implementation { Implementation( - OUString const & theName, OUString const & theLoader, - OUString const & theUri, OUString const & theEnvironment, - OUString const & theConstructorName, - OUString const & thePrefix, + OUString theName, OUString theLoader, + OUString theUri, OUString theEnvironment, + OUString theConstructorName, + OUString thePrefix, bool theIsSingleInstance, - css::uno::Reference< css::uno::XComponentContext > const & - theAlienContext, - OUString const & theRdbFile): - name(theName), loader(theLoader), uri(theUri), environment(theEnvironment), - constructorName(theConstructorName), prefix(thePrefix), + css::uno::Reference< css::uno::XComponentContext > theAlienContext, + OUString theRdbFile): + name(std::move(theName)), loader(std::move(theLoader)), uri(std::move(theUri)), environment(std::move(theEnvironment)), + constructorName(std::move(theConstructorName)), prefix(std::move(thePrefix)), isSingleInstance(theIsSingleInstance), - alienContext(theAlienContext), rdbFile(theRdbFile), + alienContext(std::move(theAlienContext)), rdbFile(std::move(theRdbFile)), constructorFn(nullptr), status(STATUS_NEW), dispose(true) {} Implementation( - OUString const & theName, + OUString theName, css::uno::Reference< css::lang::XSingleComponentFactory > const & theFactory1, css::uno::Reference< css::lang::XSingleServiceFactory > const & theFactory2, - css::uno::Reference< css::lang::XComponent > const & - theComponent): - name(theName), isSingleInstance(false), constructorFn(nullptr), + css::uno::Reference< css::lang::XComponent > theComponent): + name(std::move(theName)), isSingleInstance(false), constructorFn(nullptr), factory1(theFactory1), factory2(theFactory2), - component(theComponent), status(STATUS_LOADED), dispose(true) + component(std::move(theComponent)), status(STATUS_LOADED), dispose(true) { assert(theFactory1.is() || theFactory2.is()); } Implementation(const Implementation&) = delete; @@ -146,7 +144,7 @@ public: css::uno::Reference< css::lang::XComponent > component; Status status; - osl::Mutex mutex; + std::mutex mutex; css::uno::Reference<css::uno::XInterface> singleInstance; css::uno::Reference< css::lang::XComponent > disposeInstance; bool dispose; @@ -185,7 +183,7 @@ public: ImplementationMap singletons; }; - ServiceManager(): ServiceManagerBase(m_aMutex) {} + ServiceManager() {} ServiceManager(const ServiceManager&) = delete; const ServiceManager& operator=(const ServiceManager&) = delete; @@ -193,7 +191,7 @@ public: using ServiceManagerBase::acquire; using ServiceManagerBase::release; - void init(OUString const & rdbUris); + void init(std::u16string_view rdbUris); void setContext( css::uno::Reference< css::uno::XComponentContext > const & context) @@ -220,7 +218,7 @@ public: private: virtual ~ServiceManager() override; - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock<std::mutex>&) override; virtual OUString SAL_CALL getImplementationName() override; @@ -309,13 +307,10 @@ private: css::uno::Sequence<css::uno::Any> const & aArguments) override; - // needs to be called with rBHelper.rMutex locked: - bool isDisposed() const { return rBHelper.bDisposed || rBHelper.bInDispose; } - void removeEventListenerFromComponent( css::uno::Reference< css::lang::XComponent > const & component); - void readRdbDirectory(OUString const & uri, bool optional); + void readRdbDirectory(std::u16string_view uri, bool optional); void readRdbFile(OUString const & uri, bool optional); |