xref: /AOO41X/main/slideshow/source/inc/activitiesqueue.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_ACTIVITIESQUEUE_HXX
29*cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_ACTIVITIESQUEUE_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <deque>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "activity.hxx"
34*cdf0e10cSrcweir #include "unoviewcontainer.hxx"
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include <canvas/elapsedtime.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
39*cdf0e10cSrcweir #include <boost/utility.hpp> // for boost::noncopyable
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir /* Definition of ActivitiesQueue class */
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir namespace slideshow
45*cdf0e10cSrcweir {
46*cdf0e10cSrcweir     namespace internal
47*cdf0e10cSrcweir     {
48*cdf0e10cSrcweir 		/** This class handles the XSprite updates needed for
49*cdf0e10cSrcweir             animations, such as moves, scales etc. You can add
50*cdf0e10cSrcweir             activity objects to this class, which are called in a
51*cdf0e10cSrcweir             round-robin fashion.
52*cdf0e10cSrcweir         */
53*cdf0e10cSrcweir         class ActivitiesQueue : private ::boost::noncopyable
54*cdf0e10cSrcweir         {
55*cdf0e10cSrcweir         public:
56*cdf0e10cSrcweir             /** Create an ActivitiesQueue.
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir             	@param pPresTimer
59*cdf0e10cSrcweir                 Pointer to global presentation timer. Used for
60*cdf0e10cSrcweir                 adjusting and holding global presentation time.
61*cdf0e10cSrcweir              */
62*cdf0e10cSrcweir             ActivitiesQueue(
63*cdf0e10cSrcweir                 const ::boost::shared_ptr< ::canvas::tools::ElapsedTime >&	pPresTimer );
64*cdf0e10cSrcweir             ~ActivitiesQueue();
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir             /** Add the given activity to the queue.
67*cdf0e10cSrcweir              */
68*cdf0e10cSrcweir             bool addActivity( const ActivitySharedPtr& pActivity );
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir             /** Process the activities queue.
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir             	This method performs the smallest atomic processing
73*cdf0e10cSrcweir             	possible on the queue (typically, this means one
74*cdf0e10cSrcweir             	activity get processed).
75*cdf0e10cSrcweir              */
76*cdf0e10cSrcweir             void process();
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir             /** Call all dequeued activities' dequeued() method
79*cdf0e10cSrcweir              */
80*cdf0e10cSrcweir             void processDequeued();
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 			/** Query state of the queue
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir                 @return false, if queue is empty, true otherwise
85*cdf0e10cSrcweir              */
86*cdf0e10cSrcweir             bool isEmpty() const;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir             /** Remove all pending activities from the queue.
89*cdf0e10cSrcweir              */
90*cdf0e10cSrcweir             void clear();
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir             /** Gets the queue's timer object.
93*cdf0e10cSrcweir              */
94*cdf0e10cSrcweir             ::boost::shared_ptr< ::canvas::tools::ElapsedTime > const &
95*cdf0e10cSrcweir             getTimer() const { return mpTimer; }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir             /** returns number of all activities, waiting, reinserted and dequeued
98*cdf0e10cSrcweir              */
99*cdf0e10cSrcweir             std::size_t size() const
100*cdf0e10cSrcweir             {
101*cdf0e10cSrcweir                 return maCurrentActivitiesWaiting.size() + maCurrentActivitiesReinsert.size() + maDequeuedActivities.size();
102*cdf0e10cSrcweir             }
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir         private:
105*cdf0e10cSrcweir             ::boost::shared_ptr< ::canvas::tools::ElapsedTime > mpTimer;
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir             typedef ::std::deque< ActivitySharedPtr > ActivityQueue;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir             ActivityQueue 			maCurrentActivitiesWaiting;  // currently running
110*cdf0e10cSrcweir                                     				             // activities, that still
111*cdf0e10cSrcweir 				                                                 // await processing for this
112*cdf0e10cSrcweir                 				                                 // round
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir             ActivityQueue 			maCurrentActivitiesReinsert; 	// currently running
115*cdf0e10cSrcweir 												                  	// activities, that are
116*cdf0e10cSrcweir 										                          	// already processed for
117*cdf0e10cSrcweir 										                          	// this round, and wants
118*cdf0e10cSrcweir 				            										// to be reinserted next
119*cdf0e10cSrcweir 				            										// round
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir             ActivityQueue           maDequeuedActivities; // This list collects all activities which did not request
122*cdf0e10cSrcweir                                                           // a reinsertion. After the screen update has been
123*cdf0e10cSrcweir                                                           // performed, those are notified via dequeued(). This
124*cdf0e10cSrcweir                                                           // facilitates cleanup actions taking place _after_ the
125*cdf0e10cSrcweir                                                           // current frame has been displayed.
126*cdf0e10cSrcweir         };
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     }
129*cdf0e10cSrcweir }
130*cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_ACTIVITIESQUEUE_HXX */
131