bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / inc / tools / AsynchronousCall.hxx
bloba95ad7f58ffdf10057f41538275801e21ac54c35
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>
24 #include <memory>
25 #include <boost/function.hpp>
27 namespace sd { namespace tools {
29 /** Store a function object and execute it asynchronous.
31 The features of this class are:
32 a) It provides a wrapper around a VCL Timer so that generic function
33 objects can be used.
34 b) When more than one function objects are posted to be executed later
35 then the pending ones are erased and only the last one will actually be
36 executed.
38 Use this class like this:
39 aInstanceOfAsynchronousCall.Post(
40 ::boost::bind(
41 ::std::mem_fun(&DrawViewShell::SwitchPage),
42 pDrawViewShell,
43 11));
45 class AsynchronousCall
47 public:
48 /** Create a new asynchronous call. Each object of this class processes
49 one (semantical) type of call.
51 AsynchronousCall();
53 ~AsynchronousCall();
55 /** Post a function object that is to be executed asynchronously. When
56 this method is called while the current function object has not bee
57 executed then the later is destroyed and only the given function
58 object will be executed.
59 @param rFunction
60 The function object that may be called asynchronously in the
61 near future.
62 @param nTimeoutInMilliseconds
63 The timeout in milliseconds until the function object is
64 executed.
66 typedef ::boost::function0<void> AsynchronousFunction;
67 void Post (
68 const AsynchronousFunction& rFunction,
69 sal_uInt32 nTimeoutInMilliseconds=10);
71 private:
72 Timer maTimer;
73 /** The function object that will be executed when the TimerCallback
74 function is called the next time. This pointer may be NULL.
76 ::std::unique_ptr<AsynchronousFunction> mpFunction;
77 DECL_LINK_TYPED(TimerCallback,Timer*,void);
80 } } // end of namespace ::sd::tools
82 #endif
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */