ZG  "1.00
 All Classes Namespaces Files Functions Variables Enumerator Friends Macros Pages
Public Member Functions | List of all members
ZGStdinSession Class Reference

This is a utility class that knows how to read from the process's stdin and hand any received text commands over to the TextCommandReceived() method of the ITextCommandReceiver that is passed to its constructor. More...

#include <ZGStdinSession.h>

Inheritance diagram for ZGStdinSession:
Inheritance graph
[legend]

Public Member Functions

 ZGStdinSession (ITextCommandReceiver &target, bool endServerOnClose)
 Constructor. More...
 
virtual ConstSocketRef CreateDefaultSocket ()
 Overridden to return an invalid socket. More...
 
virtual DataIORef CreateDataIO (const ConstSocketRef &)
 Overridden to create and return a StdinDataIO object. More...
 
virtual bool ClientConnectionClosed ()
 Overridden to quit the ReflectServer event-loop when stdin is closed (if that behavior was specified in our constructor) More...
 
virtual bool IsReadyForInput () const
 Returns true iff our (target)'s IsReadyForInput() method returns true. More...
 
virtual AbstractMessageIOGatewayRef CreateGateway ()
 Overridden to create and return a PlainTextMessageIOGateway, since stdin input will be in the form of human-readable ASCII text. More...
 
virtual void MessageReceivedFromGateway (const MessageRef &msg, void *ptr)
 Overridden to handle incoming text from the PlainTextMessageIOGateway. More...
 
virtual const char * GetTypeName () const
 Implemented to return "ZGStdin". More...
 
bool IsEndServerOnClose () const
 Returns true iff we will call EndServer() if stdin is closed. More...
 
void SetEndServerOnClose (bool esoc)
 Sets whether or not we should call EndServer when stdin is closed. More...
 
const ITextCommandReceiverGetTextCommandReceiver () const
 Returns the ITextCommandReceiver object that was passed into our ctor. More...
 
ITextCommandReceiverGetTextCommandReceiver ()
 Returns the ITextCommandReceiver object that was passed into our ctor. More...
 
bool EndServerRequested () const
 Returns true iff this object called EndServer() already. More...
 

Detailed Description

This is a utility class that knows how to read from the process's stdin and hand any received text commands over to the TextCommandReceived() method of the ITextCommandReceiver that is passed to its constructor.

(The ITextCommandReceiver would typically be your ZGPeerSession object, but it's possible to use this class with any ITextCommandReceiver-derived object as its target.

Definition at line 52 of file ZGStdinSession.h.

Constructor & Destructor Documentation

ZGStdinSession ( ITextCommandReceiver target,
bool  endServerOnClose 
)

Constructor.

Parameters
targetThe object to call TextCommandReceived() on when a line of text is received from stdin
endServerOnCloseif true, we'll call EndServer() when stdin is closed, to cause this process to exit.

Member Function Documentation

virtual bool ClientConnectionClosed ( )
virtual

Overridden to quit the ReflectServer event-loop when stdin is closed (if that behavior was specified in our constructor)

virtual DataIORef CreateDataIO ( const ConstSocketRef &  )
virtual

Overridden to create and return a StdinDataIO object.

virtual ConstSocketRef CreateDefaultSocket ( )
inlinevirtual

Overridden to return an invalid socket.

We'll handle the socket-creation ourself, inside CreateDataIO()

Definition at line 62 of file ZGStdinSession.h.

virtual AbstractMessageIOGatewayRef CreateGateway ( )
virtual

Overridden to create and return a PlainTextMessageIOGateway, since stdin input will be in the form of human-readable ASCII text.

bool EndServerRequested ( ) const
inline

Returns true iff this object called EndServer() already.

Definition at line 98 of file ZGStdinSession.h.

const ITextCommandReceiver& GetTextCommandReceiver ( ) const
inline

Returns the ITextCommandReceiver object that was passed into our ctor.

Definition at line 92 of file ZGStdinSession.h.

ITextCommandReceiver& GetTextCommandReceiver ( )
inline

Returns the ITextCommandReceiver object that was passed into our ctor.

Definition at line 95 of file ZGStdinSession.h.

virtual const char* GetTypeName ( ) const
inlinevirtual

Implemented to return "ZGStdin".

Definition at line 83 of file ZGStdinSession.h.

bool IsEndServerOnClose ( ) const
inline

Returns true iff we will call EndServer() if stdin is closed.

Definition at line 86 of file ZGStdinSession.h.

virtual bool IsReadyForInput ( ) const
virtual

Returns true iff our (target)'s IsReadyForInput() method returns true.

virtual void MessageReceivedFromGateway ( const MessageRef &  msg,
void *  ptr 
)
virtual

Overridden to handle incoming text from the PlainTextMessageIOGateway.

Parameters
msgThe incoming MessageRef containing text strings to process
ptrUnused for now
void SetEndServerOnClose ( bool  esoc)
inline

Sets whether or not we should call EndServer when stdin is closed.

Definition at line 89 of file ZGStdinSession.h.


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