File indexing completed on 2024-05-12 05:34:36
0001 #ifndef oxygentimelineserver_h 0002 #define oxygentimelineserver_h 0003 0004 /* 0005 * this file is part of the oxygen gtk engine 0006 * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0007 * 0008 * SPDX-License-Identifier: LGPL-2.0-or-later 0009 */ 0010 0011 #include <glib.h> 0012 #include <set> 0013 namespace Oxygen 0014 { 0015 0016 0017 //! forward declaration 0018 class TimeLine; 0019 0020 //! keep track of timelines, triggers update at regular intervals, as long as running 0021 class TimeLineServer 0022 { 0023 0024 public: 0025 0026 //! singleton 0027 static TimeLineServer& instance( void ); 0028 0029 //! destructor 0030 virtual ~TimeLineServer( void ); 0031 0032 //! register timeline 0033 void registerTimeLine( TimeLine* timeLine ) 0034 { _timeLines.insert( timeLine ); } 0035 0036 //! unregister timeline 0037 void unregisterTimeLine( TimeLine* timeLine ) 0038 { _timeLines.erase( timeLine ); } 0039 0040 //! start timeout if needed 0041 void start( void ); 0042 0043 protected: 0044 0045 //! stop timeout 0046 void stop( void ); 0047 0048 //! update registered timers 0049 static gboolean update( gpointer ); 0050 0051 private: 0052 0053 //! constructor is private 0054 TimeLineServer( void ); 0055 0056 //! keeps track of all registered timelines 0057 typedef std::set< TimeLine* > TimeLineSet; 0058 TimeLineSet _timeLines; 0059 0060 //! timer id 0061 int _timerId; 0062 0063 //! singleton 0064 static TimeLineServer* _instance; 0065 0066 0067 0068 0069 }; 0070 0071 } 0072 0073 #endif