bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / framework / configuration / ChangeRequestQueueProcessor.hxx
blobfa3b4d456b9c691d64d58e69626770176ce5afc9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_SD_SOURCE_UI_FRAMEWORK_CONFIGURATION_CHANGEREQUESTQUEUEPROCESSOR_HXX
21 #define INCLUDED_SD_SOURCE_UI_FRAMEWORK_CONFIGURATION_CHANGEREQUESTQUEUEPROCESSOR_HXX
23 #include "ChangeRequestQueue.hxx"
24 #include <osl/mutex.hxx>
25 #include <rtl/ref.hxx>
26 #include <com/sun/star/drawing/framework/XConfigurationChangeRequest.hpp>
27 #include <com/sun/star/drawing/framework/ConfigurationChangeEvent.hpp>
29 #include <cppuhelper/interfacecontainer.hxx>
30 #include <tools/link.hxx>
32 #include <boost/shared_ptr.hpp>
34 struct ImplSVEvent;
36 namespace sd { namespace framework {
38 class ConfigurationController;
39 class ConfigurationUpdater;
41 /** The ChangeRequestQueueProcessor ownes the ChangeRequestQueue and
42 processes the configuration change requests.
44 When after processing one entry the queue is empty then the
45 XConfigurationController::update() method is called so that the changes
46 made to the local XConfiguration reference are reflected by the UI.
48 Queue entries are processed asynchronously by calling PostUserEvent().
50 class ChangeRequestQueueProcessor
52 public:
53 /** The queue processor is created with a reference to an
54 ConfigurationController so that its UpdateConfiguration() method can
55 be called when the queue becomes empty.
57 ChangeRequestQueueProcessor (
58 const ::rtl::Reference<ConfigurationController>& rxController,
59 const ::boost::shared_ptr<ConfigurationUpdater>& rpUpdater);
60 ~ChangeRequestQueueProcessor();
62 /** Sets the configuration who will be changed by subsequent change
63 requests. This method should be called only by the configuration
64 controller who owns the configuration.
66 void SetConfiguration (
67 const ::com::sun::star::uno::Reference<
68 ::com::sun::star::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
72 been processed.
74 void AddRequest (const ::com::sun::star::uno::Reference<
75 ::com::sun::star::drawing::framework::XConfigurationChangeRequest>& rxRequest);
77 /** Returns </sal_True> when the queue is empty.
79 bool IsEmpty() const;
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>
97 void Clear();
99 private:
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
106 is destroyed.
108 ImplSVEvent * mnUserEventId;
110 ::com::sun::star::uno::Reference<
111 ::com::sun::star::drawing::framework::XConfiguration> mxConfiguration;
113 ::rtl::Reference<ConfigurationController> mpConfigurationController;
115 ::boost::shared_ptr<ConfigurationUpdater> mpConfigurationUpdater;
117 /** Initiate the processing of the entries in the queue. The actual
118 processing starts asynchronously.
120 void StartProcessing();
122 /** Callback function for the PostUserEvent() call.
124 DECL_LINK(ProcessEvent,void*);
127 } } // end of namespace sd::framework
129 #endif
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */