[folks] backends: Remove BackendFactory classes



commit 6cfcdc7d4aa5c7549180b2d6638c513844ab916a
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Mon Oct 28 09:53:32 2013 +0000

    backends: Remove BackendFactory classes
    
    They were constructed, made one method call in their constructor, and then
    sat there for the lifetime of the process, using a little bit of memory each,
    and not doing anything else.
    
    Instead, just add the new Backend to the BackendStore directly from the
    module initialiser. This cuts out a reasonable amount of generated C, and
    slightly reduces memory overheads. Yay!

 backends/eds/eds-backend-factory.vala         |   27 +++++-------------------
 backends/key-file/kf-backend-factory.vala     |   25 +++++-----------------
 backends/libsocialweb/sw-backend-factory.vala |   25 +++++-----------------
 backends/ofono/ofono-backend-factory.vala     |   23 +-------------------
 backends/telepathy/tp-backend-factory.vala    |   25 +++++-----------------
 backends/tracker/tr-backend-factory.vala      |   27 ++++++------------------
 6 files changed, 33 insertions(+), 119 deletions(-)
---
diff --git a/backends/eds/eds-backend-factory.vala b/backends/eds/eds-backend-factory.vala
index 9e19c3b..51dcf62 100644
--- a/backends/eds/eds-backend-factory.vala
+++ b/backends/eds/eds-backend-factory.vala
@@ -25,40 +25,25 @@
  */
 
 using Folks;
-using Folks.Backends.Eds;
-
-private BackendFactory _backend_factory = null;
 
 /**
- * The eds backend module entry point.
+ * The EDS backend module entry point.
  *
+ * @backend_store a store to add the EDS backends to
  * @since 0.6.0
  */
 public void module_init (BackendStore backend_store)
 {
-  _backend_factory = new BackendFactory (backend_store);
+  backend_store.add_backend (new Folks.Backends.Eds.Backend ());
 }
 
 /**
- * The eds backend module exit point.
+ * The EDS backend module exit point.
  *
+ * @param backend_store the store to remove the backends from
  * @since 0.6.0
  */
 public void module_finalize (BackendStore backend_store)
 {
-  _backend_factory = null;
-}
-
-/**
- * A backend factory to create a single { link Backend}.
- */
-public class Folks.Backends.Eds.BackendFactory : Object
-{
-  /**
-   * { inheritDoc}
-   */
-  public BackendFactory (BackendStore backend_store)
-    {
-      backend_store.add_backend (new Backend ());
-    }
+  /* FIXME: No way to remove backends from the store. */
 }
diff --git a/backends/key-file/kf-backend-factory.vala b/backends/key-file/kf-backend-factory.vala
index c779cf8..da949fc 100644
--- a/backends/key-file/kf-backend-factory.vala
+++ b/backends/key-file/kf-backend-factory.vala
@@ -24,36 +24,23 @@
  */
 
 using Folks;
-using Folks.Backends.Kf;
-
-private BackendFactory _backend_factory = null;
 
 /**
  * The backend module entry point.
+ *
+ * @backend_store a store to add the key-file backends to
  */
 public void module_init (BackendStore backend_store)
 {
-  _backend_factory = new BackendFactory (backend_store);
+  backend_store.add_backend (new Folks.Backends.Kf.Backend ());
 }
 
 /**
  * The backend module exit point.
+ *
+ * @param backend_store the store to remove the backends from
  */
 public void module_finalize (BackendStore backend_store)
 {
-  _backend_factory = null;
-}
-
-/**
- * A backend factory to create a single { link Backend}.
- */
-public class Folks.Backends.Kf.BackendFactory : Object
-{
-  /**
-   * { inheritDoc}
-   */
-  public BackendFactory (BackendStore backend_store)
-    {
-      backend_store.add_backend (new Backend ());
-    }
+  /* FIXME: No way to remove backends from the store. */
 }
diff --git a/backends/libsocialweb/sw-backend-factory.vala b/backends/libsocialweb/sw-backend-factory.vala
index 14ede90..6615799 100644
--- a/backends/libsocialweb/sw-backend-factory.vala
+++ b/backends/libsocialweb/sw-backend-factory.vala
@@ -24,36 +24,23 @@
  */
 
 using Folks;
-using Folks.Backends.Sw;
-
-private BackendFactory backend_factory = null;
 
 /**
  * The libsocialweb backend module entry point.
+ *
+ * @backend_store a store to add the libsocialweb backends to
  */
 public void module_init (BackendStore backend_store)
 {
-  backend_factory = new BackendFactory (backend_store);
+  backend_store.add_backend (new Folks.Backends.Sw.Backend ());
 }
 
 /**
  * The libsocialweb backend module exit point.
+ *
+ * @param backend_store the store to remove the backends from
  */
 public void module_finalize (BackendStore backend_store)
 {
-  backend_factory = null;
-}
-
-/**
- * A backend factory to create a single { link Backend}.
- */
-public class Folks.Backends.Sw.BackendFactory : Object
-{
-  /**
-   * { inheritDoc}
-   */
-  public BackendFactory (BackendStore backend_store)
-    {
-      backend_store.add_backend (new Backend ());
-    }
+  /* FIXME: No way to remove backends from the store. */
 }
diff --git a/backends/ofono/ofono-backend-factory.vala b/backends/ofono/ofono-backend-factory.vala
index 22e175e..de2c946 100644
--- a/backends/ofono/ofono-backend-factory.vala
+++ b/backends/ofono/ofono-backend-factory.vala
@@ -26,9 +26,6 @@
  */
 
 using Folks;
-using Folks.Backends.Ofono;
-
-private BackendFactory? _backend_factory = null;
 
 /**
  * The backend module entry point.
@@ -39,7 +36,7 @@ private BackendFactory? _backend_factory = null;
  */
 public void module_init (BackendStore backend_store)
 {
-  _backend_factory = new BackendFactory (backend_store);
+  backend_store.add_backend (new Folks.Backends.Ofono.Backend ());
 }
 
 /**
@@ -51,21 +48,5 @@ public void module_init (BackendStore backend_store)
  */
 public void module_finalize (BackendStore backend_store)
 {
-  _backend_factory = null;
-}
-
-/**
- * A backend factory to create a single { link Backend}.
- *
- * @since 0.9.0
- */
-public class Folks.Backends.Ofono.BackendFactory : Object
-{
-  /**
-   * { inheritDoc}
-   */
-  public BackendFactory (BackendStore backend_store)
-    {
-      backend_store.add_backend (new Backend ());
-    }
+  /* FIXME: No way to remove backends from the store. */
 }
diff --git a/backends/telepathy/tp-backend-factory.vala b/backends/telepathy/tp-backend-factory.vala
index 8dbc689..ed1106c 100644
--- a/backends/telepathy/tp-backend-factory.vala
+++ b/backends/telepathy/tp-backend-factory.vala
@@ -23,36 +23,23 @@
  */
 
 using Folks;
-using Folks.Backends.Tp;
-
-private BackendFactory _backend_factory = null;
 
 /**
  * The Telepathy backend module entry point.
+ *
+ * @backend_store a store to add the Telepathy backends to
  */
 public void module_init (BackendStore backend_store)
 {
-  _backend_factory = new BackendFactory (backend_store);
+  backend_store.add_backend (new Folks.Backends.Tp.Backend ());
 }
 
 /**
  * The Telepathy backend module exit point.
+ *
+ * @param backend_store the store to remove the backends from
  */
 public void module_finalize (BackendStore backend_store)
 {
-  _backend_factory = null;
-}
-
-/**
- * A backend factory to create a single { link Backend}.
- */
-public class Folks.Backends.Tp.BackendFactory : Object
-{
-  /**
-   * { inheritDoc}
-   */
-  public BackendFactory (BackendStore backend_store)
-    {
-      backend_store.add_backend (new Backend ());
-    }
+  /* FIXME: No way to remove backends from the store. */
 }
diff --git a/backends/tracker/tr-backend-factory.vala b/backends/tracker/tr-backend-factory.vala
index c3ff71e..1ff07af 100644
--- a/backends/tracker/tr-backend-factory.vala
+++ b/backends/tracker/tr-backend-factory.vala
@@ -24,36 +24,23 @@
  */
 
 using Folks;
-using Folks.Backends.Tr;
-
-private BackendFactory _backend_factory = null;
 
 /**
- * The tracker backend module entry point.
+ * The Tracker backend module entry point.
+ *
+ * @backend_store a store to add the Tracker backends to
  */
 public void module_init (BackendStore backend_store)
 {
-  _backend_factory = new BackendFactory (backend_store);
+  backend_store.add_backend (new Folks.Backends.Tr.Backend ());
 }
 
 /**
  * The tracker backend module exit point.
+ *
+ * @param backend_store the store to remove the backends from
  */
 public void module_finalize (BackendStore backend_store)
 {
-  _backend_factory = null;
-}
-
-/**
- * A backend factory to create a single { link Backend}.
- */
-public class Folks.Backends.Tr.BackendFactory : Object
-{
-  /**
-   * { inheritDoc}
-   */
-  public BackendFactory (BackendStore backend_store)
-    {
-      backend_store.add_backend (new Backend ());
-    }
+  /* FIXME: No way to remove backends from the store. */
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]