|
Freya
0.0.1
A Gtk3 MPD Client
|
00001 /*********************************************************** 00002 * This file is part of Freya 00003 * - A free MPD Gtk3 MPD Client - 00004 * 00005 * Authors: Christopher Pahl, Christoph Piechula, 00006 * Eduard Schneider 00007 * 00008 * Copyright (C) [2011-2012] 00009 * Hosted at: https://github.com/studentkittens/Freya 00010 * 00011 * __..--''``---....___ _..._ __ 00012 * /// //_.-' .-/"; ` ``<._ ``.''_ `. / // / 00013 * ///_.-' _..--.'_ `( ) ) // // 00014 * / (_..-' // (< _ ;_..__ ; `' / /// 00015 * / // // // `-._,_)' // / ``--...____..-' /// / // 00016 * Ascii-Art by Felix Lee <flee@cse.psu.edu> 00017 * 00018 * Freya is free software: you can redistribute it and/or modify 00019 * it under the terms of the GNU General Public License as published by 00020 * the Free Software Foundation, either version 3 of the License, or 00021 * (at your option) any later version. 00022 * 00023 * Freya is distributed in the hope that it will be useful, 00024 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00026 * GNU General Public License for more details. 00027 * 00028 * You should have received a copy of the GNU General Public License 00029 * along with Freya. If not, see <http://www.gnu.org/licenses/>. 00030 **************************************************************/ 00031 00032 #ifndef FREYA_DATABASE_CACHE 00033 #define FREYA_DATABASE_CACHE 00034 00035 #include "../../MPD/AbstractClientUser.hh" 00036 #include "../../MPD/AbstractItemlist.hh" 00037 00038 namespace Browser 00039 { 00050 class DatabaseCache : 00051 public MPD::AbstractClientUser, 00052 public MPD::AbstractItemlist, 00053 public MPD::AbstractItemGenerator 00054 { 00055 public: 00056 00057 DatabaseCache(MPD::Client& client); 00058 virtual ~DatabaseCache(); 00059 00066 void fill_filelist(MPD::AbstractItemlist& data_model, const char * path); 00067 00075 void add_item(MPD::AbstractComposite * pItem); 00076 00077 /* Method stubs .. */ 00078 void fill_queue(MPD::AbstractItemlist& data_model) {} 00079 void fill_queue_changes(MPD::AbstractItemlist& data_model, unsigned last_version, unsigned& first_pos) {} 00080 void fill_playlists(MPD::AbstractItemlist& data_model) {} 00081 void fill_outputs(MPD::AbstractItemlist& data_model) {} 00082 00083 00084 private: 00085 00092 typedef MPD::AbstractComposite* CachePairType; 00096 typedef std::vector<CachePairType> CacheVectorType; 00100 typedef std::map<Glib::ustring,CacheVectorType> CacheMapType; 00101 00102 /* -------------------------------- */ 00103 00110 void on_client_update(mpd_idle event, MPD::NotifyData& data); 00117 void on_connection_change(bool server_changed, bool is_connected); 00118 00119 /* Logic */ 00120 void clear_cache(); 00121 00122 /* ------------------------------- */ 00123 00124 /* Path is the key, value the song or dir */ 00125 CacheMapType cacheMap; 00126 00127 /* The last vector used by fill_filelist */ 00128 CacheVectorType * lastVec; 00129 00130 /* Do not clear on first start.. */ 00131 bool isFirstStart; 00132 bool serverChanged; 00133 }; 00134 } 00135 00136 #endif /* end of include guard: FREYA_DATABASE_CACHE */
1.8.0