1 #ifndef oxygentimelineserver_h 2 #define oxygentimelineserver_h 3 4 /* 5 * this file is part of the oxygen gtk engine 6 * Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2 of the License, or(at your option ) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free 20 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 21 * MA 02110-1301, USA. 22 */ 23 24 #include <glib.h> 25 #include <set> 26 namespace Oxygen 27 { 28 29 30 //! forward declaration 31 class TimeLine; 32 33 //! keep track of timelines, triggers update at regular intervals, as long as running 34 class TimeLineServer 35 { 36 37 public: 38 39 //! singleton 40 static TimeLineServer& instance( void ); 41 42 //! destructor 43 virtual ~TimeLineServer( void ); 44 45 //! register timeline registerTimeLine(TimeLine * timeLine)46 void registerTimeLine( TimeLine* timeLine ) 47 { _timeLines.insert( timeLine ); } 48 49 //! unregister timeline unregisterTimeLine(TimeLine * timeLine)50 void unregisterTimeLine( TimeLine* timeLine ) 51 { _timeLines.erase( timeLine ); } 52 53 //! start timeout if needed 54 void start( void ); 55 56 protected: 57 58 //! stop timeout 59 void stop( void ); 60 61 //! update registered timers 62 static gboolean update( gpointer ); 63 64 private: 65 66 //! constructor is private 67 TimeLineServer( void ); 68 69 //! keeps track of all registered timelines 70 typedef std::set< TimeLine* > TimeLineSet; 71 TimeLineSet _timeLines; 72 73 //! timer id 74 int _timerId; 75 76 //! singleton 77 static TimeLineServer* _instance; 78 79 80 81 82 }; 83 84 } 85 86 #endif 87