bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / inc / tools / AsynchronousCall.hxx
blob25d4cae9c34a4f750e87bf18948351f8331f951e
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_INC_TOOLS_ASYNCHRONOUSCALL_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_TOOLS_ASYNCHRONOUSCALL_HXX
23 #include <vcl/timer.hxx>
25 #include <memory>
26 #include <functional>
28 namespace sd { namespace tools {
30 /** Store a function object and execute it asynchronous.
32 The features of this class are:
33 a) It provides a wrapper around a VCL Timer so that generic function
34 objects can be used.
35 b) When more than one function objects are posted to be executed later
36 then the pending ones are erased and only the last one will actually be
37 executed.
39 Use this class like this:
40 aInstanceOfAsynchronousCall.Post(
41 ::std::bind(
42 ::std::mem_fun(&DrawViewShell::SwitchPage),
43 pDrawViewShell,
44 11));
46 class AsynchronousCall
48 public:
49 /** Create a new asynchronous call. Each object of this class processes
50 one (semantical) type of call.
52 AsynchronousCall();
54 ~AsynchronousCall();
56 /** Post a function object that is to be executed asynchronously. When
57 this method is called while the current function object has not been
58 executed then the latter is destroyed and only the given function
59 object will be executed.
60 @param rFunction
61 The function object that may be called asynchronously in the
62 near future.
64 typedef ::std::function<void ()> AsynchronousFunction;
65 void Post (
66 const AsynchronousFunction& rFunction);
68 private:
69 Timer maTimer;
70 /** The function object that will be executed when the TimerCallback
71 function is called the next time. This pointer may be NULL.
73 ::std::unique_ptr<AsynchronousFunction> mpFunction;
74 DECL_LINK(TimerCallback,Timer*,void);
77 } } // end of namespace ::sd::tools
79 #endif
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */