xref: /AOO41X/main/svx/inc/svx/sdr/animation/scheduler.hxx (revision 3334a7e6acdae9820fa1a6f556bb10129a8de6b2)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SDR_ANIMATION_SCHEDULER_HXX
25 #define _SDR_ANIMATION_SCHEDULER_HXX
26 
27 #include <sal/types.h>
28 #include <vcl/timer.hxx>
29 #include <svx/svxdllapi.h>
30 
31 //////////////////////////////////////////////////////////////////////////////
32 // event class
33 
34 namespace sdr
35 {
36     namespace animation
37     {
38         class Event
39         {
40             // time of event in ms
41             sal_uInt32                                      mnTime;
42 
43             // pointer for simply linked list
44             Event*                                          mpNext;
45 
46         public:
47             // constructor/destructor
48             Event(sal_uInt32 nTime);
49             SVX_DLLPUBLIC virtual ~Event();
50 
51             // access to mpNext
52             Event* GetNext() const;
53             void SetNext(Event* pNew);
54 
55             // get/set time
56             sal_uInt32 GetTime() const;
57             void SetTime(sal_uInt32 nNew);
58 
59             // execute event
60             virtual void Trigger(sal_uInt32 nTime) = 0;
61         };
62     } // end of namespace animation
63 } // end of namespace sdr
64 
65 //////////////////////////////////////////////////////////////////////////////
66 // eventlist class
67 
68 namespace sdr
69 {
70     namespace animation
71     {
72         class EventList
73         {
74             // pointer to first entry
75             Event*                                          mpHead;
76 
77         public:
78             // constructor/destructor
79             EventList();
80             SVX_DLLPUBLIC virtual ~EventList();
81 
82             // insert/remove time dependent
83             void Insert(Event* pNew);
84             void Remove(Event* pOld);
85 
86             // clear list
87             void Clear();
88 
89             // get first
90             Event* GetFirst();
91         };
92     } // end of namespace animation
93 } // end of namespace sdr
94 
95 //////////////////////////////////////////////////////////////////////////////
96 // scheduler class
97 
98 namespace sdr
99 {
100     namespace animation
101     {
102         class Scheduler : public Timer
103         {
104             // time in ms
105             sal_uInt32                                      mnTime;
106 
107             // next delta time
108             sal_uInt32                                      mnDeltaTime;
109 
110             // list of events
111             EventList                                       maList;
112 
113             // Flag which remembers if this timer is paused. Default
114             // is false.
115             bool                                            mbIsPaused;
116 
117         public:
118             // constructor/destructor
119             Scheduler();
120             SVX_DLLPUBLIC virtual ~Scheduler();
121 
122             // From baseclass Timer, the timeout call
123             SVX_DLLPUBLIC virtual void Timeout();
124 
125             // get time
126             sal_uInt32 GetTime();
127 
128             // #i38135#
129             void SetTime(sal_uInt32 nTime);
130 
131             // reset
132             void Reset(sal_uInt32 nTime);
133 
134             // execute all ripe events, removes executed ones from the scheduler
135             void triggerEvents();
136 
137             // re-start or stop timer according to event list
138             void checkTimeout();
139 
140             // insert/remove events, wrapper to EventList methods
141             void InsertEvent(Event* pNew);
142             void RemoveEvent(Event* pOld);
143 
144             // get/set pause
IsPaused() const145             bool IsPaused() const { return mbIsPaused; }
146             void SetPaused(bool bNew);
147         };
148     } // end of namespace animation
149 } // end of namespace sdr
150 
151 //////////////////////////////////////////////////////////////////////////////
152 
153 #endif //_SDR_ANIMATION_SCHEDULER_HXX
154 
155 // eof
156