|
Freya
0.0.1
A Gtk3 MPD Client
|
00001 #ifndef FREYA_GLYR_REQUEST_HH 00002 #define FREYA_GLYR_REQUEST_HH 00003 00004 #include "../MPD/Client.hh" 00005 #include "../Utils/Singleton.hh" 00006 #include "UpdateInterface.hh" 00007 #include <gdkmm/pixbuf.h> 00008 00009 #include <glyr/cache.h> 00010 00011 namespace Glyr 00012 { 00023 Glib::RefPtr<Gdk::Pixbuf> create_pixbuf_from_cache(GlyrMemCache * c, int size_x = 150, int size_y = 150, bool aspect = false); 00024 00026 00027 class Stack 00028 { 00029 DEF_SINGLETON(Stack) 00030 00031 public: 00032 00040 void request(UpdateInterface * intf, MPD::Song& song, GLYR_GET_TYPE type, int number = 1); 00050 void request(UpdateInterface * intf,const char * artist, const char * album, const char * title, GLYR_GET_TYPE type, int number = 1); 00051 00052 /* 00053 * @brief Deinitializes glyr, kills all running queries, closes db 00054 */ 00055 void destroy(); 00056 00066 void enqueue(UpdateInterface * intf); 00067 00068 private: 00069 00070 /* 00071 * Actual thread function that calls 00072 * glyr_get() and notifies the client 00073 */ 00074 void thread(GlyrQuery * q, UpdateInterface * intf, Glib::Dispatcher * disp, int reqID); 00075 00076 // Vars 00077 00078 /* 00079 * A list of Queries that are running currently, 00080 * this is currently used to call glyr_signal_exit() 00081 * at program termination 00082 */ 00083 typedef std::vector<GlyrQuery*> QueryList; 00084 QueryList murderList; 00085 00086 /* 00087 * A pool of parallel executing Queries, 00088 * each thread one request 00089 */ 00090 Glib::ThreadPool pool; 00091 00092 /* 00093 * A counter of currently running jobs, 00094 * once could also just use murderList.size(), 00095 * which is not atomar and would require 00096 * additional locking 00097 */ 00098 int jobCounter; 00099 00100 /* 00101 * Locking stuff. 00102 */ 00103 Glib::Cond destroyCond; 00104 Glib::Mutex deliverMutex, condMutex, deleteMutex; 00105 00106 /* 00107 * True once destroy() was called 00108 */ 00109 bool gotDestroyed; 00110 00111 /* 00112 * Database connection 00113 */ 00114 GlyrDatabase * dbConnection; 00115 }; 00116 } 00117 00118 #endif /* end of include guard: FREYA_GLYR_REQUEST_HH */
1.8.0