 |
 |
 |
 |
Etk_Property
Detailed Description
The property system of Etk is a powerful system to set or to get the state of an object, or to be notified when the state of an object has been changed.
Most of the following functions are used internally by Etk, you usually do not have to directly call any of the etk_property_*() functions.
If you want to create a property for a new object type, use etk_type_property_add().
The only case where you have to use the etk_property_value_*_set/get() functions is in the property_set/get() methods when you are implementing a new widget, to set or to get the value of a property.
See Etk_Object for more information about how to use the property system.
|
Data Structures |
struct | Etk_Property |
| An Etk_Property is a name/value couple that can be associated to a type. A property has a default value and can be readable, writable or both. More...
|
struct | Etk_Property_Value |
| The value of a property. You usually do not need to manipulate it directly, use etk_object_properties_set() and etk_object_properties_get() to set and get the value of a property of an object. More...
|
Enumerations |
enum | Etk_Property_Type {
ETK_PROPERTY_NONE,
ETK_PROPERTY_INT,
ETK_PROPERTY_BOOL,
ETK_PROPERTY_CHAR,
ETK_PROPERTY_FLOAT,
ETK_PROPERTY_DOUBLE,
ETK_PROPERTY_SHORT,
ETK_PROPERTY_LONG,
ETK_PROPERTY_OBJECT,
ETK_PROPERTY_POINTER,
ETK_PROPERTY_STRING,
ETK_PROPERTY_OTHER
} |
| The type of a property. More...
|
enum | Etk_Property_Flags {
ETK_PROPERTY_NO_ACCESS = 1 << 0,
ETK_PROPERTY_READABLE = 1 << 1,
ETK_PROPERTY_WRITABLE = 1 << 2,
ETK_PROPERTY_READABLE_WRITABLE,
ETK_PROPERTY_CONSTRUCT = 1 << 3
} |
| Describes if the property is either readable, writable or both. You can also specify if the property needs to be initialized to its default value at the constuction of a new object with ETK_PROPERTY_CONSTRUCT. More...
|
Functions |
Etk_Property * | etk_property_new (const char *name, int property_id, Etk_Property_Type type, Etk_Property_Flags flags, Etk_Property_Value *default_value) |
| Creates a new property.
|
void | etk_property_delete (Etk_Property *property) |
| Deletes the property.
|
Etk_Property_Type | etk_property_type_get (Etk_Property *property) |
| Gets the type of the property.
|
void | etk_property_value_clear (Etk_Property_Value *value) |
| Clears a property value: the current value is freed and the type of the property is set to ETK_PROPERTY_NONE.
|
void | etk_property_value_delete (Etk_Property_Value *value) |
| Deletes a property value.
|
Etk_Property_Type | etk_property_value_type_get (Etk_Property_Value *value) |
| Gets the type of the value.
|
Etk_Property_Value * | etk_property_value_new (void) |
| Creates a new property value with no type.
|
Etk_Property_Value * | etk_property_value_create (Etk_Property_Type type,...) |
| Creates a new property value of type type.
|
Etk_Property_Value * | etk_property_value_create_valist (Etk_Property_Type type, va_list *arg) |
| Creates a new property value of type type.
|
Etk_Property_Value * | etk_property_value_int (int value) |
| Creates a new integer property value.
|
Etk_Property_Value * | etk_property_value_bool (Etk_Bool value) |
| Creates a new boolean property value.
|
Etk_Property_Value * | etk_property_value_char (char value) |
| Creates a new char property value.
|
Etk_Property_Value * | etk_property_value_float (float value) |
| Creates a new float property value.
|
Etk_Property_Value * | etk_property_value_double (double value) |
| Creates a new double property value.
|
Etk_Property_Value * | etk_property_value_short (short value) |
| Creates a new short property value.
|
Etk_Property_Value * | etk_property_value_long (long value) |
| Creates a new long property value.
|
Etk_Property_Value * | etk_property_value_object (Etk_Object *value) |
| Creates a new object property value.
|
Etk_Property_Value * | etk_property_value_pointer (void *value) |
| Creates a new pointer property value.
|
Etk_Property_Value * | etk_property_value_string (const char *value) |
| Creates a new string property value.
|
void | etk_property_value_set (Etk_Property_Value *property_value, Etk_Property_Type type,...) |
| Sets the value of a property value.
|
void | etk_property_value_set_valist (Etk_Property_Value *property_value, Etk_Property_Type type, va_list *arg) |
| Sets the value of a property value.
|
void | etk_property_value_int_set (Etk_Property_Value *property_value, int value) |
| Sets the integer value of a property value.
|
void | etk_property_value_bool_set (Etk_Property_Value *property_value, Etk_Bool value) |
| Sets the boolean value of a property value.
|
void | etk_property_value_char_set (Etk_Property_Value *property_value, char value) |
| Sets the char value of a property value.
|
void | etk_property_value_float_set (Etk_Property_Value *property_value, float value) |
| Sets the float value of a property value.
|
void | etk_property_value_double_set (Etk_Property_Value *property_value, double value) |
| Sets the double value of a property value.
|
void | etk_property_value_short_set (Etk_Property_Value *property_value, short value) |
| Sets the short value of a property value.
|
void | etk_property_value_long_set (Etk_Property_Value *property_value, long value) |
| Sets the long value of a property value.
|
void | etk_property_value_object_set (Etk_Property_Value *property_value, Etk_Object *value) |
| Sets the object value of a property value.
|
void | etk_property_value_pointer_set (Etk_Property_Value *property_value, void *value) |
| Sets the pointer value of a property value.
|
void | etk_property_value_string_set (Etk_Property_Value *property_value, const char *value) |
| Sets the string value of a property value.
|
void | etk_property_value_get (Etk_Property_Value *value, Etk_Property_Type type, void *value_location) |
| Gets the value of the property value.
|
int | etk_property_value_int_get (Etk_Property_Value *value) |
| Gets the integer value of the property value.
|
Etk_Bool | etk_property_value_bool_get (Etk_Property_Value *value) |
| Gets the boolean value of the property value.
|
char | etk_property_value_char_get (Etk_Property_Value *value) |
| Gets the char value of the property value.
|
float | etk_property_value_float_get (Etk_Property_Value *value) |
| Gets the float value of the property value.
|
double | etk_property_value_double_get (Etk_Property_Value *value) |
| Gets the double value of the property value.
|
short | etk_property_value_short_get (Etk_Property_Value *value) |
| Gets the short value of the property value.
|
long | etk_property_value_long_get (Etk_Property_Value *value) |
| Gets the long value of the property value.
|
Etk_Object * | etk_property_value_object_get (Etk_Property_Value *value) |
| Gets the object value of the property value.
|
void * | etk_property_value_pointer_get (Etk_Property_Value *value) |
| Gets the pointer value of the property value.
|
const char * | etk_property_value_string_get (Etk_Property_Value *value) |
| Gets the string value of the property value.
|
Enumeration Type Documentation
The type of a property.
- Enumerator:
-
ETK_PROPERTY_NONE |
Used when the property is uninitialized |
ETK_PROPERTY_INT |
The value of the property is an integer |
ETK_PROPERTY_BOOL |
The value of the property is a boolean (Etk_Bool) |
ETK_PROPERTY_CHAR |
The value of the property is a char |
ETK_PROPERTY_FLOAT |
The value of the property is a float |
ETK_PROPERTY_DOUBLE |
The value of the property is a double |
ETK_PROPERTY_SHORT |
The value of the property is a short |
ETK_PROPERTY_LONG |
The value of the property is a long |
ETK_PROPERTY_OBJECT |
The value of the property is an object (Etk_Object *) |
ETK_PROPERTY_POINTER |
The value of the property is a pointer (void *) |
ETK_PROPERTY_STRING |
The value of the property is a string (char *) |
ETK_PROPERTY_OTHER |
Used when none of the above type can be used. The property can't have a default value, and can't be accessible with etk_object_property_get/set(). The only interest of this kind of property is that you can still use etk_object_notify() when the value of the property has been modified. You then have to use the API of the object to get the new value |
Describes if the property is either readable, writable or both. You can also specify if the property needs to be initialized to its default value at the constuction of a new object with ETK_PROPERTY_CONSTRUCT.
- Enumerator:
-
ETK_PROPERTY_NO_ACCESS |
Used when the property type is ETK_PROPERTY_OTHER |
ETK_PROPERTY_READABLE |
The value of the property is readable |
ETK_PROPERTY_WRITABLE |
The value of the property is writable |
ETK_PROPERTY_READABLE_WRITABLE |
The value of the property is readable and writable |
ETK_PROPERTY_CONSTRUCT |
Use this flag to force the default value of the property to be set when the object is created |
Function Documentation
Creates a new property.
- Parameters:
-
| name | the name of the new property |
| property_id | the id of the new property |
| type | the type of the property |
| flags | describes if the property value should be writable (ETK_PROPERTY_WRITABLE), readable (ETK_PROPERTY_READABLE) or both (ETK_PROPERTY_WRITABLE | ETK_PROPERTY_READABLE) |
| default_value | the default value of the property |
- Returns:
- Returns the new property on success, or NULL on failure
- Warning:
- The property will have to be freed with etk_property_delete()
References default_value, flags, id, name, and type.
Referenced by etk_type_property_add().
Clears a property value: the current value is freed and the type of the property is set to ETK_PROPERTY_NONE.
- Parameters:
-
| value | the property value to clear |
References ETK_PROPERTY_NONE, ETK_PROPERTY_STRING, Etk_Property_Value::string_value, Etk_Property_Value::type, and Etk_Property_Value::value.
Referenced by etk_property_value_bool_set(), etk_property_value_char_set(), etk_property_value_delete(), etk_property_value_double_set(), etk_property_value_float_set(), etk_property_value_int_set(), etk_property_value_long_set(), etk_property_value_object_set(), etk_property_value_pointer_set(), etk_property_value_short_set(), and etk_property_value_string_set().
Creates a new property value with no type.
- Returns:
- Returns the new property value
References ETK_PROPERTY_NONE, and Etk_Property_Value::type.
Referenced by etk_object_properties_get_valist(), etk_property_value_bool(), etk_property_value_char(), etk_property_value_create_valist(), etk_property_value_double(), etk_property_value_float(), etk_property_value_int(), etk_property_value_long(), etk_property_value_object(), etk_property_value_pointer(), etk_property_value_short(), and etk_property_value_string().
Sets the value of a property value.
- Parameters:
-
| property_value | a property value |
| type | the type of the value |
| ... | the value to set (must be compatible with type) |
References etk_property_value_set_valist().
Sets the value of a property value.
- Parameters:
-
| property_value | a property value |
| type | the type of the value |
| arg | the value to set (must be compatible with type) |
References ETK_PROPERTY_BOOL, ETK_PROPERTY_CHAR, ETK_PROPERTY_DOUBLE, ETK_PROPERTY_FLOAT, ETK_PROPERTY_INT, ETK_PROPERTY_LONG, ETK_PROPERTY_OBJECT, ETK_PROPERTY_POINTER, ETK_PROPERTY_SHORT, ETK_PROPERTY_STRING, etk_property_value_bool_set(), etk_property_value_char_set(), etk_property_value_double_set(), etk_property_value_float_set(), etk_property_value_int_set(), etk_property_value_long_set(), etk_property_value_object_set(), etk_property_value_pointer_set(), etk_property_value_short_set(), and etk_property_value_string_set().
Referenced by etk_property_value_create_valist(), and etk_property_value_set().
void etk_property_value_string_set |
( |
Etk_Property_Value * |
property_value, |
|
|
const char * |
value | |
|
) |
| | |
Gets the value of the property value.
- Parameters:
-
| value | a value |
| type | the type of the value |
| value_location | the location where to store the value |
References ETK_PROPERTY_BOOL, ETK_PROPERTY_CHAR, ETK_PROPERTY_DOUBLE, ETK_PROPERTY_FLOAT, ETK_PROPERTY_INT, ETK_PROPERTY_LONG, ETK_PROPERTY_OBJECT, ETK_PROPERTY_POINTER, ETK_PROPERTY_SHORT, ETK_PROPERTY_STRING, etk_property_value_bool_get(), etk_property_value_char_get(), etk_property_value_double_get(), etk_property_value_float_get(), etk_property_value_int_get(), etk_property_value_long_get(), etk_property_value_object_get(), etk_property_value_pointer_get(), etk_property_value_short_get(), and etk_property_value_string_get().
Referenced by etk_object_properties_get_valist().
|
 |
 |
 |
 |
|