Separated functionality of PortLink into LinkMsg* to avoid some *serious* code duplication

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9334 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2004-10-14 01:18:38 +00:00
parent 8a2b9ae571
commit 67e2a74dc6
4 changed files with 161 additions and 32 deletions
+7 -32
View File
@@ -29,6 +29,8 @@
#define _PORTLINK_H
#include <OS.h>
#include <LinkMsgReader.h>
#include <LinkMsgSender.h>
/*
Error checking rules: (for if you don't want to check every return code)
@@ -57,11 +59,9 @@ public:
status_t Flush(bigtime_t timeout = B_INFINITE_TIMEOUT);
// see BPrivate::BAppServerLink which inherits from BPortLink
//status_t FlushWithReply(int32 *code);
void SetSendPort(port_id port);
port_id GetSendPort();
void SetReplyPort(port_id port);
port_id GetReplyPort();
@@ -75,39 +75,14 @@ public:
status_t GetNextReply(int32 *code, bigtime_t timeout = B_INFINITE_TIMEOUT);
status_t Read(void *data, ssize_t size);
status_t ReadString(char **string);
template <class Type> status_t Read(Type *data)
template <class T> status_t Read(T *data)
{
return Read(data, sizeof(Type));
return fReader->Read(data,sizeof(T));
}
protected:
status_t FlushCompleted(ssize_t newbuffersize);
status_t ReadFromPort(bigtime_t timeout);
status_t AdjustReplyBuffer(bigtime_t timeout);
void ResetReplyBuffer();
port_id fSendPort;
port_id fReceivePort;
char *fSendBuffer;
char *fRecvBuffer;
int32 fSendPosition; //current append position
int32 fRecvPosition; //current read position
int32 fSendStart; //start of current message
int32 fRecvStart; //start of current message
int32 fSendBufferSize;
int32 fRecvBufferSize;
int32 fSendCount; //number of completed messages in buffer
int32 fDataSize; //size of data in recv buffer
int32 fReplySize; //size of current reply message
status_t fWriteError; //Attach failed for current message
status_t fReadError; //Read failed for current message
LinkMsgReader *fReader;
LinkMsgSender *fSender;
};
#endif