[asycxx-devel] SF.net SVN: asycxx:[30] trunk
Status: Alpha
Brought to you by:
joe_steeve
|
From: <joe...@us...> - 2009-04-08 07:33:47
|
Revision: 30
http://asycxx.svn.sourceforge.net/asycxx/?rev=30&view=rev
Author: joe_steeve
Date: 2009-04-08 07:33:40 +0000 (Wed, 08 Apr 2009)
Log Message:
-----------
added class:StreamProtocol to provide a base for 'stream' protocols
This contains code that was previously in class:Protocol. This class
should serve as a base for all 'stream'/'connection' based protocols.
From: Joe Steeve <js...@hi...>
Added Paths:
-----------
trunk/include/asycxx/StreamProtocol.h
trunk/src/StreamProtocol.cxx
Added: trunk/include/asycxx/StreamProtocol.h
===================================================================
--- trunk/include/asycxx/StreamProtocol.h (rev 0)
+++ trunk/include/asycxx/StreamProtocol.h 2009-04-08 07:33:40 UTC (rev 30)
@@ -0,0 +1,77 @@
+
+/********************************************************************
+ * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
+ * rights reserved.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms described in the LICENSE file which accompanies
+ * this distribution. If the LICENSE file was not attached to this
+ * distribution or for further clarifications, please contact
+ * le...@hi....
+ *
+ *******************************************************************/
+
+#ifndef __HIPRO_ASYCXX__STREAM_PROTOCOL_H__
+#define __HIPRO_ASYCXX__STREAM_PROTOCOL_H__
+
+#ifdef HAVE_CONFIG_H
+#include <asycxx-config.h>
+#endif
+
+#include "Error.h"
+#include "Reactor.h"
+#include "DataBuffer.h"
+#include "Protocol.h"
+
+
+namespace asycxx
+{
+ class StreamProtocolFactory;
+ class StreamTransport;
+
+ class StreamProtocol : public Protocol
+ {
+ public:
+ StreamProtocol (Reactor *reactor, StreamProtocolFactory *factory,
+ StreamTransport *transport);
+ virtual ~StreamProtocol () {}
+
+ /**
+ * \brief Called when there is data available
+ *
+ * \details This method is called by the attached
+ * 'StreamTransport' when there is data available. The given
+ * 'DataBuffer' is owned by the 'StreamTransport'. The 'Protocol'
+ * should claim it if it needs it for further processing.
+ */
+ virtual void DataAvailable (DataBuffer *data);
+
+ /**
+ * \brief Called when the connection is lost
+ *
+ * \details This method is called by the attached
+ * 'StreamTransport' when it loses connection. The 'Protocol' will
+ * be deleted after this.
+ */
+ virtual void ConnectionLost (void);
+
+ /**
+ * \brief get the current Transport
+ */
+ StreamTransport * getTransport (void) { return m_Transport; }
+
+ private:
+ StreamTransport * m_Transport;
+ };
+}
+
+#endif /* __HIPRO_ASYCXX__STREAM_PROTOCOL_H__ */
+
+/*
+ Local Variables:
+ mode: c++
+ indent-tabs-mode: nil
+ tab-width: 4
+ c-file-style: "gnu"
+ End:
+*/
Added: trunk/src/StreamProtocol.cxx
===================================================================
--- trunk/src/StreamProtocol.cxx (rev 0)
+++ trunk/src/StreamProtocol.cxx 2009-04-08 07:33:40 UTC (rev 30)
@@ -0,0 +1,58 @@
+
+/********************************************************************
+ * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
+ * rights reserved.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms described in the LICENSE file which accompanies
+ * this distribution. If the LICENSE file was not attached to this
+ * distribution or for further clarifications, please contact
+ * le...@hi....
+ *
+ *******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <asycxx-config.h>
+#endif
+
+
+#include "asycxx-common.h"
+#include <asycxx/Error.h>
+#include <asycxx/StreamProtocol.h>
+#include <asycxx/StreamTransport.h>
+
+using namespace asycxx;
+
+StreamProtocol::StreamProtocol (Reactor *reactor,
+ StreamProtocolFactory *factory,
+ StreamTransport *transport)
+ : Protocol (reactor, (ProtocolFactory *)factory)
+{
+ ASSERT ((transport != NULL), "NULL transport?");
+ m_Transport = transport;
+ m_Transport->startReading();
+}
+
+/* default protocol methods. should be overridden by the derived
+ classes */
+void
+StreamProtocol::DataAvailable (DataBuffer *data)
+{
+ ERR ("data-available but not handled. lame protocol");
+}
+
+
+void
+StreamProtocol::ConnectionLost (void)
+{
+ ERR ("connection-lost not handled. lame protocol");
+}
+
+/*
+ Local Variables:
+ mode: c++
+ indent-tabs-mode: nil
+ tab-width: 4
+ c-file-style: "gnu"
+ End:
+*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|