[asycxx-devel] SF.net SVN: asycxx:[29] trunk
Status: Alpha
Brought to you by:
joe_steeve
|
From: <joe...@us...> - 2009-04-08 07:33:03
|
Revision: 29
http://asycxx.svn.sourceforge.net/asycxx/?rev=29&view=rev
Author: joe_steeve
Date: 2009-04-08 07:32:54 +0000 (Wed, 08 Apr 2009)
Log Message:
-----------
converted class:Protocol to a simple base class
Since 'stream' protocols and 'datagram' protocols behave completely
differently, the class:Protocol now contains only the bare minimum.
From: Joe Steeve <js...@hi...>
Modified Paths:
--------------
trunk/include/asycxx/Protocol.h
trunk/src/Protocol.cxx
Modified: trunk/include/asycxx/Protocol.h
===================================================================
--- trunk/include/asycxx/Protocol.h 2009-04-08 07:32:11 UTC (rev 28)
+++ trunk/include/asycxx/Protocol.h 2009-04-08 07:32:54 UTC (rev 29)
@@ -17,37 +17,54 @@
#include "Error.h"
#include "Reactor.h"
#include "DataBuffer.h"
-#include "Transport.h"
-#include "Factory.h"
#define ASYCXX_DEFAULT_PROTOCOL_BUFSIZE 1024
-class Protocol
+namespace asycxx
{
-public:
- Protocol (Reactor *reactor, Factory *factory, Transport *transport);
- virtual ~Protocol ();
+ class ProtocolFactory;
- void BuildProtocol (void);
- /* Methods exposed for the 'transport' to send msgs to the
- Protocol */
- virtual void DataAvailable (DataBuffer *data);
- virtual void ConnectionLost (void);
- virtual void ReadTimeout (h_msecs_t excess_time);
- virtual void ReadError (void);
- virtual void WriteTimeout (h_msecs_t excess_time);
- virtual void WriteError (void);
-
-protected:
- Reactor *m_Reactor;
- Factory *m_Factory;
- Transport *m_Transport;
+ class Protocol
+ {
+ public:
+ Protocol (Reactor *reactor, ProtocolFactory *factory);
+ virtual ~Protocol () {}
- /* Interface that should be implemented by all protocol
- sub-classes */
- virtual Result InitProtocol (void);
-};
+ /**
+ * \brief Get the 'Reactor' that is being used
+ */
+ Reactor * getReactor (void) { return m_Reactor; }
+ /**
+ * \brief Get the 'Factory' that created this 'Protocol'
+ */
+ ProtocolFactory * getFactory (void) { return m_Factory; }
+
+ /**
+ * \brief Method used by the 'Transport' to notify read-timeout
+ */
+ virtual void ReadTimeout (asycxx_msecs_t excess_time);
+
+ /**
+ * \brief Method used by the 'Transport' to notify read-error
+ */
+ virtual void ReadError (void);
+
+ /**
+ * \brief Method used by the 'Transport' to notify write-timeout
+ */
+ virtual void WriteTimeout (asycxx_msecs_t excess_time);
+
+ /**
+ * \brief Method used by the 'Transport' to notify write-error
+ */
+ virtual void WriteError (void);
+
+ private:
+ Reactor *m_Reactor;
+ ProtocolFactory *m_Factory;
+ };
+}
#endif /* __HIPRO_ASYCXX__PROTOCOL_H__ */
/*
Modified: trunk/src/Protocol.cxx
===================================================================
--- trunk/src/Protocol.cxx 2009-04-08 07:32:11 UTC (rev 28)
+++ trunk/src/Protocol.cxx 2009-04-08 07:32:54 UTC (rev 29)
@@ -20,63 +20,23 @@
#include <asycxx/Error.h>
#include <asycxx/Protocol.h>
+using namespace asycxx;
-Protocol::Protocol (Reactor *reactor, Factory *factory, Transport *transport)
+Protocol::Protocol (Reactor *reactor, ProtocolFactory *factory)
{
ASSERT ((reactor != NULL), "checking parameters");
ASSERT ((factory != NULL), "checking parameters");
- ASSERT ((transport != NULL), "checking parameters");
-
+
m_Reactor = reactor;
m_Factory = factory;
- m_Transport = transport;
- m_Transport->SetProtocol (this);
}
-Protocol::~Protocol ()
-{
-}
-void
-Protocol::BuildProtocol (void)
-{
- Result ret;
- ret = InitProtocol ();
- if (ret == Result_Success)
- {
- return;
- }
-
- /* looks like init-protocol was not overloaded. should configure
- sane defaults */
-}
-
-Result
-Protocol::InitProtocol (void)
-{
- return Result_Error;
-}
-
-
/* default protocol methods. should be overridden by the derived
classes */
void
-Protocol::DataAvailable (DataBuffer *data)
+Protocol::ReadTimeout (asycxx_msecs_t excess_time)
{
- ERR ("data-available but not handled. lame protocol");
-}
-
-
-void
-Protocol::ConnectionLost (void)
-{
- ERR ("connection-lost not handled. lame protocol");
-}
-
-
-void
-Protocol::ReadTimeout (h_msecs_t excess_time)
-{
ERR ("read timed out (excess=%lld) but not handled. lame protocol",
excess_time);
}
@@ -88,7 +48,7 @@
}
void
-Protocol::WriteTimeout (h_msecs_t excess_time)
+Protocol::WriteTimeout (asycxx_msecs_t excess_time)
{
ERR ("write timed out (excess=%lld) but not handled. lame protocol",
excess_time);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|