Adding database interface and generic implementation for database stuff. The generic implementation acts just as placeholder and does nothing.
This commit is contained in:
@@ -126,6 +126,11 @@ HEADERS += \
|
||||
src/engine/network_engine/clienthand.h \
|
||||
src/engine/network_engine/clientplayer.h \
|
||||
src/engine/network_engine/clientbero.h \
|
||||
src/db/serverdbcallback.h \
|
||||
src/db/serverdbfactory.h \
|
||||
src/db/serverdbinterface.h \
|
||||
src/db/serverdbgeneric.h \
|
||||
src/db/serverdbfactorygeneric.h \
|
||||
src/gui/qttoolsinterface.h \
|
||||
src/gui/generic/serverguiwrapper.h
|
||||
|
||||
@@ -205,6 +210,11 @@ SOURCES += \
|
||||
src/net/common/uploadhelper.cpp \
|
||||
src/net/common/encodedpacket.cpp \
|
||||
src/net/common/internalchatcleanerpacket.cpp \
|
||||
src/db/common/serverdbcallback.cpp \
|
||||
src/db/common/serverdbfactory.cpp \
|
||||
src/db/common/serverdbinterface.cpp \
|
||||
src/db/common/serverdbgeneric.cpp \
|
||||
src/db/common/serverdbfactorygeneric.cpp \
|
||||
src/gui/generic/serverguiwrapper.cpp \
|
||||
src/gui/qttoolsinterface.cpp
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <db/serverdbcallback.h>
|
||||
|
||||
|
||||
ServerDBCallback::~ServerDBCallback()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <db/serverdbfactory.h>
|
||||
|
||||
|
||||
ServerDBFactory::~ServerDBFactory()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <db/serverdbfactorygeneric.h>
|
||||
#include <db/serverdbgeneric.h>
|
||||
|
||||
|
||||
ServerDBFactoryGeneric::ServerDBFactoryGeneric()
|
||||
{
|
||||
}
|
||||
|
||||
ServerDBFactoryGeneric::~ServerDBFactoryGeneric()
|
||||
{
|
||||
}
|
||||
|
||||
boost::shared_ptr<ServerDBInterface>
|
||||
ServerDBFactoryGeneric::CreateServerDBObject(ServerDBCallback &/*cb*/, boost::shared_ptr<boost::asio::io_service> /*ioService*/)
|
||||
{
|
||||
return boost::shared_ptr<ServerDBInterface>(new ServerDBGeneric);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <db/serverdbgeneric.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
ServerDBGeneric::ServerDBGeneric()
|
||||
{
|
||||
}
|
||||
|
||||
ServerDBGeneric::~ServerDBGeneric()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBGeneric::Init(const string &/*host*/, const string &/*user*/, const string &/*pwd*/,
|
||||
const string &/*database*/, const string &/*encryptionKey*/)
|
||||
{
|
||||
}
|
||||
|
||||
async_handle
|
||||
ServerDBGeneric::AsyncPlayerLogin(const string &/*playerName*/, const string &/*secretString*/)
|
||||
{
|
||||
return ASYNC_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
bool
|
||||
ServerDBGeneric::PlayerLogout(db_id /*playerId*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
async_handle
|
||||
ServerDBGeneric::AsyncCreateGame(const db_list &/*players*/)
|
||||
{
|
||||
return ASYNC_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
bool
|
||||
ServerDBGeneric::SetGamePlayerPlace(db_id /*gameId*/, db_id /*playerId*/, unsigned /*place*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
ServerDBGeneric::EndGame(db_id /*gameId*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <db/serverdbinterface.h>
|
||||
|
||||
|
||||
ServerDBInterface::~ServerDBInterface()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
/* Server database callback for async database operations. */
|
||||
|
||||
#ifndef _SERVERDBCALLBACK_H_
|
||||
#define _SERVERDBCALLBACK_H_
|
||||
|
||||
typedef unsigned db_id;
|
||||
typedef unsigned async_handle;
|
||||
#define DB_ID_INVALID 0
|
||||
#define ASYNC_HANDLE_INVALID 0
|
||||
|
||||
// Callback operations are posted using the io service,
|
||||
// and will therefore be executed in the io service thread.
|
||||
class ServerDBCallback
|
||||
{
|
||||
public:
|
||||
virtual ~ServerDBCallback();
|
||||
|
||||
virtual void PlayerLoginSuccess(async_handle login, db_id playerId) = 0;
|
||||
virtual void PlayerLoginFailed(async_handle login) = 0;
|
||||
|
||||
virtual void CreateGameSuccess(async_handle create, db_id gameId) = 0;
|
||||
virtual void CreateGameFailed(async_handle create) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
/* Server database factory. */
|
||||
|
||||
#ifndef _SERVERDBFACTORY_H_
|
||||
#define _SERVERDBFACTORY_H_
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <db/serverdbinterface.h>
|
||||
#include <db/serverdbcallback.h>
|
||||
|
||||
class ServerDBFactory
|
||||
{
|
||||
public:
|
||||
virtual ~ServerDBFactory();
|
||||
|
||||
virtual boost::shared_ptr<ServerDBInterface> CreateServerDBObject(
|
||||
ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
/* Server database factory for generic objects. */
|
||||
|
||||
#ifndef _SERVERDBFACTORYGENERIC_H_
|
||||
#define _SERVERDBFACTORYGENERIC_H_
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <db/serverdbinterface.h>
|
||||
#include <db/serverdbcallback.h>
|
||||
|
||||
class ServerDBFactoryGeneric
|
||||
{
|
||||
public:
|
||||
ServerDBFactoryGeneric();
|
||||
virtual ~ServerDBFactoryGeneric();
|
||||
|
||||
virtual boost::shared_ptr<ServerDBInterface> CreateServerDBObject(
|
||||
ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
/* Generic server database implementation. Basically does nothing. */
|
||||
|
||||
#ifndef _SERVERDBGENERIC_H_
|
||||
#define _SERVERDBGENERIC_H_
|
||||
|
||||
#include <db/serverdbinterface.h>
|
||||
|
||||
|
||||
class ServerDBGeneric : public ServerDBInterface
|
||||
{
|
||||
public:
|
||||
ServerDBGeneric();
|
||||
virtual ~ServerDBGeneric();
|
||||
|
||||
virtual void Init(const std::string &host, const std::string &user, const std::string &pwd,
|
||||
const std::string &database, const std::string &encryptionKey);
|
||||
|
||||
virtual async_handle AsyncPlayerLogin(const std::string &playerName, const std::string &secretString);
|
||||
virtual bool PlayerLogout(db_id playerId);
|
||||
|
||||
virtual async_handle AsyncCreateGame(const db_list &players);
|
||||
virtual bool SetGamePlayerPlace(db_id gameId, db_id playerId, unsigned place);
|
||||
virtual bool EndGame(db_id gameId);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,46 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
/* Server database interface. */
|
||||
|
||||
#ifndef _SERVERDBINTERFACE_H_
|
||||
#define _SERVERDBINTERFACE_H_
|
||||
|
||||
#include <db/serverdbcallback.h>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
typedef std::list<db_id> db_list;
|
||||
|
||||
class ServerDBInterface
|
||||
{
|
||||
public:
|
||||
virtual ~ServerDBInterface();
|
||||
|
||||
virtual void Init(const std::string &host, const std::string &user, const std::string &pwd,
|
||||
const std::string &database, const std::string &encryptionKey) = 0;
|
||||
|
||||
virtual async_handle AsyncPlayerLogin(const std::string &playerName, const std::string &secretString) = 0;
|
||||
virtual bool PlayerLogout(db_id playerId) = 0;
|
||||
|
||||
virtual async_handle AsyncCreateGame(const db_list &players) = 0;
|
||||
virtual bool SetGamePlayerPlace(db_id gameId, db_id playerId, unsigned place) = 0;
|
||||
virtual bool EndGame(db_id gameId) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user