Main | License | Installation | FAQ | Screenshots | Contact | Links | Sf.net | Freshmeat.net | KDE-Apps.org
Requirements | Design | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

MySQLDaemon Class Reference
[MySQL C++ Wrappers]

#include <mysqlDaemon.hpp>

Inheritance diagram for MySQLDaemon:

Inheritance graph
[legend]

Public Member Functions

 MySQLDaemon (const std::string &_datadir, const std::string &_socket) throw (Error)
virtual ~MySQLDaemon (void)
bool running (void)
const std::string getLog (void)

Static Public Member Functions

static std::string create (const std::string &_datadir, const std::string &_socket) throw (Error)

Protected Member Functions

void readPending (void)

Protected Attributes

int pipes [2]
pid_t pid
std::ostringstream log

Detailed Description

Definition at line 27 of file mysqlDaemon.hpp.


Constructor & Destructor Documentation

MySQLDaemon::MySQLDaemon ( const std::string &  _datadir,
const std::string &  _socket 
) throw (Error)

Constructor.

Parameters:
_datadir Directory of database server.
_socket The database-server should use this file-socket.

MySQLDaemon::~MySQLDaemon ( void   )  [virtual]

Definition at line 67 of file mysqlDaemon.cpp.

References pid.

00068 {
00069   kill( pid, SIGQUIT );// SIGTERM required on older systems.
00070   int status;
00071   waitpid( pid, &status, 0 );
00072 }


Member Function Documentation

bool MySQLDaemon::running ( void   ) 

Definition at line 74 of file mysqlDaemon.cpp.

References pid.

00075 {
00076   int status;
00077   return waitpid( pid, &status, WNOHANG ) == 0;
00078 }

const string MySQLDaemon::getLog ( void   ) 

Definition at line 80 of file mysqlDaemon.cpp.

References log, and readPending().

00081 {
00082   readPending();
00083   return log.str();
00084 }

static std::string MySQLDaemon::create ( const std::string &  _datadir,
const std::string &  _socket 
) throw (Error) [static]

Create database. This method calls 'mysql_install_db' to create the database directories.

Parameters:
_datadir Directory for database.
_socket Temporary socket required by some distributions.
Returns:
Output generated by mysql_install_db.

void MySQLDaemon::readPending ( void   )  [protected]

Definition at line 106 of file mysqlDaemon.cpp.

References log, and pipes.

Referenced by getLog().

00107 {
00108   int filedes = pipes[0];
00109 
00110   fd_set set;
00111   struct timeval timeout;
00112 
00113   FD_ZERO(&set);
00114   FD_SET (filedes, &set);
00115 
00116   timeout.tv_sec = 0;
00117   timeout.tv_usec = 0;
00118 
00119   while( true ) {
00120 
00121     int count;
00122     ioctl( filedes, FIONREAD, &count );
00123     if ( count == 0 )
00124       break;
00125     shared_array< char > buffer( new char[ count + 1 ] );
00126     read( filedes, buffer.get(), count );
00127     buffer[ count ] = 0;
00128     log << buffer.get();
00129 
00130   };
00131 }


Field Documentation

int MySQLDaemon::pipes[2] [protected]

Definition at line 52 of file mysqlDaemon.hpp.

Referenced by readPending().

pid_t MySQLDaemon::pid [protected]

Definition at line 54 of file mysqlDaemon.hpp.

Referenced by running(), and ~MySQLDaemon().

std::ostringstream MySQLDaemon::log [protected]

Definition at line 56 of file mysqlDaemon.hpp.

Referenced by getLog(), and readPending().


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

anymeal 0.30 - recipe management software - Make the most of your food! - © Jan Wedekind Sun Sep 14 16:01:29 2008 - GNU Free Documentation License