1 //------------------------------------------------------------------------------ 2 // MessagePrivate.h 3 // 4 //------------------------------------------------------------------------------ 5 6 #ifdef USING_MESSAGE4 7 # include <MessagePrivate4.h> 8 #else 9 10 #ifndef MESSAGEPRIVATE_H 11 #define MESSAGEPRIVATE_H 12 13 #include <Message.h> 14 #include <Messenger.h> 15 #include <MessengerPrivate.h> 16 #include <TokenSpace.h> 17 18 class BMessage::Private { 19 public: 20 Private(BMessage* msg) : fMessage(msg) {;} 21 Private(BMessage& msg) : fMessage(&msg) {;} 22 23 inline void SetTarget(int32 token) 24 { 25 fMessage->fTarget = token; 26 fMessage->fPreferred = token == B_PREFERRED_TOKEN; 27 } 28 29 inline void SetReply(team_id team, port_id port, int32 token) 30 { 31 fMessage->fReplyTo.port = port; 32 fMessage->fReplyTo.target = token; 33 fMessage->fReplyTo.team = team; 34 fMessage->fReplyTo.preferred = token == B_PREFERRED_TOKEN; 35 } 36 37 inline void SetReply(BMessenger messenger) 38 { 39 BMessenger::Private mp(messenger); 40 fMessage->fReplyTo.port = mp.Port(); 41 fMessage->fReplyTo.target = mp.Token(); 42 fMessage->fReplyTo.team = mp.Team(); 43 fMessage->fReplyTo.preferred = mp.IsPreferredTarget(); 44 } 45 46 inline int32 GetTarget() 47 { 48 return fMessage->fTarget; 49 } 50 51 inline bool UsePreferredTarget() 52 { 53 return fMessage->fPreferred; 54 } 55 56 static inline status_t SendFlattenedMessage(void *data, int32 size, 57 port_id port, int32 token, bigtime_t timeout) 58 { 59 return BMessage::_SendFlattenedMessage(data, size, port, token, 60 timeout); 61 } 62 63 static inline void StaticInit() 64 { 65 BMessage::_StaticInit(); 66 } 67 68 static inline void StaticCleanup() 69 { 70 BMessage::_StaticCleanup(); 71 } 72 73 static inline void StaticCacheCleanup() 74 { 75 BMessage::_StaticCacheCleanup(); 76 } 77 78 private: 79 BMessage* fMessage; 80 }; 81 82 #endif // MESSAGEPRIVATE_H 83 #endif // USING_MESSAGE4 84