blob: cd18e37fc5b3b3161579a8b2d3d27c0c9940a89b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#ifndef PROTOCOL_H
#define PROTOCOL_H
#include "connection.h"
/** This is the template for a class that handles specialized input and output
* to connections of different types with different protocols.
*@author Mike Buland
*/
class Protocol
{
public:
/** Constructor */
Protocol();
/** Deconstructor */
virtual ~Protocol();
/**
* Function is called every time there is new data on the line. This is
* called directly from the Connection class to process data. This is not
* called whever there is pending data on the input, but every time new data
* is added to the input buffer.
*@returns True if processing went alright, false if something went wrong,
* I suppose. In truth this value is thrown away right now.
*@todo Either make a return value of false mean something, or make these
* void.
*/
virtual bool onNewData()=0;
/**
* Function is called when there is a new connection. This should only
* happen once per Protocol object, but gives each protocol object a
* chance to perform connection handshaking and initialization at a point
* where they know that they have a handle to an active Connection.
*@returns See onNewData
*/
virtual bool onNewConnection()=0;
/**
* Sets the Protocol's Connection object. This is rather important, and
* handled usually by the ConnectionManager.
*@param pNewConnection The Connection object that this protocol will use to
* deal with the outside world.
*/
void setConnection( class Connection *pNewConnection );
/**
* Get a pointer to this object's Connection object, or NULL if one was
* never set. If used with the ConnectionManager that should never happen.
*@returns A pointer to the active Connection.
*/
Connection *getConnection();
private:
class Connection *pConnection; /**< The pointer to the Connection. */
};
#endif
|