Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes
rail::spatial_temporal_learning::worldlib::remote::SqlClient Class Reference

The main MySQL client connection. More...

#include <SqlClient.h>

Inheritance diagram for rail::spatial_temporal_learning::worldlib::remote::SqlClient:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual bool connect ()
 Create a connection to the database.
bool connected () const
 Check if there is a connection to the database.
virtual void disconnect ()
 Closes a connection to the database.
const std::string & getDatabase () const
 Database value accessor.
const std::string & getPassword () const
 Password value accessor.
const std::string & getUser () const
 User value accessor.
 SqlClient (const SqlClient &client)
 Create a new SqlClient.
 SqlClient (const std::string &host, const uint16_t port, const std::string &user, const std::string &password, const std::string &database)
 Create a new SqlClient.
virtual ~SqlClient ()
 Cleans up a SqlClient.

Static Public Attributes

static const unsigned int DEFAULT_PORT = 3306

Protected Member Functions

void printSqlError () const
 Print the latest SQL error to ROS_ERROR.
MYSQL_RES * query (const std::string &query) const
 Execute a SQL query in the database.

Private Attributes

bool connected_
MYSQL * connection_
const std::string database_
const std::string password_
const std::string user_

Detailed Description

The main MySQL client connection.

The worldlib SQL client can communicate with a MySQL database.

Definition at line 35 of file SqlClient.h.


Constructor & Destructor Documentation

SqlClient::SqlClient ( const SqlClient client)

Create a new SqlClient.

Creates a new SqlClient by copying the values from the given SqlClient. A new connection is made if one exists.

Parameters:
clientThe SqlClient to copy.

Definition at line 20 of file SqlClient.cpp.

rail::spatial_temporal_learning::worldlib::remote::SqlClient::SqlClient ( const std::string &  host,
const uint16_t  port,
const std::string &  user,
const std::string &  password,
const std::string &  database 
)

Create a new SqlClient.

Creates a new SqlClient with the given connection information. A connection is not made by default.

Parameters:
hostThe host of the database.
portThe host port of the database.
userThe user of the database.
passwordThe password for the user of the database.
databaseThe database name.
SqlClient::~SqlClient ( ) [virtual]

Cleans up a SqlClient.

Cleans up any connections used by the SqlClient.

Definition at line 40 of file SqlClient.cpp.


Member Function Documentation

bool SqlClient::connect ( ) [virtual]

Create a connection to the database.

Attempts to create a connection to the database. A flag is returned to indicate the success.

Returns:
True if a connection has been successfully made.

Reimplemented in rail::spatial_temporal_learning::worldlib::remote::SpatialWorldClient.

Definition at line 66 of file SqlClient.cpp.

bool SqlClient::connected ( ) const

Check if there is a connection to the database.

A boolean check to see if a connection exists to the database.

Returns:
True if a connection has been made.

Definition at line 61 of file SqlClient.cpp.

void SqlClient::disconnect ( ) [virtual]

Closes a connection to the database.

Attempts to close a connection to the database. No effect is seen if there is no current connection.

Definition at line 83 of file SqlClient.cpp.

const string & SqlClient::getDatabase ( ) const

Database value accessor.

Get the database value of this SqlClient.

Returns:
The database value.

Definition at line 56 of file SqlClient.cpp.

const string & SqlClient::getPassword ( ) const

Password value accessor.

Get the password value of this SqlClient.

Returns:
The password value.

Definition at line 51 of file SqlClient.cpp.

const string & SqlClient::getUser ( ) const

User value accessor.

Get the user value of this SqlClient.

Returns:
The user value.

Definition at line 46 of file SqlClient.cpp.

void SqlClient::printSqlError ( ) const [protected]

Print the latest SQL error to ROS_ERROR.

Prints the latest SQL error message to the ROS error stream.

Definition at line 118 of file SqlClient.cpp.

MYSQL_RES * SqlClient::query ( const std::string &  query) const [protected]

Execute a SQL query in the database.

Attempt to run a SQL query in the database and return the result. If no connection is made or an error occurred, NULL is returned. It is the job of the caller to cleanup and returned pointer via mysql_free_result.

Parameters:
queryThe SQL query to run.
Returns:
The SQL result or NULL if an error occurred.

Definition at line 97 of file SqlClient.cpp.


Member Data Documentation

Connection flag

Definition at line 146 of file SqlClient.h.

The main database connection client.

Definition at line 148 of file SqlClient.h.

Definition at line 144 of file SqlClient.h.

The default MySQL port.

Reimplemented from rail::spatial_temporal_learning::worldlib::remote::Client.

Definition at line 39 of file SqlClient.h.

Definition at line 144 of file SqlClient.h.

Database connection information.

Definition at line 144 of file SqlClient.h.


The documentation for this class was generated from the following files:


worldlib
Author(s): Russell Toris
autogenerated on Fri Feb 12 2016 00:24:19