Dependents:   MySQLClientExample MySQLClientExampleMA

Revision:
5:91c24a06d12c
Parent:
0:403b85869e53
--- a/LPC2368/services/mysql/MySQLClient.h	Mon Jul 19 16:22:25 2010 +0000
+++ b/LPC2368/services/mysql/MySQLClient.h	Thu Aug 05 15:16:36 2010 +0000
@@ -21,10 +21,15 @@
 THE SOFTWARE.
 */
 
+/** \file
+MySQL Client header file
+*/
+
 #ifndef MYSQL_CLIENT_H
 #define MYSQL_CLIENT_H
 
-#include "if/net/net.h"
+#include "core/net.h"
+#include "core/netservice.h"
 #include "api/TCPSocket.h"
 #include "api/DNSRequest.h"
 #include "mbed.h"
@@ -37,28 +42,55 @@
 
 typedef unsigned char byte;
 
+///MySQL client results
 enum MySQLResult
 {
-  MYSQL_OK,
-  MYSQL_PROCESSING,
-  MYSQL_PRTCL,
-  MYSQL_SETUP, //Not properly configured
-  MYSQL_DNS, //Could not resolve name
-  MYSQL_AUTHFAILED, //Auth failure
-  MYSQL_READY, //Ready to send commands
-  MYSQL_SQL, //SQL Error
-  MYSQL_TIMEOUT, //Connection timeout
-  MYSQL_CONN //Connection error
+  MYSQL_OK, ///<Success
+  MYSQL_PROCESSING, ///<Processing
+  MYSQL_PRTCL, ///<Protocol error
+  MYSQL_SETUP, ///<Not properly configured
+  MYSQL_DNS, ///<Could not resolve name
+  MYSQL_AUTHFAILED, ///<Auth failure
+  MYSQL_READY, ///<Ready to send commands
+  MYSQL_SQL, ///<SQL Error
+  MYSQL_TIMEOUT, ///<Connection timeout
+  MYSQL_CONN ///<Connection error
 };
 
+///A MySQL Client
+/**
+This MySQL client implements a limited subset of the MySQL internal client/server protocol (including authentication), for server versions 4.1 and newer.
+*/
 class MySQLClient : protected NetService
 {
 public:
+  ///Instantiates the MySQL client
   MySQLClient();
   virtual ~MySQLClient();
   
   //High Level setup functions
+  
+  ///Opens a connection to a server
+  /**
+  Opens a connection to the server host using the provided username, password passowrd and selecting database
+  On completion of this call (and any further one), the callback set in parameter is fired with the result of that command in parameter
+  @param host : server
+  @param user : username
+  @param db : database to use
+  @param pMethod : callback to call on each request completion
+  */
   MySQLResult open(Host& host, const string& user, const string& password, const string& db, void (*pMethod)(MySQLResult)); //Non blocking
+  
+  ///Opens a connection to a server
+  /**
+  Opens a connection to the server host using the provided username, password passowrd and selecting database
+  On completion of this call (and any further one), the callback set in parameter is fired with the result of that command in parameter
+  @param host : server
+  @param user : username
+  @param db : database to use
+  @param pItem : callback's class instance
+  @param pMethod : callback's method to call on each request completion
+  */
   template<class T> 
   MySQLResult open(Host& host, const string& user, const string& password, const string& db, T* pItem, void (T::*pMethod)(MySQLResult)) //Non blocking
   {
@@ -67,8 +99,17 @@
     return MYSQL_PROCESSING;
   }
   
+  
+  ///Executes an SQL command
+  /**
+  Executes an SQL request on the SQL server
+  This is a non-blocking function
+  On completion, the callback set in the open function is fired with the result of the command in parameter
+  @param sqlCommand SQL request to execute
+  */
   MySQLResult sql(string& sqlCommand);
   
+  ///Closes the connection to the server
   MySQLResult exit();
       
   void setOnResult( void (*pMethod)(MySQLResult) );
@@ -81,6 +122,10 @@
     m_pCbMeth = (void (CDummy::*)(MySQLResult)) pMethod;
   }
   
+  ///Setups timeout
+  /**
+  @param ms : time of connection inactivity in ms after which the request should timeout
+  */
   void setTimeout(int ms);
   
   virtual void poll(); //Called by NetServices