1 /* 2 * Copyright 2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 9 #ifndef PROPERTY_OBJECT_H 10 #define PROPERTY_OBJECT_H 11 12 #include "Observable.h" 13 14 class BMessage; 15 class BString; 16 class Property; 17 18 class PropertyObject : public Observable { 19 public: 20 PropertyObject(); 21 PropertyObject(const PropertyObject& other); 22 virtual ~PropertyObject(); 23 24 status_t Archive(BMessage* into) const; 25 status_t Unarchive(const BMessage* archive); 26 27 bool AddProperty(Property* property); 28 29 Property* PropertyAt(int32 index) const; 30 Property* PropertyAtFast(int32 index) const; 31 int32 CountProperties() const; 32 33 Property* FindProperty(uint32 propertyID) const; 34 bool HasProperty(Property* property) const; 35 36 bool ContainsSameProperties( 37 const PropertyObject& other) const; 38 private: 39 status_t Assign(const PropertyObject& other); 40 41 public: 42 void DeleteProperties(); 43 bool DeleteProperty(uint32 propertyID); 44 45 virtual void ValueChanged(uint32 propertyID); 46 47 // common interface for any property 48 bool SetValue(uint32 propertyID, 49 const char* value); 50 bool GetValue(uint32 propertyID, 51 BString& value) const; 52 53 54 // access to more specific property types 55 bool SetValue(uint32 propertyID, 56 int32 value); 57 int32 Value(uint32 propertyID, 58 int32 defaultValue) const; 59 60 bool SetValue(uint32 propertyID, 61 int64 value); 62 int64 Value(uint32 propertyID, 63 int64 defaultValue) const; 64 65 bool SetValue(uint32 propertyID, 66 float value); 67 float Value(uint32 propertyID, 68 float defaultValue) const; 69 70 bool SetValue(uint32 propertyID, 71 bool value); 72 bool Value(uint32 propertyID, 73 bool defaultValue) const; 74 75 private: 76 BList fProperties; 77 }; 78 79 #endif // PROPERTY_OBJECT_H 80