[libgdamm] ServerOperation: Move enums into the class.



commit fbbab1a1139266ea8486c49a67c0990c90cb868e
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Apr 26 22:21:21 2017 +0200

    ServerOperation: Move enums into the class.

 libgda/src/connection.hg       |    2 +-
 libgda/src/serveroperation.ccg |    3 +++
 libgda/src/serveroperation.hg  |   26 ++++++++++++++------------
 libgda/src/serverprovider.ccg  |    4 ++--
 libgda/src/serverprovider.hg   |    8 ++++----
 tools/m4/convert_libgdamm.m4   |    6 +++---
 6 files changed, 27 insertions(+), 22 deletions(-)
---
diff --git a/libgda/src/connection.hg b/libgda/src/connection.hg
index ac85874..88c3af8 100644
--- a/libgda/src/connection.hg
+++ b/libgda/src/connection.hg
@@ -290,7 +290,7 @@ public:
   #m4 _CONVERSION(`GSList*',`std::vector< Glib::RefPtr<Glib::Object> >',`$2(Glib::SListHandler< 
Glib::RefPtr<Glib::Object > >::slist_to_vector($3, Glib::OWNERSHIP_SHALLOW))')
   _WRAP_METHOD(std::vector< Glib::RefPtr<Glib::Object> > batch_execute(const Glib::RefPtr<Batch>& batch, 
const Glib::RefPtr<const Set>& params, StatementModelUsage model_usage), gda_connection_batch_execute, 
errthrow)
 
-  _WRAP_METHOD(Glib::RefPtr<ServerOperation> create_operation(ServerOperationType type, const 
Glib::RefPtr<const Set>& options), gda_connection_create_operation, errthrow)
+  _WRAP_METHOD(Glib::RefPtr<ServerOperation> create_operation(ServerOperation::Type type, const 
Glib::RefPtr<const Set>& options), gda_connection_create_operation, errthrow)
   _WRAP_METHOD(bool perform_operation(const Glib::RefPtr<ServerOperation>& op), 
gda_connection_perform_operation, errthrow)
 
   _WRAP_METHOD(Glib::RefPtr<ServerProvider> get_provider(), gda_connection_get_provider, refreturn)
diff --git a/libgda/src/serveroperation.ccg b/libgda/src/serveroperation.ccg
index 2c206f1..7062331 100644
--- a/libgda/src/serveroperation.ccg
+++ b/libgda/src/serveroperation.ccg
@@ -24,6 +24,9 @@
 #include <libgda/gda-enum-types.h>
 #include <libgdamm/connection.h>
 
+using Type = Gnome::Gda::ServerOperation::Type;
+using NodeType = Gnome::Gda::ServerOperation::NodeType;
+
 namespace Gnome
 {
 
diff --git a/libgda/src/serveroperation.hg b/libgda/src/serveroperation.hg
index 8b7774d..079651d 100644
--- a/libgda/src/serveroperation.hg
+++ b/libgda/src/serveroperation.hg
@@ -34,15 +34,11 @@ namespace Gnome
 namespace Gda
 {
 
+//_WRAP_ENUM(ClientSpecsType, GdaClientSpecsType)
 
 class Connection;
 class ServerProvider;
 
-//_WRAP_ENUM(ClientSpecsType, GdaClientSpecsType)
-_WRAP_ENUM(ServerOperationNodeType, GdaServerOperationNodeType, NO_GTYPE)
-_WRAP_ENUM(ServerOperationNodeStatus, GdaServerOperationNodeStatus, NO_GTYPE)
-_WRAP_ENUM(ServerOperationType, GdaServerOperationType, NO_GTYPE)
-
 typedef GdaServerOperationNode ServerOperationNode;
 
 /** @defgroup DDL Data definition (DDL) queries
@@ -50,10 +46,10 @@ typedef GdaServerOperationNode ServerOperationNode;
 
 /** Handles any DDL query in an abstract way.
  *
- * Basically this object is just a named data store: it can store named values, 
+ * Basically this object is just a named data store: it can store named values,
  * the values being organized hirarchically. A value can be read from its path
  * (similar to a Unix file path) using the get_value_at() method.
- * 
+ *
  * @ingroup DDL
  */
 class ServerOperation : public Glib::Object
@@ -61,10 +57,14 @@ class ServerOperation : public Glib::Object
   _CLASS_GOBJECT(ServerOperation, GdaServerOperation, GDA_SERVER_OPERATION, Glib::Object, GObject)
 
 public:
+  _WRAP_ENUM(NodeType, GdaServerOperationNodeType, NO_GTYPE)
+  _WRAP_ENUM(NodeStatus, GdaServerOperationNodeStatus, NO_GTYPE)
+  _WRAP_ENUM(Type, GdaServerOperationType, NO_GTYPE)
+
   // These are from gda-easy but they fit in here best
   static Glib::RefPtr<ServerOperation> prepare_create_database(const Glib::ustring& provider,
                                                                const Glib::ustring& db_name);
- 
+
   static Glib::RefPtr<ServerOperation> prepare_drop_database(const Glib::ustring& provider,
                                                              const Glib::ustring& db_name);
 
@@ -82,7 +82,9 @@ public:
   void set_value_at_as_value(const Glib::ustring& path_format, const Glib::ValueBase& value);
 
   //TODO: See http://bugzilla.gnome.org/show_bug.cgi?id=574742
-  _WRAP_METHOD(ServerOperationNodeType get_node_type(const Glib::ustring& path, ServerOperationNodeStatus& 
status) const, gda_server_operation_get_node_type)
+
+#m4 _CONVERSION(`NodeStatus&',`GdaServerOperationNodeStatus*', `(GdaServerOperationNodeStatus*)(&($3))')
+  _WRAP_METHOD(NodeType get_node_type(const Glib::ustring& path, NodeStatus& status) const, 
gda_server_operation_get_node_type)
   _WRAP_METHOD(guint get_sequence_size(const Glib::ustring& path) const, 
gda_server_operation_get_sequence_size)
   _WRAP_METHOD(guint get_sequence_max_size(const Glib::ustring& path) const, 
gda_server_operation_get_sequence_max_size)
   _WRAP_METHOD(guint get_sequence_min_size(const Glib::ustring& path) const, 
gda_server_operation_get_sequence_min_size)
@@ -97,11 +99,11 @@ public:
   //TODO: get_node_info => varargs
   _WRAP_METHOD(bool is_valid(const std::string& xml_file) const, gda_server_operation_is_valid, errthrow)
   _WRAP_METHOD(bool load_data_from_xml(xmlNodePtr node), gda_server_operation_load_data_from_xml, errthrow)
-  _WRAP_METHOD(xmlNodePtr save_data_to_xml(), gda_server_operation_save_data_to_xml, errthrow)  
+  _WRAP_METHOD(xmlNodePtr save_data_to_xml(), gda_server_operation_save_data_to_xml, errthrow)
   _WRAP_METHOD(Glib::ustring get_node_path_portion(const Glib::ustring& path) const, 
gda_server_operation_get_node_path_portion)
   _WRAP_METHOD(Glib::ustring get_node_parent(const Glib::ustring& path) const, 
gda_server_operation_get_node_parent)
-  _WRAP_METHOD(ServerOperationType get_op_type() const, gda_server_operation_get_op_type)
-  
+  _WRAP_METHOD(Type get_op_type() const, gda_server_operation_get_op_type)
+
   _WRAP_METHOD(bool del_item_from_sequence(const std::string& item_path), 
gda_server_operation_del_item_from_sequence)
   _WRAP_METHOD(guint add_item_to_sequence(const std::string& item_path), 
gda_server_operation_add_item_to_sequence)
   _WRAP_METHOD(std::vector<Glib::ustring> get_root_nodes() const, gda_server_operation_get_root_nodes)
diff --git a/libgda/src/serverprovider.ccg b/libgda/src/serverprovider.ccg
index c0113ac..d8491d9 100644
--- a/libgda/src/serverprovider.ccg
+++ b/libgda/src/serverprovider.ccg
@@ -57,7 +57,7 @@ Value ServerProvider::string_to_value(const Glib::RefPtr<Connection>& cnc,
   return retval;
 }
 
-Glib::RefPtr<ServerOperation> ServerProvider::create_operation(const Glib::RefPtr<Connection>& cnc, 
ServerOperationType type)
+Glib::RefPtr<ServerOperation> ServerProvider::create_operation(const Glib::RefPtr<Connection>& cnc, 
ServerOperation::Type type)
 {
   GError* gerror = 0;
   Glib::RefPtr<ServerOperation> retvalue = Glib::wrap(gda_server_provider_create_operation(gobj(), 
Glib::unwrap(cnc), ((GdaServerOperationType)(type)), 0, &(gerror)));
@@ -68,7 +68,7 @@ Glib::RefPtr<ServerOperation> ServerProvider::create_operation(const Glib::RefPt
   return retvalue;
 }
 
-bool ServerProvider::supports_operation(const Glib::RefPtr<Connection>& cnc, ServerOperationType type) const
+bool ServerProvider::supports_operation(const Glib::RefPtr<Connection>& cnc, ServerOperation::Type type) 
const
 {
   return gda_server_provider_supports_operation(const_cast<GdaServerProvider*>(gobj()), Glib::unwrap(cnc), 
((GdaServerOperationType)(type)), 0);
 }
diff --git a/libgda/src/serverprovider.hg b/libgda/src/serverprovider.hg
index dbeeb3b..193e8ca 100644
--- a/libgda/src/serverprovider.hg
+++ b/libgda/src/serverprovider.hg
@@ -63,12 +63,12 @@ public:
   _WRAP_METHOD(Glib::ustring get_server_version(const Glib::RefPtr<Connection>& cnc) const, 
gda_server_provider_get_server_version)
 
   //TODO: options may be NULL: Add a method overload.
-  _WRAP_METHOD(bool supports_operation(const Glib::RefPtr<Connection>& cnc, ServerOperationType type, const 
Glib::RefPtr<Set>& options) const, gda_server_provider_supports_operation)
+  _WRAP_METHOD(bool supports_operation(const Glib::RefPtr<Connection>& cnc, ServerOperation::Type type, 
const Glib::RefPtr<Set>& options) const, gda_server_provider_supports_operation)
 
-  bool supports_operation(const Glib::RefPtr<Connection>& cnc, ServerOperationType type) const;
+  bool supports_operation(const Glib::RefPtr<Connection>& cnc, ServerOperation::Type type) const;
 
 
-  _WRAP_METHOD(Glib::RefPtr<ServerOperation> create_operation(const Glib::RefPtr<Connection>& cnc, 
ServerOperationType type, const Glib::RefPtr<Set>& options), gda_server_provider_create_operation, errthrow)
+  _WRAP_METHOD(Glib::RefPtr<ServerOperation> create_operation(const Glib::RefPtr<Connection>& cnc, 
ServerOperation::Type type, const Glib::RefPtr<Set>& options), gda_server_provider_create_operation, errthrow)
   
   /** Creates a new Gda::ServerOperation object which can be modified in order to perform the @a type type of
    * action. The @a options can contain:
@@ -81,7 +81,7 @@ public:
    * @return A new Gda::ServerOperation object, or <tt>0</tt> in the provider does not support the @a type 
type
    * of operation or if an error occurred.
    */
-  Glib::RefPtr<ServerOperation> create_operation(const Glib::RefPtr<Connection>& cnc, ServerOperationType 
type);
+  Glib::RefPtr<ServerOperation> create_operation(const Glib::RefPtr<Connection>& cnc, ServerOperation::Type 
type);
 
 
   _WRAP_METHOD(Glib::ustring render_operation(const Glib::RefPtr<Connection>& cnc, const 
Glib::RefPtr<ServerOperation>& op), gda_server_provider_render_operation, errthrow)
diff --git a/tools/m4/convert_libgdamm.m4 b/tools/m4/convert_libgdamm.m4
index e37ae85..503f5b7 100644
--- a/tools/m4/convert_libgdamm.m4
+++ b/tools/m4/convert_libgdamm.m4
@@ -125,9 +125,9 @@ _CONV_GNOME_GDA_INCLASS_ENUM(ConnectionEvent,Code)
 _CONV_GNOME_GDA_INCLASS_ENUM(ConnectionEvent,Type)
 _CONV_GNOME_GDA_INCLASS_ENUM(Connection,MetaType)
 _CONV_GNOME_GDA_INCLASS_ENUM(Connection,Options)
-_CONV_ENUM(Gda,ServerOperationType)
-_CONV_ENUM(Gda,ServerOperationNodeType)
-_CONV_ENUM(Gda,ServerOperationNodeStatus)
+_CONV_GNOME_GDA_INCLASS_ENUM(ServerOperation,Type)
+_CONV_GNOME_GDA_INCLASS_ENUM(ServerOperation,NodeType)
+_CONV_GNOME_GDA_INCLASS_ENUM(ServerOperation,NodeStatus)
 _CONV_ENUM(Gda,ValueAttribute)
 _CONV_ENUM(Gda,StatementModelUsage)
 _CONV_GNOME_GDA_INCLASS_ENUM(SqlStatement,Type)


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