Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

VTQL::Connect Class Reference

Provides basic stuff for connections to a VTQLserver. More...

#include <vtql_base.h>

Inheritance diagram for VTQL::Connect:

VTQL::Event_generic VTQL::Query_generic List of all members.

Callback Interface

A CModul adds itself to this list and hopes to get a callback by the Process(bool) method.

typedef thread::CallBack<
std::pair< int, std::string > > 
CallB
 we use a pair of int and std::string for a callback.

CallB cb
 the callback structure is public.


Public Methods

virtual ~Connect ()
 Connect (const Connect &)
 Connect (const std::string &file_name)
 Open a connection to a server. More...

 Connect (const sock::Socket_basic &file_descriptor)
 Open a connection to a server (advanced). More...

virtual Connect & operator<< (const std::string &line)
 Send a line to server. More...

virtual bool Process (bool block)=0
 Read form server and handle the lines read. More...


Protected Methods

size_t InpLineC ()
 \brief Get the number of input lines in buffer.

std::string FetchLine ()
 get a line (without newline) from read buffer. More...

void Poll (bool block)
 Flushes i/o buffers. More...


Detailed Description

Provides basic stuff for connections to a VTQLserver.

Usually you will not use this abstract class, but higher level ones. You can simpliy connect to the server and send lines to. There are tools to read lines and the idea is to call callback classes on on read lines. The method Process(bool,bool) that is intended to read and call back is pure.


Constructor & Destructor Documentation

VTQL::Connect::Connect const Connect &   
 

Warning:
The copy constructor is not implemented.

VTQL::Connect::Connect const std::string &    file_name
 

Open a connection to a server.

Parameters:
file_name  File name of a socket of VTQLserver.

VTQL::Connect::Connect const sock::Socket_basic   file_descriptor
 

Open a connection to a server (advanced).

If you have an file descriptor and it is connected to a server, you can use this constructor.

Parameters:
file_descriptor  A file descriptor that is connected to a VTQLserver.
See also:
sock::Socket_basic::Socket_basic(int), sock::Socket_basic::operator int()


Member Function Documentation

virtual Connect& VTQL::Connect::operator<< const std::string &    line [virtual]
 

Send a line to server.

The input string+newline is added to the output queue. Send this queue with the Poll(bool) method to the server.

Parameters:
line  The line, that should be sent.
Returns:
The calling instance itself.

virtual bool VTQL::Connect::Process bool    block [pure virtual]
 

Read form server and handle the lines read.

This method gets called by CModul::Wait(bool) and should read all data, that is in the input queue, i.e. until InpLineC() is 0. The CModul expects this method to call the callback classes with the data just read. It must not contain a loop to read until the command output had finished, but its return value should indicate a CModul, that it can return with true from the CModul::Wait(bool) method. It is expectet, that this function calls the Poll(bool) method.

Parameters:
block  true: blocking ; false: nonblocking i/o \retrun true if command output has finished, false otherwise.
See also:
CModul::Wait(bool)

Implemented in VTQL::Event_generic.

std::string VTQL::Connect::FetchLine   [protected]
 

get a line (without newline) from read buffer.

You can get the number of input lines with InpLineC. Fill the buffer with Poll(bool).

void VTQL::Connect::Poll bool    block [protected]
 

Flushes i/o buffers.

Tries to write and read a bit from/to buffers (it does not contain a loop).

Parameters:
b  true: waiting for a chance to read and/or write


The documentation for this class was generated from the following file:
Generated on Sun Apr 14 17:37:04 2002 for libvtql by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002