[rygel] media-export: Make MediaCache single-instance
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Make MediaCache single-instance
- Date: Sat, 7 Aug 2010 15:44:41 +0000 (UTC)
commit 7c17162b41328cbad238d934094b2d6250f804c2
Author: Jens Georg <mail jensge org>
Date: Wed Jul 28 18:29:24 2010 +0200
media-export: Make MediaCache single-instance
.../rygel-media-export-media-cache.vala | 14 ++++++++++++--
.../rygel-media-export-root-container.vala | 2 +-
2 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala b/src/plugins/media-export/rygel-media-export-media-cache.vala
index a6a7304..747786d 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -47,6 +47,8 @@ public class Rygel.MediaExport.MediaCache : Object {
private ObjectFactory factory;
private SQLFactory sql;
+ private static MediaCache instance;
+
public void remove_by_id (string id) throws DatabaseError {
GLib.Value[] values = { id };
this.db.exec (this.sql.make (SQLString.DELETE), values);
@@ -333,9 +335,17 @@ public class Rygel.MediaExport.MediaCache : Object {
return children;
}
- public MediaCache (string name) throws Error {
+ public static MediaCache get_default () throws Error {
+ if (instance == null) {
+ instance = new MediaCache ();
+ }
+
+ return instance;
+ }
+
+ private MediaCache () throws Error {
this.sql = new SQLFactory ();
- this.open_db (name);
+ this.open_db ("media-export");
this.factory = new ObjectFactory ();
}
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala b/src/plugins/media-export/rygel-media-export-root-container.vala
index cdbb394..0dca896 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -257,7 +257,7 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
* Create a new root container.
*/
private RootContainer () throws Error {
- var db = new MediaCache ("media-export");
+ var db = MediaCache.get_default ();
base (db, "0", "MediaExportRoot");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]