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