KGameProcessIO

Search for usage in LXR

#include <KGame/KGameIO>

Inheritance diagram for KGameProcessIO:

Signals

void signalIOAdded (KGameIO *game, QDataStream &stream, KPlayer *p, bool *send)
 
void signalProcessQuery (QDataStream &stream, KGameProcessIO *me)
 
void signalReceivedStderr (const QString &msg)
 
- Signals inherited from KGameIO
void signalPrepareTurn (QDataStream &stream, bool turn, KGameIO *io, bool *send)
 

Public Member Functions

 KGameProcessIO (const QString &name)
 
 ~KGameProcessIO () override
 
void initIO (KPlayer *p) override
 
void notifyTurn (bool turn) override
 
int rtti () const override
 
void sendMessage (QDataStream &stream, int msgid, quint32 receiver, quint32 sender)
 
void sendSystemMessage (QDataStream &stream, int msgid, quint32 receiver, quint32 sender)
 
- Public Member Functions inherited from KGameIO
 KGameIO ()
 
 KGameIO (KPlayer *)
 
void Debug ()
 
KGamegame () const
 
KPlayerplayer () const
 
bool sendInput (QDataStream &stream, bool transmit=true, quint32 sender=0)
 
void setPlayer (KPlayer *p)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Slots

void receivedMessage (const QByteArray &receiveBuffer)
 

Protected Member Functions

void sendAllMessages (QDataStream &stream, int msgid, quint32 receiver, quint32 sender, bool usermsg)
 
- Protected Member Functions inherited from KGameIO
 KGameIO (KGameIOPrivate &dd, KPlayer *player=nullptr)
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Public Types inherited from KGameIO
enum  IOMode {
  GenericIO = 1 , KeyIO = 2 , MouseIO = 4 , ProcessIO = 8 ,
  ComputerIO = 16
}
 
- Public Types inherited from QObject
typedef  QObjectList
 
- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Detailed Description

The KGameProcessIO class.

It is used to create a computer player via a separate process and communicate transparently 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 357 of file kgameio.h.

Constructor & Destructor Documentation

◆ KGameProcessIO()

KGameProcessIO::KGameProcessIO ( const QString & name)
explicit

Creates a computer player via a separate process.

The process name is given as fully qualified filename. Example:

input=new KGameProcessIO(executable_file);
connect(input,SIGNAL(signalPrepareTurn(QDataStream &,bool,KGameIO *,bool *)),
this,SLOT(slotPrepareTurn(QDataStream &,bool,KGameIO *,bool *)));
this,SLOT(slotProcessQuery(QDataStream &,KGameProcessIO *)));
Base class for IO devices for games.
Definition kgameio.h:57
void signalPrepareTurn(QDataStream &stream, bool turn, KGameIO *io, bool *send)
Signal generated when KPlayer::myTurn changes.
The KGameProcessIO class.
Definition kgameio.h:358
void signalProcessQuery(QDataStream &stream, KGameProcessIO *me)
A computer query message is received.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
Parameters
namethe filename of the process to start

Definition at line 260 of file kgameio.cpp.

◆ ~KGameProcessIO()

KGameProcessIO::~KGameProcessIO ( )
override

Deletes the process input devices.

Definition at line 288 of file kgameio.cpp.

Member Function Documentation

◆ initIO()

void KGameProcessIO::initIO ( KPlayer * p)
overridevirtual

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 308 of file kgameio.cpp.

◆ notifyTurn()

void KGameProcessIO::notifyTurn ( bool turn)
overridevirtual

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.

Parameters
turnis true/false

Reimplemented from KGameIO.

Definition at line 328 of file kgameio.cpp.

◆ receivedMessage

void KGameProcessIO::receivedMessage ( const QByteArray & receiveBuffer)
protectedslot

Internal message handler to receive data from the process.

Definition at line 387 of file kgameio.cpp.

◆ rtti()

int KGameProcessIO::rtti ( ) const
overridevirtual

The identification of the IO.

Returns
ProcessIO

Implements KGameIO.

Definition at line 303 of file kgameio.cpp.

◆ sendAllMessages()

void KGameProcessIO::sendAllMessages ( QDataStream & stream,
int msgid,
quint32 receiver,
quint32 sender,
bool usermsg )
protected

Internal combined function for all message handling.

Definition at line 356 of file kgameio.cpp.

◆ sendMessage()

void KGameProcessIO::sendMessage ( QDataStream & stream,
int msgid,
quint32 receiver,
quint32 sender )

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.

Parameters
stream- the actual data
msgid- the id of the message
receiver- not used
sender- who send the message

Definition at line 351 of file kgameio.cpp.

◆ sendSystemMessage()

void KGameProcessIO::sendSystemMessage ( QDataStream & stream,
int msgid,
quint32 receiver,
quint32 sender )

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.

Parameters
stream- the actual data
msgid- the id of the message
receiver- not used
sender- who send the message

Definition at line 346 of file kgameio.cpp.

◆ signalIOAdded

void KGameProcessIO::signalIOAdded ( KGameIO * game,
QDataStream & stream,
KPlayer * p,
bool * send )
signal

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.

Parameters
gamethe KGameIO object itself
streamthe stream into which the move will be written
pthe player itself
sendset this to false if no move should be generated

◆ signalProcessQuery

void KGameProcessIO::signalProcessQuery ( QDataStream & stream,
KGameProcessIO * me )
signal

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 number
if (no==1) // but YOU have to do this in the process player
{
QByteArray buffer;
reply->sendSystemMessage(out,4242,0,0); // lets reply something...
}
}
void sendSystemMessage(QDataStream &stream, int msgid, quint32 receiver, quint32 sender)
Send a system message to the process.
Definition kgameio.cpp:346

◆ signalReceivedStderr

void KGameProcessIO::signalReceivedStderr ( const QString & msg)
signal

Text is received by the process on STDERR.

This is usually a debug string.

Parameters
msgThe text

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:13:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.