1 //------------------------------------------------------------------------------ 2 // MessagePointerItemTest.h 3 // 4 //------------------------------------------------------------------------------ 5 6 #ifndef MESSAGEPOINTERITEMTEST_H 7 #define MESSAGEPOINTERITEMTEST_H 8 9 // Standard Includes ----------------------------------------------------------- 10 11 // System Includes ------------------------------------------------------------- 12 13 // Project Includes ------------------------------------------------------------ 14 15 // Local Includes -------------------------------------------------------------- 16 #include "MessageItemTest.h" 17 18 // Local Defines --------------------------------------------------------------- 19 20 // Globals --------------------------------------------------------------------- 21 22 struct TPointerFuncPolicy 23 { 24 static status_t Add(BMessage& msg, const char* name, const void* val) 25 { return msg.AddPointer(name, val); } 26 static status_t AddData(BMessage& msg, const char* name, type_code type, 27 const void* data, ssize_t size, bool) 28 { return msg.AddData(name, type, data, size); } 29 static status_t Find(BMessage& msg, const char* name, int32 index, 30 const void** val) 31 { return msg.FindPointer(name, index, (void**)val); } 32 static status_t ShortFind(BMessage& msg, const char* name, const void** val) 33 { return msg.FindPointer(name, (void**)val); } 34 static const void* QuickFind(BMessage& msg, const char* name, int32 index) 35 { 36 const void* ptr; 37 msg.FindPointer(name, index, (void**)&ptr); 38 return ptr; 39 } 40 static bool Has(BMessage& msg, const char* name, int32 index) 41 { return msg.HasPointer(name, index); } 42 static status_t Replace(BMessage& msg, const char* name, int32 index, 43 const void* val) 44 { return msg.ReplacePointer(name, index, val); } 45 static status_t FindData(BMessage& msg, const char* name, type_code type, 46 int32 index, const void** data, ssize_t* size) 47 { return msg.FindData(name, type, index, data, size); } 48 }; 49 50 struct TPointerInitPolicy : public ArrayTypeBase<const void*> 51 { 52 inline static const void* Zero() { return NULL; } 53 inline static const void* Test1() { return &Test1; } 54 inline static const void* Test2() { return &Test2; } 55 inline static size_t SizeOf(const void*) { return sizeof (const void*); } 56 inline static ArrayType Array() 57 { 58 ArrayType array; 59 array.push_back(Zero()); 60 array.push_back(Test1()); 61 array.push_back(Test2()); 62 return array; 63 } 64 }; 65 66 struct TPointerAssertPolicy 67 { 68 inline static const void* Zero() { return NULL; } 69 inline static const void* Invalid() { return NULL; } 70 inline static bool Size(size_t size, const void* t) 71 { return size == sizeof (t); } 72 }; 73 74 typedef TMessageItemTest 75 < 76 const void*, 77 B_POINTER_TYPE, 78 TPointerFuncPolicy, 79 TPointerInitPolicy, 80 TPointerAssertPolicy 81 > 82 TMessagePointerItemTest; 83 84 #endif // MESSAGEPOINTERITEMTEST_H 85 86 /* 87 * $Log $ 88 * 89 * $Id $ 90 * 91 */ 92 93