Files
haiku-beta6/headers/private/app/PortLink.h
T

48 lines
880 B
C++
Raw Normal View History

#ifndef _PORTLINK_H
#define _PORTLINK_H
2002-07-09 12:24:59 +00:00
#include <BeBuild.h>
2002-07-09 12:24:59 +00:00
#include <OS.h>
2003-06-23 13:18:39 +00:00
class PortMessage;
2002-07-09 12:24:59 +00:00
2003-10-03 22:20:28 +00:00
class PortLink
{
2003-07-11 23:16:15 +00:00
public:
2003-10-03 22:20:28 +00:00
PortLink(port_id port);
PortLink(const PortLink &link);
2003-10-03 23:28:05 +00:00
virtual ~PortLink(void);
2003-10-03 22:20:28 +00:00
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);
2003-06-23 13:18:39 +00:00
2003-10-03 22:20:28 +00:00
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;
2003-07-11 23:16:15 +00:00
}
2003-10-03 22:20:28 +00:00
return B_NO_MEMORY;
}
private:
2003-10-03 22:20:28 +00:00
bool port_ok;
port_id fSendPort;
port_id fReceivePort;
char *fSendBuffer;
int32 fSendPosition;
int32 fSendCode;
2002-07-09 12:24:59 +00:00
};
2003-04-14 01:56:41 +00:00
#endif