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 #define B_PROPERTY_INFO_TYPE 'SCTD' 76 77 /*----------------------------------------------------------------*/ 78 /*----- BPropertyInfo class --------------------------------------*/ 79 80 class BPropertyInfo : public BFlattenable { 81 public: 82 BPropertyInfo(property_info *p = NULL, 83 value_info *ci = NULL, 84 bool free_on_delete = false); 85 virtual ~BPropertyInfo(); 86 87 virtual int32 FindMatch(BMessage *msg, 88 int32 index, 89 BMessage *spec, 90 int32 form, 91 const char *prop, 92 void *data = NULL) const; 93 94 virtual bool IsFixedSize() const; 95 virtual type_code TypeCode() const; 96 virtual ssize_t FlattenedSize() const; 97 virtual status_t Flatten(void *buffer, ssize_t size) const; 98 virtual bool AllowsTypeCode(type_code code) const; 99 virtual status_t Unflatten(type_code c, 100 const void *buf, 101 ssize_t s); 102 const property_info *Properties() const; 103 const value_info *Values() const; 104 int32 CountProperties() const; 105 int32 CountValues() const; 106 107 void PrintToStream() const; 108 109 /*----- Private or reserved -----------------------------------------*/ 110 protected: 111 static bool FindCommand(uint32, int32, property_info *); 112 static bool FindSpecifier(uint32, property_info *); 113 114 private: 115 virtual void _ReservedPropertyInfo1(); 116 virtual void _ReservedPropertyInfo2(); 117 virtual void _ReservedPropertyInfo3(); 118 virtual void _ReservedPropertyInfo4(); 119 120 BPropertyInfo(const BPropertyInfo &); 121 BPropertyInfo &operator=(const BPropertyInfo &); 122 void FreeMem(); 123 124 property_info *fPropInfo; 125 value_info *fValueInfo; 126 int32 fPropCount; 127 bool fInHeap; 128 uint16 fValueCount; 129 #ifndef R3_COMPATIBLE 130 uint32 _reserved[4]; 131 #else 132 _oproperty_info_ *fOldPropInfo; 133 bool fOldInHeap; 134 uint32 _reserved[2]; /* was 4 */ 135 136 /* Deprecated */ 137 private: 138 static property_info *ConvertToNew(const _oproperty_info_ *p); 139 static _oproperty_info_ *ConvertFromNew(const property_info *p); 140 const property_info *PropertyInfo() const; 141 BPropertyInfo(property_info *p, 142 bool free_on_delete); 143 static bool MatchCommand(uint32, int32, property_info *); 144 static bool MatchSpecifier(uint32, property_info *); 145 146 #endif 147 }; 148 149 /*-------------------------------------------------------------*/ 150 /*-------------------------------------------------------------*/ 151 152 #endif /* _PROPERTY_INFO_H */ 153