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