LibreOffice Module svx (master)  1
scheduler.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SVX_SDR_ANIMATION_SCHEDULER_HXX
21 #define INCLUDED_SVX_SDR_ANIMATION_SCHEDULER_HXX
22 
23 #include <sal/types.h>
24 #include <vcl/timer.hxx>
25 #include <svx/svxdllapi.h>
26 #include <vector>
27 
28 
29 namespace sdr
30 {
31  namespace animation
32  {
33 
35  {
36  // time of event in ms
37  sal_uInt32 mnTime;
38 
39  public:
40  // constructor/destructor
41  SAL_DLLPRIVATE explicit Event();
42  virtual ~Event();
43 
44  // get/set time
45  SAL_DLLPRIVATE sal_uInt32 GetTime() const { return mnTime; }
46  void SetTime(sal_uInt32 nNew);
47 
48  // execute event
49  virtual void Trigger(sal_uInt32 nTime) = 0;
50  };
51 
52  class SVX_DLLPUBLIC Scheduler : public Timer
53  {
54  // time in ms
55  sal_uInt32 mnTime;
56 
57  // next delta time
58  sal_uInt32 mnDeltaTime;
59 
60  // list of events, sorted by time
61  std::vector<Event*> mvEvents;
62 
63  // Flag which remembers if this timer is paused. Default
64  // is false.
65  bool mbIsPaused;
66 
67  public:
68  // constructor/destructor
69  SAL_DLLPRIVATE Scheduler();
70  virtual ~Scheduler() override;
71 
72  // From baseclass Timer, the timeout call
73  virtual void Invoke() override;
74 
75  // get time
76  SAL_DLLPRIVATE sal_uInt32 GetTime() const { return mnTime; }
77 
78  // #i38135#
79  SAL_DLLPRIVATE void SetTime(sal_uInt32 nTime);
80 
81  // execute all ripe events, removes executed ones from the scheduler
82  SAL_DLLPRIVATE void triggerEvents();
83 
84  // re-start or stop timer according to event list
85  SAL_DLLPRIVATE void checkTimeout();
86 
87  // insert/remove events, wrapper to EventList methods
88  void InsertEvent(Event& rNew);
89  SAL_DLLPRIVATE void RemoveEvent(Event* pOld);
90 
91  // get/set pause
92  SAL_DLLPRIVATE bool IsPaused() const { return mbIsPaused; }
93  SAL_DLLPRIVATE void SetPaused(bool bNew);
94  };
95 
96  } // end of namespace animation
97 } // end of namespace sdr
98 
99 
100 #endif // INCLUDED_SVX_SDR_ANIMATION_SCHEDULER_HXX
101 
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< Event * > mvEvents
Definition: scheduler.hxx:61
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
SAL_DLLPRIVATE sal_uInt32 GetTime() const
Definition: scheduler.hxx:76
SAL_DLLPRIVATE sal_uInt32 GetTime() const
Definition: scheduler.hxx:45
SAL_DLLPRIVATE bool IsPaused() const
Definition: scheduler.hxx:92