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 "ChangeRequestQueue.hxx"
23 #include <osl/mutex.hxx>
25 #include <tools/link.hxx>
29 namespace com::sun::star::drawing::framework
33 namespace com::sun::star::drawing::framework
35 class XConfigurationChangeRequest
;
40 namespace sd::framework
42 class ConfigurationUpdater
;
44 /** The ChangeRequestQueueProcessor owns the ChangeRequestQueue and
45 processes the configuration change requests.
47 When after processing one entry the queue is empty then the
48 XConfigurationController::update() method is called so that the changes
49 made to the local XConfiguration reference are reflected by the UI.
51 Queue entries are processed asynchronously by calling PostUserEvent().
53 class ChangeRequestQueueProcessor
56 /** The queue processor is created with a reference to an
57 ConfigurationController so that its UpdateConfiguration() method can
58 be called when the queue becomes empty.
60 explicit ChangeRequestQueueProcessor(std::shared_ptr
<ConfigurationUpdater
> pUpdater
);
61 ~ChangeRequestQueueProcessor();
63 /** Sets the configuration who will be changed by subsequent change
64 requests. This method should be called only by the configuration
65 controller who owns the configuration.
67 void SetConfiguration(
68 const css::uno::Reference
<css::drawing::framework::XConfiguration
>& rxConfiguration
);
70 /** The given request is appended to the end of the queue and will
71 eventually be processed when all other entries in front of it have
75 const css::uno::Reference
<css::drawing::framework::XConfigurationChangeRequest
>& rxRequest
);
77 /** Returns </sal_True> when the queue is empty.
81 /** Process all events in the queue synchronously.
83 <p>This method is typically called when the framework is shut down
84 to establish an empty configuration.</p>
86 void ProcessUntilEmpty();
88 /** Process the first event in queue.
90 void ProcessOneEvent();
92 /** Remove all events from the queue.
94 <p>This method is typically called when the framework is shut down
95 to avoid the processing of still pending activation requests.</p>
100 mutable ::osl::Mutex maMutex
;
102 ChangeRequestQueue maQueue
;
104 /** The id returned by the last PostUserEvent() call. This id is stored
105 so that a pending user event can be removed when the queue processor
108 ImplSVEvent
* mnUserEventId
;
110 css::uno::Reference
<css::drawing::framework::XConfiguration
> mxConfiguration
;
112 std::shared_ptr
<ConfigurationUpdater
> mpConfigurationUpdater
;
114 /** Initiate the processing of the entries in the queue. The actual
115 processing starts asynchronously.
117 void StartProcessing();
119 /** Callback function for the PostUserEvent() call.
121 DECL_LINK(ProcessEvent
, void*, void);
124 } // end of namespace sd::framework
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */