• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdegames
 

libtdegames

Signals | Public Member Functions | Protected Slots | Protected Member Functions | List of all members
KGameProcessIO Class Reference

#include <kgameio.h>

Inheritance diagram for KGameProcessIO:
KGameIO

Signals

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

Public Member Functions

 KGameProcessIO (const TQString &name)
 
virtual ~KGameProcessIO ()
 
int rtti () const
 
void sendMessage (TQDataStream &stream, int msgid, TQ_UINT32 receiver, TQ_UINT32 sender)
 
void sendSystemMessage (TQDataStream &stream, int msgid, TQ_UINT32 receiver, TQ_UINT32 sender)
 
void initIO (KPlayer *p)
 
virtual void notifyTurn (bool turn)
 
- Public Member Functions inherited from KGameIO
 KGameIO ()
 
 KGameIO (KPlayer *)
 
void Debug ()
 
KPlayer * player () const
 
KGame * game () const
 
void setPlayer (KPlayer *p)
 
bool sendInput (TQDataStream &stream, bool transmit=true, TQ_UINT32 sender=0)
 

Protected Slots

void receivedMessage (const TQByteArray &receiveBuffer)
 

Protected Member Functions

void sendAllMessages (TQDataStream &stream, int msgid, TQ_UINT32 receiver, TQ_UINT32 sender, bool usermsg)
 

Additional Inherited Members

- Public Types inherited from KGameIO
enum  IOMode {
  GenericIO =1, KeyIO =2, MouseIO =4, ProcessIO =8,
  ComputerIO =16
}
 

Detailed Description

The KGameProcessIO class.

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.

Author
Martin Heni marti.nosp@m.n@he.nosp@m.ni-on.nosp@m.line.nosp@m..de

Definition at line 326 of file kgameio.h.

Constructor & Destructor Documentation

◆ KGameProcessIO()

KGameProcessIO::KGameProcessIO ( const TQString &  name)

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,TQ_SIGNAL(signalPrepareTurn(TQDataStream &,bool,KGameIO *,bool *)),
this,TQ_SLOT(slotPrepareTurn(TQDataStream &,bool,KGameIO *,bool *)));
connect(input,TQ_SIGNAL(signalProcessQuery(TQDataStream &,KGameProcessIO *)),
this,TQ_SLOT(slotProcessQuery(TQDataStream &,KGameProcessIO *)));
Parameters
namethe filename of the process to start

Definition at line 252 of file kgameio.cpp.

◆ ~KGameProcessIO()

KGameProcessIO::~KGameProcessIO ( )
virtual

Deletes the process input devices.

Definition at line 278 of file kgameio.cpp.

Member Function Documentation

◆ initIO()

void KGameProcessIO::initIO ( KPlayer *  p)
virtual

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.

◆ notifyTurn()

void KGameProcessIO::notifyTurn ( bool  turn)
virtual

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

◆ receivedMessage

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

Internal message handler to receive data from the process.

Definition at line 381 of file kgameio.cpp.

◆ rtti()

int KGameProcessIO::rtti ( ) const
virtual

The idendification of the IO.

Returns
ProcessIO

Implements KGameIO.

Definition at line 294 of file kgameio.cpp.

◆ sendAllMessages()

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

Internal ~ombined function for all message handling.

Definition at line 351 of file kgameio.cpp.

◆ sendMessage()

void KGameProcessIO::sendMessage ( TQDataStream &  stream,
int  msgid,
TQ_UINT32  receiver,
TQ_UINT32  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 346 of file kgameio.cpp.

◆ sendSystemMessage()

void KGameProcessIO::sendSystemMessage ( TQDataStream &  stream,
int  msgid,
TQ_UINT32  receiver,
TQ_UINT32  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 341 of file kgameio.cpp.

◆ signalIOAdded

void KGameProcessIO::signalIOAdded ( KGameIO *  game,
TQDataStream &  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 ( TQDataStream &  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(TQDataStream &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
{
TQByteArray buffer;
TQDataStream out(buffer,IO_WriteOnly);
reply->sendSystemMessage(out,4242,0,0); // lets reply something...
}
}

The documentation for this class was generated from the following files:
  • kgameio.h
  • kgameio.cpp

libtdegames

Skip menu "libtdegames"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libtdegames

Skip menu "libtdegames"
  • libtdegames
Generated for libtdegames by doxygen 1.8.13
This website is maintained by Timothy Pearson.