cid#1607171 Data race condition
[LibreOffice.git] / include / svx / sdr / animation / scheduler.hxx
blob312083b684a2439ae0ed98282725ce61b87d18e8
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_SVX_SDR_ANIMATION_SCHEDULER_HXX
21 #define INCLUDED_SVX_SDR_ANIMATION_SCHEDULER_HXX
23 #include <sal/types.h>
24 #include <vcl/timer.hxx>
25 #include <svx/svxdllapi.h>
26 #include <vector>
29 namespace sdr::animation
32 class SVXCORE_DLLPUBLIC Event
34 // time of event in ms
35 sal_uInt32 mnTime;
37 public:
38 // constructor/destructor
39 SAL_DLLPRIVATE explicit Event();
40 virtual ~Event();
42 // get/set time
43 SAL_DLLPRIVATE sal_uInt32 GetTime() const { return mnTime; }
44 void SetTime(sal_uInt32 nNew);
46 // execute event
47 virtual void Trigger(sal_uInt32 nTime) = 0;
50 class SVXCORE_DLLPUBLIC Scheduler : public Timer
52 // time in ms
53 sal_uInt32 mnTime;
55 // next delta time
56 sal_uInt32 mnDeltaTime;
58 // list of events, sorted by time
59 std::vector<Event*> mvEvents;
61 // Flag which remembers if this timer is paused. Default
62 // is false.
63 bool mbIsPaused;
65 public:
66 // constructor/destructor
67 SAL_DLLPRIVATE Scheduler();
68 virtual ~Scheduler() override;
70 // From baseclass Timer, the timeout call
71 virtual void Invoke() override;
73 // get time
74 SAL_DLLPRIVATE sal_uInt32 GetTime() const { return mnTime; }
76 // #i38135#
77 SAL_DLLPRIVATE void SetTime(sal_uInt32 nTime);
79 // execute all ripe events, removes executed ones from the scheduler
80 SAL_DLLPRIVATE void triggerEvents();
82 // re-start or stop timer according to event list
83 SAL_DLLPRIVATE void checkTimeout();
85 // insert/remove events, wrapper to EventList methods
86 void InsertEvent(Event& rNew);
87 SAL_DLLPRIVATE void RemoveEvent(Event* pOld);
89 // get/set pause
90 SAL_DLLPRIVATE bool IsPaused() const { return mbIsPaused; }
91 SAL_DLLPRIVATE void SetPaused(bool bNew);
94 } // end of namespace sdr::animation
97 #endif // INCLUDED_SVX_SDR_ANIMATION_SCHEDULER_HXX
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */