aboutsummaryrefslogtreecommitdiff
path: root/src/protocol.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-07-03 00:28:59 +0000
committerMike Buland <eichlan@xagasoft.com>2007-07-03 00:28:59 +0000
commitac517a2b7625e0aa0862679e961c6349f859ea3b (patch)
treee3e27a6b9bd5e2be6150088495c91fc91786ad9d /src/protocol.h
parentf8d4301e9fa4f3709258505941e37fab2eadadc6 (diff)
parentbd865cee5f89116c1f054cd0e5c275e97c2d0a9b (diff)
downloadlibbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.gz
libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.bz2
libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.xz
libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.zip
The reorg is being put in trunk, I think it's ready. Now we just get to find
out how many applications won't work anymore :)
Diffstat (limited to 'src/protocol.h')
-rw-r--r--src/protocol.h67
1 files changed, 16 insertions, 51 deletions
diff --git a/src/protocol.h b/src/protocol.h
index 09e1c98..bca337f 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -1,62 +1,27 @@
1#ifndef PROTOCOL_H 1#ifndef BU_PROTOCOL_H
2#define PROTOCOL_H 2#define BU_PROTOCOL_H
3 3
4#include "connection.h" 4#include <stdint.h>
5 5
6/** This is the template for a class that handles specialized input and output 6namespace Bu
7 * to connections of different types with different protocols.
8 *@author Mike Buland
9 */
10class Protocol
11{ 7{
12public: 8 class Client;
13 /** Constructor */
14 Protocol();
15 /** Deconstructor */
16 virtual ~Protocol();
17 9
18 /** 10 /**
19 * Function is called every time there is new data on the line. This is 11 *
20 * called directly from the Connection class to process data. This is not
21 * called whever there is pending data on the input, but every time new data
22 * is added to the input buffer.
23 *@returns True if processing went alright, false if something went wrong,
24 * I suppose. In truth this value is thrown away right now.
25 *@todo Either make a return value of false mean something, or make these
26 * void.
27 */ 12 */
28 virtual bool onNewData()=0; 13 class Protocol
14 {
15 public:
16 Protocol();
17 virtual ~Protocol();
29 18
30 /** 19 virtual void onNewConnection( Bu::Client *pClient )=0;
31 * Function is called when there is a new connection. This should only 20 virtual void onNewData( Bu::Client *pClient )=0;
32 * happen once per Protocol object, but gives each protocol object a
33 * chance to perform connection handshaking and initialization at a point
34 * where they know that they have a handle to an active Connection.
35 *@returns See onNewData
36 */
37 virtual bool onNewConnection()=0;
38
39 virtual void onNewClientConnection(){};
40 21
41 virtual void poll(){}; 22 private:
42
43 /**
44 * Sets the Protocol's Connection object. This is rather important, and
45 * handled usually by the ConnectionManager.
46 *@param pNewConnection The Connection object that this protocol will use to
47 * deal with the outside world.
48 */
49 void setConnection( class Connection *pNewConnection );
50
51 /**
52 * Get a pointer to this object's Connection object, or NULL if one was
53 * never set. If used with the ConnectionManager that should never happen.
54 *@returns A pointer to the active Connection.
55 */
56 Connection *getConnection();
57 23
58private: 24 };
59 class Connection *pConnection; /**< The pointer to the Connection. */ 25}
60};
61 26
62#endif 27#endif