bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / framework / configuration / ChangeRequestQueueProcessor.hxx
blobb0bf3ec438b8eac0ec3d80091f12ed76b8070f0f
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 SD_FRAMEWORK_CHANGE_REQUEST_QUEUE_PROCESSOR_HXX
21 #define SD_FRAMEWORK_CHANGE_REQUEST_QUEUE_PROCESSOR_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 namespace sd { namespace framework {
36 class ConfigurationController;
37 class ConfigurationUpdater;
39 /** The ChangeRequestQueueProcessor ownes the ChangeRequestQueue and
40 processes the configuration change requests.
42 When after processing one entry the queue is empty then the
43 XConfigurationController::update() method is called so that the changes
44 made to the local XConfiguration reference are reflected by the UI.
46 Queue entries are processed asynchronously by calling PostUserEvent().
48 class ChangeRequestQueueProcessor
50 public:
51 /** The queue processor is created with a reference to an
52 ConfigurationController so that its UpdateConfiguration() method can
53 be called when the queue becomes empty.
55 ChangeRequestQueueProcessor (
56 const ::rtl::Reference<ConfigurationController>& rxController,
57 const ::boost::shared_ptr<ConfigurationUpdater>& rpUpdater);
58 ~ChangeRequestQueueProcessor (void);
60 /** Sets the configuration who will be changed by subsequent change
61 requests. This method should be called only by the configuration
62 controller who owns the configuration.
64 void SetConfiguration (
65 const ::com::sun::star::uno::Reference<
66 ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration);
68 /** The given request is appended to the end of the queue and will
69 eventually be processed when all other entries in front of it have
70 been processed.
72 void AddRequest (const ::com::sun::star::uno::Reference<
73 ::com::sun::star::drawing::framework::XConfigurationChangeRequest>& rxRequest);
75 /** Returns </sal_True> when the queue is empty.
77 bool IsEmpty (void) const;
79 /** Process all events in the queue synchronously.
81 <p>This method is typically called when the framework is shut down
82 to establish an empty configuration.</p>
84 void ProcessUntilEmpty (void);
86 /** Process the first event in queue.
88 void ProcessOneEvent (void);
90 /** Remove all events from the queue.
92 <p>This method is typically called when the framework is shut down
93 to avoid the processing of still pending activation requests.</p>
95 void Clear (void);
97 private:
98 mutable ::osl::Mutex maMutex;
100 ChangeRequestQueue maQueue;
102 /** The id returned by the last PostUserEvent() call. This id is stored
103 so that a pending user event can be removed whent he queue processor
104 is destroyed.
106 sal_uIntPtr mnUserEventId;
108 ::com::sun::star::uno::Reference<
109 ::com::sun::star::drawing::framework::XConfiguration> mxConfiguration;
111 ::rtl::Reference<ConfigurationController> mpConfigurationController;
113 ::boost::shared_ptr<ConfigurationUpdater> mpConfigurationUpdater;
115 /** Initiate the processing of the entries in the queue. The actual
116 processing starts asynchronously.
118 void StartProcessing (void);
120 /** Callback function for the PostUserEvent() call.
122 DECL_LINK(ProcessEvent,void*);
126 } } // end of namespace sd::framework
128 #endif
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */