1 #ifndef _PORTLINK_H_ 2 #define _PORTLINK_H_ 3 4 #include <Errors.h> 5 #include <OS.h> 6 #include <SupportDefs.h> 7 #include <Rect.h> 8 9 #ifndef _PORTLINK_BUFFERSIZE 10 #define _PORTLINK_MAX_ATTACHMENTS 50 11 #endif 12 13 class PortLinkData; 14 15 class PortLink 16 { 17 class ReplyData 18 { 19 public: 20 ReplyData(void) { code=0; buffersize=0; buffer=NULL; } 21 int32 code; 22 ssize_t buffersize; 23 int8 *buffer; 24 }; 25 public: 26 PortLink(port_id port); 27 PortLink(const PortLink &link); 28 ~PortLink(void); 29 void SetOpCode(int32 code); 30 void SetPort(port_id port); 31 port_id GetPort(void); 32 status_t Flush(bigtime_t timeout=B_INFINITE_TIMEOUT); 33 int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, 34 bigtime_t timeout=B_INFINITE_TIMEOUT); 35 status_t FlushWithReply(PortLink::ReplyData *data,bigtime_t timeout=B_INFINITE_TIMEOUT); 36 status_t Attach(void *data, size_t size); 37 status_t Attach(int32 data); 38 status_t Attach(int16 data); 39 status_t Attach(int8 data); 40 status_t Attach(float data); 41 status_t Attach(bool data); 42 status_t Attach(BRect data); 43 status_t Attach(BPoint data); 44 void MakeEmpty(void); 45 protected: 46 void FlattenData(int8 **buffer,int32 *size); 47 port_id target, replyport; 48 int32 opcode; 49 uint32 bufferlength,capacity; 50 int num_attachments; 51 bool port_ok; 52 PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS]; 53 }; 54 55 #endif