#ifndef __TclDatabaseWrapper_h_ #define __TclDatabaseWrapper_h_ /* This is a wrapper around the DatabaseWithRetry and TclResultRef classes. * There are other ways to access MySql from TCL. I chose to create this * wrapper mostly to get the automatic retries. The logging and smart * database names are nice features, too. */ #include #include "../shared/DatabaseWithRetry.h" class TclDatabaseWrapper { private: DatabaseWithRetry _database; TclDatabaseWrapper(std::string const &serverName, std::string const &debugName); static int databaseCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); int databaseCmd(Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], int offset); static void deleteDatabaseCmd(ClientData clientData); static int resultCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int resultCmd(MysqlResultRef result, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], int offset); static void deleteResultCmd(ClientData clientData); public: // commandName is changed to be an absolute name. I.e. "my_database" might // become "::my_database" or "::my_namespace::my_database". static Tcl_Command createDatabaseCmd(Tcl_Interp *interp, std::string &commandName, std::string const &serverName, std::string debugName = ""); static Tcl_Command createDatabaseCmd(Tcl_Interp *interp, char const *commandName, std::string const &serverName, std::string const &debugName = "") { std::string temp = commandName; return createDatabaseCmd(interp, temp, serverName, debugName); } // Name is changed to be an absolute name. I.e. "my_result" might become // "::my_result" or "::my_namespace::my_result". static Tcl_Command createResultCmd(Tcl_Interp *interp, std::string &name, MysqlResultRef result); }; #endif