Added a sensible workaround for BSession message code packaging git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4936 a95241bf-73f2-0310-859d-f6bbb57e9c96
48 lines
880 B
C++
48 lines
880 B
C++
#ifndef _PORTLINK_H
|
|
#define _PORTLINK_H
|
|
|
|
#include <BeBuild.h>
|
|
#include <OS.h>
|
|
|
|
class PortMessage;
|
|
|
|
class PortLink
|
|
{
|
|
public:
|
|
PortLink(port_id port);
|
|
PortLink(const PortLink &link);
|
|
virtual ~PortLink(void);
|
|
|
|
void SetOpCode(int32 code);
|
|
|
|
void SetPort(port_id port);
|
|
port_id GetPort();
|
|
|
|
status_t Flush(bigtime_t timeout = B_INFINITE_TIMEOUT);
|
|
status_t FlushWithReply(PortMessage *msg,bigtime_t timeout=B_INFINITE_TIMEOUT);
|
|
|
|
void MakeEmpty();
|
|
status_t Attach(const void *data, size_t size);
|
|
template <class Type> status_t Attach(Type data)
|
|
{
|
|
int32 size = sizeof(Type);
|
|
|
|
if (4096 - fSendPosition > size){
|
|
memcpy(fSendBuffer + fSendPosition, &data, size);
|
|
fSendPosition += size;
|
|
return B_OK;
|
|
}
|
|
return B_NO_MEMORY;
|
|
}
|
|
|
|
private:
|
|
bool port_ok;
|
|
port_id fSendPort;
|
|
port_id fReceivePort;
|
|
char *fSendBuffer;
|
|
int32 fSendPosition;
|
|
int32 fSendCode;
|
|
};
|
|
|
|
#endif
|