xref: /haiku/headers/os/app/PropertyInfo.h (revision 21258e2674226d6aa732321b6f8494841895af5f)
1 /*
2  * Copyright 2009-2010 Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT license.
4  */
5 #ifndef _PROPERTY_INFO_H
6 #define _PROPERTY_INFO_H
7 
8 
9 #include <BeBuild.h>
10 #include <Flattenable.h>
11 #include <SupportDefs.h>
12 #include <TypeConstants.h>
13 
14 
15 class BMessage;
16 
17 
18 struct compound_type {
19 	struct field_pair {
20 		const char*	name;
21 		type_code	type;
22 	};
23 	field_pair	pairs[5];
24 };
25 
26 
27 struct property_info {
28 	const char*		name;
29 	uint32			commands[10];
30 	uint32			specifiers[10];
31 	const char*		usage;
32 	uint32			extra_data;
33 	uint32			types[10];
34 	compound_type	ctypes[3];
35 	uint32			_reserved[10];
36 };
37 
38 
39 enum value_kind {
40 	B_COMMAND_KIND = 0,
41 	B_TYPE_CODE_KIND = 1
42 };
43 
44 
45 struct value_info {
46 	const char*		name;
47 	uint32			value;
48 	value_kind		kind;
49 	const char*		usage;
50 	uint32			extra_data;
51 	uint32			_reserved[10];
52 };
53 
54 
55 class BPropertyInfo : public BFlattenable {
56 public:
57 								BPropertyInfo(property_info* prop = NULL,
58 									value_info* value = NULL,
59 									bool freeOnDelete = false);
60 	virtual						~BPropertyInfo();
61 
62 	virtual	int32				FindMatch(BMessage* msg, int32 index,
63 									BMessage* specifier, int32 form,
64 									const char* prop, void* data = NULL) const;
65 
66 	virtual	bool				IsFixedSize() const;
67 	virtual	type_code			TypeCode() const;
68 	virtual	ssize_t				FlattenedSize() const;
69 	virtual	status_t			Flatten(void* buffer, ssize_t size) const;
70 	virtual	bool				AllowsTypeCode(type_code code) const;
71 	virtual	status_t			Unflatten(type_code code, const void* buffer,
72 									ssize_t size);
73 
74 		const property_info*	Properties() const;
75 		const value_info*		Values() const;
76 		int32					CountProperties() const;
77 		int32					CountValues() const;
78 
79 		void					PrintToStream() const;
80 
81 protected:
82 	static	bool				FindCommand(uint32 what, int32 index,
83 									property_info* info);
84 	static	bool				FindSpecifier(uint32 form, property_info* info);
85 
86 private:
87 	virtual	void				_ReservedPropertyInfo1();
88 	virtual	void				_ReservedPropertyInfo2();
89 	virtual	void				_ReservedPropertyInfo3();
90 	virtual	void				_ReservedPropertyInfo4();
91 
92 								BPropertyInfo(const BPropertyInfo& other);
93 			BPropertyInfo&		operator=(const BPropertyInfo& other);
94 			void				FreeMem();
95 
96 			property_info*		fPropInfo;
97 			value_info*			fValueInfo;
98 			int32				fPropCount;
99 			bool				fInHeap;
100 			uint16				fValueCount;
101 			uint32				_reserved[4];
102 };
103 
104 
105 #endif	/* _PROPERTY_INFO_H */
106