1*aaef562fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*aaef562fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*aaef562fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*aaef562fSAndrew Rist * distributed with this work for additional information 6*aaef562fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*aaef562fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*aaef562fSAndrew Rist * "License"); you may not use this file except in compliance 9*aaef562fSAndrew Rist * with the License. You may obtain a copy of the License at 10*aaef562fSAndrew Rist * 11*aaef562fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*aaef562fSAndrew Rist * 13*aaef562fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*aaef562fSAndrew Rist * software distributed under the License is distributed on an 15*aaef562fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*aaef562fSAndrew Rist * KIND, either express or implied. See the License for the 17*aaef562fSAndrew Rist * specific language governing permissions and limitations 18*aaef562fSAndrew Rist * under the License. 19*aaef562fSAndrew Rist * 20*aaef562fSAndrew Rist *************************************************************/ 21*aaef562fSAndrew Rist 22*aaef562fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_ACTIVITIESQUEUE_HXX 25cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_ACTIVITIESQUEUE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <deque> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "activity.hxx" 30cdf0e10cSrcweir #include "unoviewcontainer.hxx" 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <canvas/elapsedtime.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 35cdf0e10cSrcweir #include <boost/utility.hpp> // for boost::noncopyable 36cdf0e10cSrcweir 37cdf0e10cSrcweir 38cdf0e10cSrcweir /* Definition of ActivitiesQueue class */ 39cdf0e10cSrcweir 40cdf0e10cSrcweir namespace slideshow 41cdf0e10cSrcweir { 42cdf0e10cSrcweir namespace internal 43cdf0e10cSrcweir { 44cdf0e10cSrcweir /** This class handles the XSprite updates needed for 45cdf0e10cSrcweir animations, such as moves, scales etc. You can add 46cdf0e10cSrcweir activity objects to this class, which are called in a 47cdf0e10cSrcweir round-robin fashion. 48cdf0e10cSrcweir */ 49cdf0e10cSrcweir class ActivitiesQueue : private ::boost::noncopyable 50cdf0e10cSrcweir { 51cdf0e10cSrcweir public: 52cdf0e10cSrcweir /** Create an ActivitiesQueue. 53cdf0e10cSrcweir 54cdf0e10cSrcweir @param pPresTimer 55cdf0e10cSrcweir Pointer to global presentation timer. Used for 56cdf0e10cSrcweir adjusting and holding global presentation time. 57cdf0e10cSrcweir */ 58cdf0e10cSrcweir ActivitiesQueue( 59cdf0e10cSrcweir const ::boost::shared_ptr< ::canvas::tools::ElapsedTime >& pPresTimer ); 60cdf0e10cSrcweir ~ActivitiesQueue(); 61cdf0e10cSrcweir 62cdf0e10cSrcweir /** Add the given activity to the queue. 63cdf0e10cSrcweir */ 64cdf0e10cSrcweir bool addActivity( const ActivitySharedPtr& pActivity ); 65cdf0e10cSrcweir 66cdf0e10cSrcweir /** Process the activities queue. 67cdf0e10cSrcweir 68cdf0e10cSrcweir This method performs the smallest atomic processing 69cdf0e10cSrcweir possible on the queue (typically, this means one 70cdf0e10cSrcweir activity get processed). 71cdf0e10cSrcweir */ 72cdf0e10cSrcweir void process(); 73cdf0e10cSrcweir 74cdf0e10cSrcweir /** Call all dequeued activities' dequeued() method 75cdf0e10cSrcweir */ 76cdf0e10cSrcweir void processDequeued(); 77cdf0e10cSrcweir 78cdf0e10cSrcweir /** Query state of the queue 79cdf0e10cSrcweir 80cdf0e10cSrcweir @return false, if queue is empty, true otherwise 81cdf0e10cSrcweir */ 82cdf0e10cSrcweir bool isEmpty() const; 83cdf0e10cSrcweir 84cdf0e10cSrcweir /** Remove all pending activities from the queue. 85cdf0e10cSrcweir */ 86cdf0e10cSrcweir void clear(); 87cdf0e10cSrcweir 88cdf0e10cSrcweir /** Gets the queue's timer object. 89cdf0e10cSrcweir */ 90cdf0e10cSrcweir ::boost::shared_ptr< ::canvas::tools::ElapsedTime > const & getTimer() const91cdf0e10cSrcweir getTimer() const { return mpTimer; } 92cdf0e10cSrcweir 93cdf0e10cSrcweir /** returns number of all activities, waiting, reinserted and dequeued 94cdf0e10cSrcweir */ size() const95cdf0e10cSrcweir std::size_t size() const 96cdf0e10cSrcweir { 97cdf0e10cSrcweir return maCurrentActivitiesWaiting.size() + maCurrentActivitiesReinsert.size() + maDequeuedActivities.size(); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir private: 101cdf0e10cSrcweir ::boost::shared_ptr< ::canvas::tools::ElapsedTime > mpTimer; 102cdf0e10cSrcweir 103cdf0e10cSrcweir typedef ::std::deque< ActivitySharedPtr > ActivityQueue; 104cdf0e10cSrcweir 105cdf0e10cSrcweir ActivityQueue maCurrentActivitiesWaiting; // currently running 106cdf0e10cSrcweir // activities, that still 107cdf0e10cSrcweir // await processing for this 108cdf0e10cSrcweir // round 109cdf0e10cSrcweir 110cdf0e10cSrcweir ActivityQueue maCurrentActivitiesReinsert; // currently running 111cdf0e10cSrcweir // activities, that are 112cdf0e10cSrcweir // already processed for 113cdf0e10cSrcweir // this round, and wants 114cdf0e10cSrcweir // to be reinserted next 115cdf0e10cSrcweir // round 116cdf0e10cSrcweir 117cdf0e10cSrcweir ActivityQueue maDequeuedActivities; // This list collects all activities which did not request 118cdf0e10cSrcweir // a reinsertion. After the screen update has been 119cdf0e10cSrcweir // performed, those are notified via dequeued(). This 120cdf0e10cSrcweir // facilitates cleanup actions taking place _after_ the 121cdf0e10cSrcweir // current frame has been displayed. 122cdf0e10cSrcweir }; 123cdf0e10cSrcweir 124cdf0e10cSrcweir } 125cdf0e10cSrcweir } 126cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_ACTIVITIESQUEUE_HXX */ 127