[glom] Remove ifdefs from libglom to allow parallel install of full and



commit 5ec8e28f2341e2c2cb1c485dd05d39d9ddd59239
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Jul 4 12:09:19 2009 +0200

    Remove ifdefs from libglom to allow parallel install of full and
    client-only versions.
    
    * glom/libglom/connectionpool_backends/postgres.h:
    * glom/libglom/connectionpool_backends/postgres_central.h:
    * glom/libglom/connectionpool_backends/sqlite.h:
    * glom/libglom/document/document.[h|cc]:
    * glom/libglom/test_connectionpool.cc: Remove ifdefs that remove
    PostgreSQL or Sqlite API so that libglom always offers all features and
    always has the same ABI (ignoring no-exceptions/no-vfuncs
    alternative-glibmm-api versions). This will allow us to parallel install
    the full and client-only versions.
    
    * glom/libglom/libglom_config.h.in: Move GLOM_ENABLE_POSTGRESQL/SQLITE
    config.h.in because we now only use it in the application, not in libglom.
    * glom/application.cc:
    * glom/dialog_connection.cc:
    * glom/frame_glom.cc:
    * glom/utility_widgets/filechooserdialog_saveextras.cc:
    * glom/utility_widgets/filechooserdialog_saveextras.h:
    Include config.h to get these
    definitions.

 ChangeLog                                          |   25 ++++++++++++++++++
 config.h.in                                        |    6 ++++
 glom/application.cc                                |   14 +++++-----
 glom/dialog_connection.cc                          |    1 +
 glom/frame_glom.cc                                 |    3 +-
 glom/libglom/connectionpool_backends/postgres.h    |    4 ---
 .../connectionpool_backends/postgres_central.h     |    4 ---
 glom/libglom/connectionpool_backends/sqlite.h      |    6 +---
 glom/libglom/document/document.cc                  |   27 ++-----------------
 glom/libglom/document/document.h                   |   13 ++-------
 glom/libglom/libglom_config.h.in                   |    6 ----
 glom/libglom/test_connectionpool.cc                |    2 +
 .../filechooserdialog_saveextras.cc                |    1 +
 .../utility_widgets/filechooserdialog_saveextras.h |    3 +-
 14 files changed, 53 insertions(+), 62 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6d016a0..77df73d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2009-07-04  Murray Cumming  <murrayc murrayc com>
+
+	Remove ifdefs from libglom to allow parallel install of full and 
+	client-only versions.
+
+	* glom/libglom/connectionpool_backends/postgres.h:
+	* glom/libglom/connectionpool_backends/postgres_central.h:
+	* glom/libglom/connectionpool_backends/sqlite.h:
+	* glom/libglom/document/document.[h|cc]: 
+	* glom/libglom/test_connectionpool.cc: Remove ifdefs that remove 
+	PostgreSQL or Sqlite API so that libglom always offers all features and 
+	always has the same ABI (ignoring no-exceptions/no-vfuncs 
+	alternative-glibmm-api versions). This will allow us to parallel install 
+	the full and client-only versions.
+
+	* glom/libglom/libglom_config.h.in: Move GLOM_ENABLE_POSTGRESQL/SQLITE 
+	config.h.in because we now only use it in the application, not in libglom.
+	* glom/application.cc:
+	* glom/dialog_connection.cc:
+	* glom/frame_glom.cc:
+	* glom/utility_widgets/filechooserdialog_saveextras.cc:
+	* glom/utility_widgets/filechooserdialog_saveextras.h:
+	Include config.h to get these 
+	definitions.
+
 2009-07-03  Murray Cumming  <murrayc murrayc com>
 
 	Allow parallel installs of libglom major versions.
diff --git a/config.h.in b/config.h.in
index 915afdb..d765f7c 100644
--- a/config.h.in
+++ b/config.h.in
@@ -2,6 +2,12 @@
 /* Include libglom_config.h so we also get the prefixed definitions */
 #include "glom/libglom/libglom_config.h"
 
+/* Whether to enable support for PostgreSQL databases. */
+#undef GLOM_ENABLE_POSTGRESQL
+
+/* Whether to enable support for SQLite databases. */
+#undef GLOM_ENABLE_SQLITE
+
 /* always defined to indicate that i18n is enabled */
 #undef ENABLE_NLS
 
diff --git a/glom/application.cc b/glom/application.cc
index 3cd2f56..041ca7b 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -102,7 +102,7 @@ App_Glom::App_Glom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& bu
   m_menu_print_layouts_ui_merge_id(0),
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   m_ui_save_extra_showextras(false),
-  m_ui_save_extra_newdb_hosting_mode(Document::DEFAULT_HOSTED),
+  m_ui_save_extra_newdb_hosting_mode(Document::HOSTING_MODE_DEFAULT),
 
 #endif // !GLOM_ENABLE_CLIENT_ONLY
   m_avahi_progress_dialog(0),
@@ -989,7 +989,7 @@ bool App_Glom::on_document_load()
         m_ui_save_extra_title = _("Creating From Example File");
         m_ui_save_extra_message = _("To use this example file you must save an editable copy of the file. A new database will also be created on the server.");
         m_ui_save_extra_newdb_title = "TODO";
-        m_ui_save_extra_newdb_hosting_mode = Document::DEFAULT_HOSTED;
+        m_ui_save_extra_newdb_hosting_mode = Document::HOSTING_MODE_DEFAULT;
 
         
         // Reinit cancelled state
@@ -1006,7 +1006,7 @@ bool App_Glom::on_document_load()
           //Get the results from the extended save dialog:
           pDocument->set_database_title(m_ui_save_extra_newdb_title);
           pDocument->set_hosting_mode(m_ui_save_extra_newdb_hosting_mode);
-          m_ui_save_extra_newdb_hosting_mode = Document::DEFAULT_HOSTED;
+          m_ui_save_extra_newdb_hosting_mode = Document::HOSTING_MODE_DEFAULT;
           pDocument->set_is_example_file(false);
 
           // For self-hosting, we will choose a port later. For central
@@ -1360,7 +1360,7 @@ void App_Glom::existing_or_new_new()
   Glib::ustring db_title;
 
   m_ui_save_extra_showextras = true; //Offer self-hosting or central hosting, and offer the database title.
-  m_ui_save_extra_newdb_hosting_mode = Document::DEFAULT_HOSTED; /* Default to self-hosting */
+  m_ui_save_extra_newdb_hosting_mode = Document::HOSTING_MODE_DEFAULT; /* Default to self-hosting */
   m_ui_save_extra_newdb_title.clear();
   offer_saveas();
 
@@ -1372,13 +1372,13 @@ void App_Glom::existing_or_new_new()
     const Glib::ustring db_title = m_ui_save_extra_newdb_title;
     Document::HostingMode hosting_mode = m_ui_save_extra_newdb_hosting_mode;
     m_ui_save_extra_newdb_title.clear();
-    m_ui_save_extra_newdb_hosting_mode = Document::DEFAULT_HOSTED;
+    m_ui_save_extra_newdb_hosting_mode = Document::HOSTING_MODE_DEFAULT;
 
     //Make sure that the user can do something with his new document:
     document->set_userlevel(AppState::USERLEVEL_DEVELOPER);
     // Try various ports if connecting to an existing database server instead
     // of self-hosting one:
-    document->set_connection_try_other_ports(m_ui_save_extra_newdb_hosting_mode == Document::DEFAULT_HOSTED);
+    document->set_connection_try_other_ports(m_ui_save_extra_newdb_hosting_mode == Document::HOSTING_MODE_DEFAULT);
 
     //Each new document must have an associated new database,
     //so choose a name
@@ -2008,7 +2008,7 @@ void App_Glom::on_menu_file_save_as_example()
   m_ui_save_extra_title.clear();
   m_ui_save_extra_message.clear();
   m_ui_save_extra_newdb_title.clear();
-  m_ui_save_extra_newdb_hosting_mode = Document::DEFAULT_HOSTED;
+  m_ui_save_extra_newdb_hosting_mode = Document::HOSTING_MODE_DEFAULT;
 
   Glib::ustring file_uri = ui_file_select_save(file_uriOld); //Also asks for overwrite confirmation.
   if(!file_uri.empty())
diff --git a/glom/dialog_connection.cc b/glom/dialog_connection.cc
index 524a96d..f75646a 100644
--- a/glom/dialog_connection.cc
+++ b/glom/dialog_connection.cc
@@ -18,6 +18,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include "config.h" //For GLOM_ENABLE_POSTGRESQL
 #include "dialog_connection.h"
 #include "box_withbuttons.h" //For Box_WithButtons::connect_to_server().
 #include <glibmm/i18n.h>
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 7f06de5..293e5ec 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -18,7 +18,8 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include <libglom/libglom_config.h> // For GLOM_ENABLE_SQLITE, GLOM_ENABLE_CLIENT_ONLY
+#include "config.h" //For GLOM_ENABLE_SQLITE
+#include <libglom/libglom_config.h> // For GLOM_ENABLE_CLIENT_ONLY
 
 #include <glom/frame_glom.h>
 #include <glom/application.h>
diff --git a/glom/libglom/connectionpool_backends/postgres.h b/glom/libglom/connectionpool_backends/postgres.h
index 1fbdd2c..30b1f02 100644
--- a/glom/libglom/connectionpool_backends/postgres.h
+++ b/glom/libglom/connectionpool_backends/postgres.h
@@ -26,10 +26,6 @@
 
 #include <libglom/libglom_config.h> // For GLOM_ENABLE_CLIENT_ONLY
 
-#ifndef GLOM_ENABLE_POSTGRESQL
-# error The Glom <postgres.h> backend has been included even though PostgreSQL support is disabled
-#endif
-
 namespace Glom
 {
 
diff --git a/glom/libglom/connectionpool_backends/postgres_central.h b/glom/libglom/connectionpool_backends/postgres_central.h
index 8c330b5..3858040 100644
--- a/glom/libglom/connectionpool_backends/postgres_central.h
+++ b/glom/libglom/connectionpool_backends/postgres_central.h
@@ -25,10 +25,6 @@
 
 #include <libglom/libglom_config.h> // For GLOM_ENABLE_CLIENT_ONLY
 
-#ifndef GLOM_ENABLE_POSTGRESQL
-# error The Glom <postgres_central.h> backend has been included even though PostgreSQL support is disabled
-#endif
-
 namespace Glom
 {
 
diff --git a/glom/libglom/connectionpool_backends/sqlite.h b/glom/libglom/connectionpool_backends/sqlite.h
index bb1c84b..07bad41 100644
--- a/glom/libglom/connectionpool_backends/sqlite.h
+++ b/glom/libglom/connectionpool_backends/sqlite.h
@@ -24,11 +24,7 @@
 #include <libgdamm.h>
 #include <libglom/connectionpool_backends/backend.h>
 
-#include <libglom/libglom_config.h> // For GLOM_ENABLE_CLIENT_ONLY, GLOM_ENABLE_SQLITE
-
-#ifndef GLOM_ENABLE_SQLITE
-# error The Glom <sqlite.h> backend has been included even though sqlite support is disabled
-#endif
+#include <libglom/libglom_config.h> // For GLOM_ENABLE_CLIENT_ONLY
 
 namespace Glom
 {
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 85ba111..d039b83 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -238,8 +238,7 @@ private:
 
 
 Document::Document()
-:
-  m_hosting_mode(DEFAULT_HOSTED),
+: m_hosting_mode(HOSTING_MODE_DEFAULT),
   m_network_shared(false),
   m_connection_port(0),
   m_connection_try_other_ports(false),
@@ -327,20 +326,15 @@ std::string Document::get_connection_self_hosted_directory_uri() const
     {
       switch(m_hosting_mode)
       {
-#ifdef GLOM_ENABLE_POSTGRESQL
       case HOSTING_MODE_POSTGRES_SELF:
         datadir = parent->get_child("glom_postgres_data");
         break;
       case HOSTING_MODE_POSTGRES_CENTRAL:
         datadir = parent;
         break;
-#endif //GLOM_ENABLE_POSTGRESQL
-
-#ifdef GLOM_ENABLE_SQLITE
       case HOSTING_MODE_SQLITE:
         datadir = parent;
         break;
-#endif //GLOM_ENABLE_SQLITE
       default:
         g_assert_not_reached();
         break;
@@ -2390,32 +2384,24 @@ bool Document::load_after(int& failure_code)
 
         const Glib::ustring attr_mode = get_node_attribute_value(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE);
 
-        HostingMode mode = DEFAULT_HOSTED;
+        HostingMode mode = HOSTING_MODE_DEFAULT;
 
         if(attr_mode.empty())
         {
-#ifdef GLOM_ENABLE_POSTGRESQL
           // If no hosting mode is set, then try the self_hosted flag which
           // was used before sqlite support was implemented.
           const bool self_hosted = get_node_attribute_value_as_bool(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_SELF_HOSTED);
           mode = self_hosted ? HOSTING_MODE_POSTGRES_SELF : HOSTING_MODE_POSTGRES_CENTRAL;
-#endif //GLOM_ENABLE_POSTGRESQL
         }
         else
         {
-#ifdef GLOM_ENABLE_POSTGRESQL
           if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_POSTGRES_CENTRAL)
             mode = HOSTING_MODE_POSTGRES_CENTRAL;
           else if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_POSTGRES_SELF)
             mode = HOSTING_MODE_POSTGRES_SELF;
-          else
-#endif //GLOM_ENABLE_POSTGRESQL
-
-#ifdef GLOM_ENABLE_SQLITE
-          if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_SQLITE)
+          else if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_SQLITE)
             mode = HOSTING_MODE_SQLITE;
           else
-#endif //GLOM_ENABLE_SQLITE
 	  {
             std::cerr << "Document::load_after(): Hosting mode " << attr_mode << " is not supported" << std::endl;
             return false; //TODO: Provide more information so the application (or Bakery) can say exactly why loading failed.
@@ -2423,13 +2409,11 @@ bool Document::load_after(int& failure_code)
         }
 
 #ifdef GLOM_ENABLE_CLIENT_ONLY
-#ifdef GLOM_ENABLE_POSTGRESQL
         if(mode == HOSTING_MODE_POSTGRES_SELF) //TODO: Define these enums always and show a dialog saying that the feature is not enabled.
         {
           std::cerr << "Document::load_after(): Loading failed because the document needs to be self-hosted, but self-hosting is not supported in client only mode" << std::endl;
           return false; //TODO: Provide more information so the application (or Bakery) can say exactly why loading failed.
         }
-#endif //GLOM_ENABLE_POSTGRESQL
 #endif
         m_hosting_mode = mode;
       }
@@ -3296,20 +3280,15 @@ bool Document::save_before()
 
     switch(m_hosting_mode)
     {
-#ifdef GLOM_ENABLE_POSTGRESQL
     case HOSTING_MODE_POSTGRES_CENTRAL:
       set_node_attribute_value(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE, GLOM_ATTRIBUTE_CONNECTION_HOSTING_POSTGRES_CENTRAL);
       break;
     case HOSTING_MODE_POSTGRES_SELF:
       set_node_attribute_value(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE, GLOM_ATTRIBUTE_CONNECTION_HOSTING_POSTGRES_SELF);
       break;
-#endif //GLOM_ENABLE_POSTGRESQL
-
-#ifdef GLOM_ENABLE_SQLITE
     case HOSTING_MODE_SQLITE:
       set_node_attribute_value(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE, GLOM_ATTRIBUTE_CONNECTION_HOSTING_SQLITE);
       break;
-#endif
     default:
       g_assert_not_reached();
       break;
diff --git a/glom/libglom/document/document.h b/glom/libglom/document/document.h
index e2d4274..ed6828e 100644
--- a/glom/libglom/document/document.h
+++ b/glom/libglom/document/document.h
@@ -21,7 +21,7 @@
 #ifndef DOCUMENT_GLOM_H
 #define DOCUMENT_GLOM_H
 
-#include <libglom/libglom_config.h> // For GLOM_ENABLE_CLIENT_ONLY, GLOM_ENABLE_SQLITE
+#include <libglom/libglom_config.h> // For GLOM_ENABLE_CLIENT_ONLY
 
 #include <libglom/document/bakery/document_xml.h>
 #include <libglom/data_structure/relationship.h>
@@ -100,21 +100,14 @@ public:
   /// How the database is hosted.
   enum HostingMode
   {
-    //Only enabled if GLOM_ENABLE_POSTGRESQL is defined:
     HOSTING_MODE_POSTGRES_CENTRAL, /*!< The database is hosted on an external postgresql server. */
     
-    //Only enabled if GLOM_ENABLE_POSTGRESQL is defined and GLOM_ENABLE_CLIENT_ONLY is not defined:
+    //Only enabled if GLOM_ENABLE_CLIENT_ONLY is not defined:
     HOSTING_MODE_POSTGRES_SELF, /*!< A new postgres database process is spawned that hosts the data. */
 
-    //Only enabled if GLOM_ENABLE_SQLITE is defined:
     HOSTING_MODE_SQLITE, /*!< A sqlite database file is used. */
 
-    //This reduces the ifdefs elsewhere:
-#ifdef GLOM_ENABLE_POSTGRESQL
-    DEFAULT_HOSTED = HOSTING_MODE_POSTGRES_SELF
-#else
-    DEFAULT_HOSTED = HOSTING_MODE_SQLITE
-#endif
+    HOSTING_MODE_DEFAULT = HOSTING_MODE_POSTGRES_SELF /*!- Arbitrary default. */
   };
 
   /** Set the hosting mode of the database. 
diff --git a/glom/libglom/libglom_config.h.in b/glom/libglom/libglom_config.h.in
index 721b47c..baf3a45 100644
--- a/glom/libglom/libglom_config.h.in
+++ b/glom/libglom/libglom_config.h.in
@@ -11,10 +11,4 @@
 /* Whether to enable support for the maemo platform */
 #undef GLOM_ENABLE_MAEMO
 
-/* Whether to enable support for PostgreSQL databases. */
-#undef GLOM_ENABLE_POSTGRESQL
-
-/* Whether to enable support for SQLite databases. */
-#undef GLOM_ENABLE_SQLITE
-
 #endif /* GLOM_LIBGLOM_CONFIG_H */
diff --git a/glom/libglom/test_connectionpool.cc b/glom/libglom/test_connectionpool.cc
index 02328aa..5f3222e 100644
--- a/glom/libglom/test_connectionpool.cc
+++ b/glom/libglom/test_connectionpool.cc
@@ -21,6 +21,8 @@
 #include <libgdamm/init.h>
 #include <libglom/connectionpool.h>
 
+#define GLOM_ENABLE_POSTGRESQL
+
 #ifdef GLOM_ENABLE_POSTGRESQL
 #include <libglom/connectionpool_backends/postgres_central.h>
 #else
diff --git a/glom/utility_widgets/filechooserdialog_saveextras.cc b/glom/utility_widgets/filechooserdialog_saveextras.cc
index 4c0901a..1dd081b 100644
--- a/glom/utility_widgets/filechooserdialog_saveextras.cc
+++ b/glom/utility_widgets/filechooserdialog_saveextras.cc
@@ -18,6 +18,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include "config.h"
 #include <glom/utility_widgets/filechooserdialog_saveextras.h>
 #include <glom/utils_ui.h>
 #include <gtkmm/alignment.h>
diff --git a/glom/utility_widgets/filechooserdialog_saveextras.h b/glom/utility_widgets/filechooserdialog_saveextras.h
index 17c2c05..12ae42b 100644
--- a/glom/utility_widgets/filechooserdialog_saveextras.h
+++ b/glom/utility_widgets/filechooserdialog_saveextras.h
@@ -21,7 +21,8 @@
 #ifndef GLOM_UTILITY_WIDGETS_FILECHOOSERDIALOG_SAVEEXTRAS_H
 #define GLOM_UTILITY_WIDGETS_FILECHOOSERDIALOG_SAVEEXTRAS_H
 
-#include <libglom/libglom_config.h> // For GLOM_ENABLE_CLIENT_ONLY, GLOM_ENABLE_SQLITE
+#include "config.h" //For GLOM_ENABLE_SQLITE
+#include <libglom/libglom_config.h> // For GLOM_ENABLE_CLIENT_ONLY,
 
 #include <libglom/document/document.h>
 



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