openblt

a hobby OS from the late 90s
git clone http://frotz.net/git/openblt.git
Log | Files | Refs | LICENSE

Message.h (1635B)


      1 // Copyright 1999, Brian J. Swetland.  All Rights Reserved.
      2 // This file is provided under the terms of the OpenBLT License
      3 
      4 #ifndef __BLT_MESSAGE_H
      5 #define __BLT_MESSAGE_H
      6 
      7 #include <blt/types.h>
      8 
      9 #define BLT_TYPE_INT32      'bI32'
     10 #define BLT_TYPE_STRING     'bSTR'
     11 #define BLT_TYPE_POINTER    'bPTR'
     12 #define BLT_TYPE_MESSAGE    'bMSG'
     13 
     14 namespace BLT {
     15 
     16 class Message 
     17 {
     18 public:
     19 	Message();
     20 	~Message();
     21 	
     22 	/* -------------------------------------------------------- */
     23 	int PutData(uint32 type, uint32 id, const void *data, uint32 len);
     24 	int GetData(uint32 type, uint32 id, void *data, uint32 len) const;
     25 	int GetData(uint32 type, uint32 id, const void **data, uint32 *len) const;
     26 	int GetEntry(uint32 n, uint32 *type, uint32 *id, const void **data, uint32 *len) const;
     27 	
     28 	/* -------------------------------------------------------- */
     29 	int PutInt32(uint32 id, int32 data);
     30 	int PutString(uint32 id, const char *data);
     31 	int PutPointer(uint32 id, void *data);
     32 	int PutMessage(uint32 id, Message *msg);
     33 			
     34 	/* -------------------------------------------------------- */
     35 	int GetInt32(uint32 id, int32 *data) const;
     36 	int GetString(uint32 id, const char **data) const;		
     37 	int GetPointer(uint32 id, void **ptr) const;
     38 	int GetMessage(uint32 id, Message *msg) const;
     39 	
     40 	/* -------------------------------------------------------- */
     41 	int GetPackedData(const void **data, uint32 *length) const;
     42 	int PutPackedData(const void *data, uint32 length, int reply_port = -1);
     43 	
     44 	int Reply(const Message *msg) const;
     45 	
     46 	void Empty();
     47 	
     48 	void dump();
     49 	
     50 private:
     51 	void *_data;
     52 	uint32 _length;
     53 	uint32 _available;
     54 	
     55 	int _reply_port;
     56 };
     57 
     58 }
     59 #endif
     60