2 * Copyright 2006, Haiku.
3 * Distributed under the terms of the MIT License.
6 * Stephan Aßmus <superstippi@gmx.de>
14 #include <Archivable.h>
16 #include <TypeConstants.h>
18 class PropertyAnimator
;
21 class Property
: public BArchivable
{
23 Property(uint32 identifier
);
24 Property(const Property
& other
);
25 Property(BMessage
* archive
);
28 // BArchivable interface
29 virtual status_t
Archive(BMessage
* archive
,
30 bool deep
= true) const;
33 virtual Property
* Clone() const = 0;
35 virtual type_code
Type() const = 0;
37 virtual bool SetValue(const char* value
) = 0;
38 virtual bool SetValue(const Property
* other
) = 0;
39 virtual void GetValue(BString
& string
) = 0;
42 virtual bool InterpolateTo(const Property
* other
,
45 inline uint32
Identifier() const
46 { return fIdentifier
; }
48 void SetEditable(bool editable
);
49 inline bool IsEditable() const
58 class IntProperty
: public Property
{
60 IntProperty(uint32 identifier
,
62 int32 min
= INT32_MIN
,
63 int32 max
= INT32_MAX
);
64 IntProperty(const IntProperty
& other
);
65 IntProperty(BMessage
* archive
);
66 virtual ~IntProperty();
68 virtual status_t
Archive(BMessage
* archive
,
69 bool deep
= true) const;
70 static BArchivable
* Instantiate(BMessage
* archive
);
72 virtual Property
* Clone() const;
74 virtual type_code
Type() const
75 { return B_INT32_TYPE
; }
77 virtual bool SetValue(const char* value
);
78 virtual bool SetValue(const Property
* other
);
79 virtual void GetValue(BString
& string
);
81 virtual bool InterpolateTo(const Property
* other
,
85 bool SetValue(int32 value
);
87 inline int32
Value() const
89 inline int32
Min() const
91 inline int32
Max() const
101 class FloatProperty
: public Property
{
103 FloatProperty(uint32 identifier
,
105 float min
= -1000000.0,
106 float max
= 1000000.0);
107 FloatProperty(const FloatProperty
& other
);
108 FloatProperty(BMessage
* archive
);
109 virtual ~FloatProperty();
111 virtual status_t
Archive(BMessage
* archive
,
112 bool deep
= true) const;
113 static BArchivable
* Instantiate(BMessage
* archive
);
115 virtual Property
* Clone() const;
117 virtual type_code
Type() const
118 { return B_FLOAT_TYPE
; }
120 virtual bool SetValue(const char* value
);
121 virtual bool SetValue(const Property
* other
);
122 virtual void GetValue(BString
& string
);
124 virtual bool InterpolateTo(const Property
* other
,
128 bool SetValue(float value
);
130 inline float Value() const
132 inline float Min() const
134 inline float Max() const
144 class UInt8Property
: public Property
{
146 UInt8Property(uint32 identifier
,
148 UInt8Property(const UInt8Property
& other
);
149 UInt8Property(BMessage
* archive
);
150 virtual ~UInt8Property();
152 virtual status_t
Archive(BMessage
* archive
,
153 bool deep
= true) const;
154 static BArchivable
* Instantiate(BMessage
* archive
);
156 virtual Property
* Clone() const;
158 virtual type_code
Type() const
159 { return B_INT8_TYPE
; }
161 virtual bool SetValue(const char* value
);
162 virtual bool SetValue(const Property
* other
);
163 virtual void GetValue(BString
& string
);
165 virtual bool InterpolateTo(const Property
* other
,
169 bool SetValue(uint8 value
);
171 inline uint8
Value() const
179 class BoolProperty
: public Property
{
181 BoolProperty(uint32 identifier
,
183 BoolProperty(const BoolProperty
& other
);
184 BoolProperty(BMessage
* archive
);
185 virtual ~BoolProperty();
187 virtual status_t
Archive(BMessage
* archive
,
188 bool deep
= true) const;
189 static BArchivable
* Instantiate(BMessage
* archive
);
191 virtual Property
* Clone() const;
193 virtual type_code
Type() const
194 { return B_BOOL_TYPE
; }
196 virtual bool SetValue(const char* value
);
197 virtual bool SetValue(const Property
* other
);
198 virtual void GetValue(BString
& string
);
200 virtual bool InterpolateTo(const Property
* other
,
204 bool SetValue(bool value
);
206 inline bool Value() const
214 class StringProperty
: public Property
{
216 StringProperty(uint32 identifier
,
218 StringProperty(const StringProperty
& other
);
219 StringProperty(BMessage
* archive
);
220 virtual ~StringProperty();
222 virtual status_t
Archive(BMessage
* archive
,
223 bool deep
= true) const;
224 static BArchivable
* Instantiate(BMessage
* archive
);
226 virtual Property
* Clone() const;
228 virtual type_code
Type() const
229 { return B_STRING_TYPE
; }
231 virtual bool SetValue(const char* value
);
232 virtual bool SetValue(const Property
* other
);
233 virtual void GetValue(BString
& string
);
236 inline const char* Value() const
237 { return fValue
.String(); }