#include <kgameio.h>
Inheritance diagram for KGameProcessIO:


Signals | |
| void | signalProcessQuery (QDataStream &stream, KGameProcessIO *me) |
| A computer query message is received. | |
| void | signalIOAdded (KGameIO *game, QDataStream &stream, KPlayer *p, bool *send) |
| Signal generated when the computer player is added. | |
Public Member Functions | |
| KGameProcessIO (const QString &name) | |
| Creates a computer player via a separate process. | |
| virtual | ~KGameProcessIO () |
| Deletes the process input devices. | |
| int | rtti () const |
| The idendification of the IO. | |
| void | sendMessage (QDataStream &stream, int msgid, Q_UINT32 receiver, Q_UINT32 sender) |
| Send a message to the process. | |
| void | sendSystemMessage (QDataStream &stream, int msgid, Q_UINT32 receiver, Q_UINT32 sender) |
| Send a system message to the process. | |
| void | initIO (KPlayer *p) |
| Init this device by setting the player and e.g. | |
| virtual void | notifyTurn (bool turn) |
| Notifies the IO device that the player's setTurn had been called Called by KPlayer. | |
Protected Slots | |
| void | receivedMessage (const QByteArray &receiveBuffer) |
| Internal message handler to receive data from the process. | |
Protected Member Functions | |
| void | sendAllMessages (QDataStream &stream, int msgid, Q_UINT32 receiver, Q_UINT32 sender, bool usermsg) |
| Internal ~ombined function for all message handling. | |
Classes | |
| class | KGameProcessIOPrivate |
It is used to create a computer player via a separate process and communicate transparetly with it. Its counterpart is the KGameProcess class which needs to be used by the computer player. See its documentation for the definition of the computer player.
Definition at line 323 of file kgameio.h.
|
|
Creates a computer player via a separate process. The process name is given as fully qualified filename. Example: KGameProcessIO *input; input=new KGameProcessIO(executable_file); connect(input,SIGNAL(signalPrepareTurn(QDataStream &,bool,KGameIO *,bool *)), this,SLOT(slotPrepareTurn(QDataStream &,bool,KGameIO *,bool *))); connect(input,SIGNAL(signalProcessQuery(QDataStream &,KGameProcessIO *)), this,SLOT(slotProcessQuery(QDataStream &,KGameProcessIO *)));
Definition at line 252 of file kgameio.cpp. References KGameProcessIO::KGameProcessIOPrivate::mProcessIO, and receivedMessage(). |
|
|
Deletes the process input devices.
Definition at line 278 of file kgameio.cpp. References KGameProcessIO::KGameProcessIOPrivate::mProcessIO, KGameIO::player(), and KPlayer::removeGameIO(). Here is the call graph for this function: ![]() |
|
|
Init this device by setting the player and e.g. sending an init message to the device. Calling this function will emit the IOAdded signal on which you can react and initilise the computer player. This function is called automatically when adding the IO to a player. Reimplemented from KGameIO. Definition at line 299 of file kgameio.cpp. References KPlayer::id(), KGameMessage::IdIOAdded, KGameIO::initIO(), sendSystemMessage(), signalIOAdded(), and KPlayer::userId(). Here is the call graph for this function: ![]() |
|
|
Notifies the IO device that the player's setTurn had been called Called by KPlayer. You can react on the signalPrepareTurn to prepare a message for the process, i.e. either update it on the changes made to the game since the last turn or the initIO has been called or transmit your gamestatus now.
Reimplemented from KGameIO. Definition at line 321 of file kgameio.cpp. References KPlayer::id(), KGameMessage::IdTurn, KGameIO::player(), sendSystemMessage(), and KGameIO::signalPrepareTurn(). Here is the call graph for this function: ![]() |
|
|
Internal message handler to receive data from the process.
Definition at line 381 of file kgameio.cpp. References KGameMessage::extractHeader(), KPlayer::forwardMessage(), KPlayer::id(), KGameMessage::IdPlayerInput, KGameMessage::IdProcessQuery, KGameIO::player(), KGameIO::sendInput(), and signalProcessQuery(). Referenced by KGameProcessIO(). |
|
|
The idendification of the IO.
Implements KGameIO. Definition at line 294 of file kgameio.cpp. References KGameIO::ProcessIO. |
|
||||||||||||||||||||||||
|
Internal ~ombined function for all message handling.
Definition at line 351 of file kgameio.cpp. References KGameMessage::createHeader(), KGameMessage::IdUser, KGameProcessIO::KGameProcessIOPrivate::mProcessIO, and KMessageProcess::send(). Referenced by sendMessage(), and sendSystemMessage(). Here is the call graph for this function: ![]() |
|
||||||||||||||||||||
|
Send a message to the process. This is analogous to the sendMessage commands of KGame. It will result in a signal of the computer player on which you can react in the process player.
Definition at line 346 of file kgameio.cpp. References sendAllMessages(). Here is the call graph for this function: ![]() |
|
||||||||||||||||||||
|
Send a system message to the process. This is analogous to the sendMessage commands of KGame. It will result in a signal of the computer player on which you can react in the process player.
Definition at line 341 of file kgameio.cpp. References sendAllMessages(). Referenced by initIO(), and notifyTurn(). Here is the call graph for this function: ![]() |
|
||||||||||||||||||||
|
Signal generated when the computer player is added. You can use this to communicated with the process and e.g. send initialisation information to the process.
Referenced by initIO(). |
|
||||||||||||
|
A computer query message is received. This is a 'dummy' message sent by the process if it needs to communicate with us. It is not forwarded over the network. Reacting to this message allows you to 'answer' questions of the process, e.g. sending addition data which the process needs to calculate a move. Example: void GameWindow::slotProcessQuery(QDataStream &stream,KGameProcessIO *reply) { int no; stream >> no; // We assume the process sends us an integer question numner if (no==1) // but YOU have to do this in the process player { QByteArray buffer; QDataStream out(buffer,IO_WriteOnly); reply->sendSystemMessage(out,4242,0,0); // lets reply something... } } Referenced by receivedMessage(). |
1.4.6