fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / inc / tools / AsynchronousCall.hxx
blob3619def24413120a5a6342dbec345db5e126877f
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_ASYNCHRONOUS_CALL_HXX
21 #define SD_ASYNCHRONOUS_CALL_HXX
23 #include <vcl/timer.hxx>
24 #include <memory>
25 #include <boost/function.hpp>
27 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 ::boost::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 (void);
54 ~AsynchronousCall (void);
56 /** Post a function object that is to be executed asynchronously. When
57 this method is called while the current function object has not bee
58 executed then the later 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.
63 @param nTimeoutInMilliseconds
64 The timeout in milliseconds until the function object is
65 executed.
67 typedef ::boost::function0<void> AsynchronousFunction;
68 void Post (
69 const AsynchronousFunction& rFunction,
70 sal_uInt32 nTimeoutInMilliseconds=10);
72 private:
73 Timer maTimer;
74 /** The function object that will be executed when the TimerCallback
75 function is called the next time. This pointer may be NULL.
77 ::std::auto_ptr<AsynchronousFunction> mpFunction;
78 DECL_LINK(TimerCallback,Timer*);
82 } } // end of namespace ::sd::tools
84 #endif
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */