[asycxx-devel] SF.net SVN: asycxx:[42] trunk
Status: Alpha
Brought to you by:
joe_steeve
|
From: <joe...@us...> - 2009-04-08 07:43:07
|
Revision: 42
http://asycxx.svn.sourceforge.net/asycxx/?rev=42&view=rev
Author: joe_steeve
Date: 2009-04-08 07:43:06 +0000 (Wed, 08 Apr 2009)
Log Message:
-----------
updated GimpleMsgBus to accomodate changes in rest of asycxx
From: Joe Steeve <js...@hi...>
Modified Paths:
--------------
trunk/include/asycxx/GimpleMsgBus.h
trunk/src/GimpleMsgBus.cxx
Modified: trunk/include/asycxx/GimpleMsgBus.h
===================================================================
--- trunk/include/asycxx/GimpleMsgBus.h 2009-04-08 07:42:19 UTC (rev 41)
+++ trunk/include/asycxx/GimpleMsgBus.h 2009-04-08 07:43:06 UTC (rev 42)
@@ -20,7 +20,8 @@
#include "Error.h"
#include "Reactor.h"
-#include "Protocol.h"
+#include "StreamProtocol.h"
+#include "StreamTransport.h"
#include "MsgBus.h"
/**
@@ -36,51 +37,54 @@
* the Transport.
*/
-class GimpleMsgBus : public Protocol, public MsgBus
+namespace asycxx
{
+ class GimpleMsgBus : public StreamProtocol, public MsgBus
+ {
-public:
- GimpleMsgBus (Reactor *reactor, Factory *factory, Transport *transport,
- MsgHandler *handler);
- ~GimpleMsgBus ();
+ public:
+ GimpleMsgBus (Reactor *reactor, StreamProtocolFactory *factory,
+ StreamTransport *transport, MsgHandler *handler);
+ ~GimpleMsgBus ();
- void DataAvailable (DataBuffer *data);
- void ReadError (void);
- void WriteError (void);
- void ReadTimeout (h_msecs_t excess_time);
- void WriteTimeout (h_msecs_t excess_time);
- void SendMsg (DataBuffer *msg);
+ void DataAvailable (DataBuffer *data);
+ void ReadError (void);
+ void WriteError (void);
+ void ReadTimeout (asycxx_msecs_t excess_time);
+ void WriteTimeout (asycxx_msecs_t excess_time);
+ void SendMsg (DataBuffer *msg);
-protected:
- Result InitProtocol (void);
+ protected:
+ RetCode InitProtocol (void);
-private:
- struct GMBPacketHdr_s
- {
- char signature [4]; /* should contain "GMB\0" */
- uint32_t len; /* length of the xml-packet in
- network-byte-order. */
- } __attribute__ ((packed));
-
- enum GMBState
+ private:
+ struct GMBPacketHdr_s
{
- GMB_WaitingForNewMsg = 0,
- GMB_MsgHarvestInProgress
- };
- GMBState m_State;
+ char signature [4]; /* should contain "GMB\0" */
+ uint32_t len; /* length of the xml-packet in
+ network-byte-order. */
+ } __attribute__ ((packed));
- GMBPacketHdr_s m_Hdr;
- size_t m_Hdr_filled;
- size_t m_Hdr_left;
+ enum GMBState
+ {
+ GMB_WaitingForNewMsg = 0,
+ GMB_MsgHarvestInProgress
+ };
+ GMBState m_State;
- DataBuffer *m_Payload;
- size_t m_Payload_filled;
- size_t m_Payload_left;
+ GMBPacketHdr_s m_Hdr;
+ size_t m_Hdr_filled;
+ size_t m_Hdr_left;
- Result ReadHeader (void *data_ptr, size_t len, size_t& processed);
- Result ReadPayload (void *data_ptr, size_t len, size_t& processed);
-};
+ DataBuffer *m_Payload;
+ size_t m_Payload_filled;
+ size_t m_Payload_left;
+ RetCode ReadHeader (void *data_ptr, size_t len, size_t& processed);
+ RetCode ReadPayload (void *data_ptr, size_t len, size_t& processed);
+ };
+}
+
#endif /* __HIPRO_ASYCXX__GIMPLE_MSG_BUS_H__ */
/*
Modified: trunk/src/GimpleMsgBus.cxx
===================================================================
--- trunk/src/GimpleMsgBus.cxx 2009-04-08 07:42:19 UTC (rev 41)
+++ trunk/src/GimpleMsgBus.cxx 2009-04-08 07:43:06 UTC (rev 42)
@@ -21,14 +21,15 @@
#include "asycxx-common.h"
#include <asycxx/Error.h>
#include <asycxx/Transport.h>
-#include <asycxx/Factory.h>
+#include <asycxx/StreamProtocolFactory.h>
#include <asycxx/MsgHandler.h>
#include <asycxx/GimpleMsgBus.h>
+using namespace asycxx;
-GimpleMsgBus::GimpleMsgBus (Reactor *reactor, Factory *factory,
- Transport *transport, MsgHandler *handler) :
- Protocol (reactor, factory, transport),
+GimpleMsgBus::GimpleMsgBus (Reactor *reactor, StreamProtocolFactory *factory,
+ StreamTransport *transport, MsgHandler *handler) :
+ StreamProtocol (reactor, factory, transport),
MsgBus (handler)
{
ctorLOG ("GimpleMsgBus");
@@ -58,17 +59,17 @@
}
-Result
+RetCode
GimpleMsgBus::InitProtocol (void)
{
- return Result_Success;
+ return RetCode_Success;
}
void
GimpleMsgBus::DataAvailable (DataBuffer *data)
{
- Result ret;
+ RetCode ret;
void *data_ptr;
size_t dleft, processed;
dleft = data->Len();
@@ -84,9 +85,9 @@
{
case GMB_WaitingForNewMsg:
ret = ReadHeader (data_ptr, dleft, processed);
- if (ret != Result_Success)
+ if (ret != RetCode_Success)
{
- m_Transport->LoseConnection ();
+ getTransport()->loseConnection ();
return;
}
data_ptr = (void *)((unsigned int)data->Data() + processed);
@@ -95,9 +96,9 @@
case GMB_MsgHarvestInProgress:
ret = ReadPayload (data_ptr, dleft, processed);
- if (ret != Result_Success)
+ if (ret != RetCode_Success)
{
- m_Transport->LoseConnection ();
+ getTransport()->loseConnection ();
return;
}
data_ptr = (void *)((unsigned int)data->Data() + processed);
@@ -110,7 +111,7 @@
}
-Result
+RetCode
GimpleMsgBus::ReadHeader (void *data_ptr, size_t len, size_t& processed)
{
ASSERT ((data_ptr != NULL), "bad data pointer");
@@ -149,7 +150,7 @@
{
processed = 0;
ERR ("bad signature");
- return Result_Error;
+ return RetCode_Error;
}
/* converting byte-order from network to host */
@@ -163,11 +164,11 @@
}
processed = to_copy;
- return Result_Success;
+ return RetCode_Success;
}
-Result
+RetCode
GimpleMsgBus::ReadPayload (void *data_ptr, size_t len, size_t& processed)
{
ASSERT ((data_ptr != NULL), "bad data pointer");
@@ -180,7 +181,7 @@
"m_Payload_left is going haywire. currently %u",
m_Payload_left);
- Result ret;
+ RetCode ret;
size_t to_copy;
void *dptr;
@@ -206,10 +207,10 @@
/* deliver message to the MessageHandler */
ret = m_Handler->GotMsg (m_Payload);
- if (ret != Result_Success)
+ if (ret != RetCode_Success)
{
ERR ("MsgHandler <%p> does not like data.");
- return Result_Error;
+ return RetCode_Error;
}
/* setup the next state */
@@ -219,7 +220,7 @@
}
processed = to_copy;
- return Result_Success;
+ return RetCode_Success;
}
@@ -248,7 +249,7 @@
/* send it to transport */
try
{
- m_Transport->Write (pkt);
+ getTransport()->Write (pkt);
}
catch (...)
{
@@ -272,13 +273,13 @@
}
void
-GimpleMsgBus::ReadTimeout (h_msecs_t excess_time)
+GimpleMsgBus::ReadTimeout (asycxx_msecs_t excess_time)
{
ERR ("data read timeout. excess = %lld", excess_time);
}
void
-GimpleMsgBus::WriteTimeout (h_msecs_t excess_time)
+GimpleMsgBus::WriteTimeout (asycxx_msecs_t excess_time)
{
ERR ("data write timeout. excess = %lld", excess_time);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|