1 /******************************************************************************* 2 / 3 / File: PropertyInfo.h 4 / 5 / Description: Utility class for maintain scripting information 6 / 7 / Copyright 1997-98, Be Incorporated, All Rights Reserved 8 / Modified for use with OpenBeOS. 9 / 10 *******************************************************************************/ 11 12 #ifndef _PROPERTY_INFO_H 13 #define _PROPERTY_INFO_H 14 15 #include <BeBuild.h> 16 #include <SupportDefs.h> 17 #include <Flattenable.h> 18 #include <TypeConstants.h> /* For convenience */ 19 20 /* 21 * The following define is used to turn off a number of member functions 22 * and member variables in BPropertyInfo which are only there to faciliate 23 * BeOS R3 compatibility. Be changed the property_info structure between 24 * R3 and R4 and these functions ensure that BPropertyInfo is backward 25 * compatible. However, between R3 and R4, Be changed the Intel executable 26 * format so R4 was not backward compatible with R3. 27 * 28 * Because OpenBeOS is only targetting Intel platform compatibility at this 29 * time, there is no need for R3 compatibility in OpenBeOS. By default 30 * these members will be turned off with the R3_COMPATIBLE define. 31 */ 32 #undef R3_COMPATIBLE 33 34 #ifdef R3_COMPATIBLE 35 struct _oproperty_info_; 36 #endif 37 38 39 /*----------------------------------------------------------------*/ 40 /*----- the property_info structure ------------------------------*/ 41 42 struct compound_type { 43 struct field_pair { 44 char *name; // name of entry in message 45 type_code type; // type_code of entry in message 46 }; 47 field_pair pairs[5]; 48 }; 49 50 struct property_info { 51 char *name; 52 uint32 commands[10]; 53 uint32 specifiers[10]; 54 char *usage; 55 uint32 extra_data; 56 uint32 types[10]; 57 compound_type ctypes[3]; 58 uint32 _reserved[10]; 59 }; 60 61 enum value_kind { 62 B_COMMAND_KIND = 0, 63 B_TYPE_CODE_KIND = 1 64 }; 65 66 struct value_info { 67 char *name; 68 uint32 value; 69 value_kind kind; 70 char *usage; 71 uint32 extra_data; 72 uint32 _reserved[10]; 73 }; 74 75 /*----------------------------------------------------------------*/ 76 /*----- BPropertyInfo class --------------------------------------*/ 77 78 class BPropertyInfo : public BFlattenable { 79 public: 80 BPropertyInfo(property_info *p = NULL, 81 value_info *ci = NULL, 82 bool free_on_delete = false); 83 virtual ~BPropertyInfo(); 84 85 virtual int32 FindMatch(BMessage *msg, 86 int32 index, 87 BMessage *spec, 88 int32 form, 89 const char *prop, 90 void *data = NULL) const; 91 92 virtual bool IsFixedSize() const; 93 virtual type_code TypeCode() const; 94 virtual ssize_t FlattenedSize() const; 95 virtual status_t Flatten(void *buffer, ssize_t size) const; 96 virtual bool AllowsTypeCode(type_code code) const; 97 virtual status_t Unflatten(type_code c, 98 const void *buf, 99 ssize_t s); 100 const property_info *Properties() const; 101 const value_info *Values() const; 102 int32 CountProperties() const; 103 int32 CountValues() const; 104 105 void PrintToStream() const; 106 107 /*----- Private or reserved -----------------------------------------*/ 108 protected: 109 static bool FindCommand(uint32, int32, property_info *); 110 static bool FindSpecifier(uint32, property_info *); 111 112 private: 113 virtual void _ReservedPropertyInfo1(); 114 virtual void _ReservedPropertyInfo2(); 115 virtual void _ReservedPropertyInfo3(); 116 virtual void _ReservedPropertyInfo4(); 117 118 BPropertyInfo(const BPropertyInfo &); 119 BPropertyInfo &operator=(const BPropertyInfo &); 120 void FreeMem(); 121 122 property_info *fPropInfo; 123 value_info *fValueInfo; 124 int32 fPropCount; 125 bool fInHeap; 126 uint16 fValueCount; 127 #ifndef R3_COMPATIBLE 128 uint32 _reserved[4]; 129 #else 130 _oproperty_info_ *fOldPropInfo; 131 bool fOldInHeap; 132 uint32 _reserved[2]; /* was 4 */ 133 134 /* Deprecated */ 135 private: 136 static property_info *ConvertToNew(const _oproperty_info_ *p); 137 static _oproperty_info_ *ConvertFromNew(const property_info *p); 138 const property_info *PropertyInfo() const; 139 BPropertyInfo(property_info *p, 140 bool free_on_delete); 141 static bool MatchCommand(uint32, int32, property_info *); 142 static bool MatchSpecifier(uint32, property_info *); 143 144 #endif 145 }; 146 147 /*-------------------------------------------------------------*/ 148 /*-------------------------------------------------------------*/ 149 150 #endif /* _PROPERTY_INFO_H */ 151