2003-08-31 21:21:49 +04:00
|
|
|
#ifndef _PORTLINK_H
|
|
|
|
#define _PORTLINK_H
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-08-31 21:21:49 +04:00
|
|
|
|
|
|
|
#include <BeBuild.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <OS.h>
|
2003-08-31 21:21:49 +04:00
|
|
|
|
|
|
|
#include "Session.h"
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-06-23 17:18:39 +04:00
|
|
|
class PortMessage;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-08-31 21:21:49 +04:00
|
|
|
class PortLink : public BSession{
|
2003-07-12 03:16:15 +04:00
|
|
|
public:
|
2003-08-31 21:21:49 +04:00
|
|
|
class ReplyData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ReplyData(void) { code=0; buffersize=0; buffer=NULL; }
|
|
|
|
~ReplyData(void) { if(buffer) delete buffer; }
|
|
|
|
|
|
|
|
int32 code;
|
|
|
|
ssize_t buffersize;
|
|
|
|
int8 *buffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
PortLink( port_id port );
|
|
|
|
PortLink( const PortLink &link );
|
|
|
|
virtual ~PortLink() { }
|
2003-07-12 03:16:15 +04:00
|
|
|
|
2003-08-31 21:21:49 +04:00
|
|
|
void SetOpCode( int32 code );
|
|
|
|
void SetPort( port_id port );
|
|
|
|
port_id GetPort();
|
|
|
|
status_t Flush( bigtime_t timeout = B_INFINITE_TIMEOUT );
|
|
|
|
int8* FlushWithReply( int32 *code, status_t *status, ssize_t *buffersize,
|
|
|
|
bigtime_t timeout=B_INFINITE_TIMEOUT );
|
|
|
|
status_t FlushWithReply( PortLink::ReplyData *data,bigtime_t timeout=B_INFINITE_TIMEOUT );
|
|
|
|
status_t FlushWithReply( PortMessage *msg,bigtime_t timeout=B_INFINITE_TIMEOUT );
|
2003-06-23 17:18:39 +04:00
|
|
|
|
2003-08-31 21:21:49 +04:00
|
|
|
status_t Attach(const void *data, size_t size);
|
|
|
|
void MakeEmpty();
|
|
|
|
template <class Type> status_t Attach(Type data)
|
2003-07-12 03:16:15 +04:00
|
|
|
{
|
2003-08-31 21:21:49 +04:00
|
|
|
int32 size = sizeof(Type);
|
2003-07-12 03:16:15 +04:00
|
|
|
|
2003-08-31 21:21:49 +04:00
|
|
|
if (4096 - fSendPosition > size){
|
|
|
|
memcpy(fSendBuffer + fSendPosition, &data, size);
|
|
|
|
fSendPosition += size;
|
|
|
|
return B_OK;
|
2003-07-12 03:16:15 +04:00
|
|
|
}
|
2003-08-31 21:21:49 +04:00
|
|
|
return B_NO_MEMORY;
|
2003-07-12 03:16:15 +04:00
|
|
|
}
|
2003-08-31 21:21:49 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool port_ok;
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2003-08-31 21:21:49 +04:00
|
|
|
//extern _IMPEXP_BE _PortLink_ *main_session;
|
|
|
|
|
2003-04-14 05:56:41 +04:00
|
|
|
#endif
|