Data Model Children
[Data Model API]
Children and their usage with models.
More...Functions | |
int | eina_model_child_count (const Eina_Model *model) |
Returns the number of child models in model. | |
Eina_Model * | eina_model_child_get (const Eina_Model *model, unsigned int position) |
Get the child at a given position from a model. | |
Eina_Bool | eina_model_child_set (Eina_Model *model, unsigned int position, Eina_Model *child) |
Set the child at a given position from a model. | |
Eina_Bool | eina_model_child_del (Eina_Model *model, unsigned int position) |
Deletes the child model in position-th of model. | |
Eina_Bool | eina_model_child_insert_at (Eina_Model *model, unsigned int position, Eina_Model *child) |
Insert child in the position-th of the list of children of model. | |
int | eina_model_child_append (Eina_Model *model, Eina_Model *child) |
Appends child in model. | |
int | eina_model_child_find (const Eina_Model *model, unsigned int start_position, const Eina_Model *other) |
Returns the position of other amongst the children of model. | |
int | eina_model_child_criteria_match (const Eina_Model *model, unsigned int start_position, Eina_Each_Cb match, const void *data) |
Returns the position of a child of model that mathes the criteria. | |
Eina_Bool | eina_model_child_sort (Eina_Model *model, Eina_Compare_Cb compare) |
Sorts the children of model according to compare. |
Detailed Description
Children and their usage with models.Children are other model instances that are kept sequentially in the model. They are accessed by their integer index within the model. Their index may change if child are inserted or deleted before them, as in an array.
Function Documentation
int eina_model_child_count | ( | const Eina_Model * | model | ) |
Returns the number of child models in model.
- Parameters:
-
model The model instance.
- Returns:
- Number of children in model.
- Since:
- 1.2
Referenced by eina_model_child_append(), eina_model_child_filtered_iterator_get(), eina_model_child_iterator_get(), eina_model_child_reversed_iterator_get(), and eina_model_child_sorted_iterator_get().
Eina_Model* eina_model_child_get | ( | const Eina_Model * | model, | |
unsigned int | position | |||
) |
Get the child at a given position from a model.
- Parameters:
-
model the model instance. position index of child to get.
- Returns:
- child instance with reference increased, or
NULL
on error.
NULL
, one should check for a valid position with eina_model_child_count().
- Warning:
- The returned model has its reference increased, you must release it with eina_model_unref(). This convention is imposed to avoid the object being removed before the caller function has time to use it.
Eina_Bool eina_model_child_set | ( | Eina_Model * | model, | |
unsigned int | position, | |||
Eina_Model * | child | |||
) |
Set the child at a given position from a model.
- Parameters:
-
model the model instance. position index of child to set. child the child to use at given position.
- Returns:
- EINA_TRUE on success, EINA_FALSE on failure.
The existing child is replaced. Its reference will be decreased automatically. To insert a new item instead of replacing, use eina_model_child_insert_at() or eina_model_child_append().
The given model will be adopted by model, that is, the child will have its reference increased if this call succeeds.
- Since:
- 1.2
References eina_error_set(), and EINA_FALSE.
Eina_Bool eina_model_child_del | ( | Eina_Model * | model, | |
unsigned int | position | |||
) |
Deletes the child model in position-th of model.
- Parameters:
-
model The model instance. position The position of the child to be deleted.
- Returns:
- EINA_TRUE on success, EINA_FALSE on failure.
- Warning:
- This decrements the reference count of the child being deleted, which may, or not, cause it to be deconstructed and freed.
- Since:
- 1.2
References eina_error_set(), and EINA_FALSE.
Eina_Bool eina_model_child_insert_at | ( | Eina_Model * | model, | |
unsigned int | position, | |||
Eina_Model * | child | |||
) |
Insert child in the position-th of the list of children of model.
- Parameters:
-
model The model instance. position Position in which to insert child. child The child to be inserted.
- Returns:
- EINA_TRUE on success, EINA_FALSE on failure.
- Warning:
- This increments the reference count of the child being inserted, if it will no longer be used by the inserting code it should call eina_model_unref() on it.
- Since:
- 1.2
References eina_error_set(), and EINA_FALSE.
int eina_model_child_append | ( | Eina_Model * | model, | |
Eina_Model * | child | |||
) |
Appends child in model.
- Parameters:
-
model The model instance. child The child to be appended.
- Returns:
- The position of the added child, or -1 on failure.
- Warning:
- This increments the reference count of the child being inserted, if it will no longer be used by the inserting code it should call eina_model_unref() on it.
- Since:
- 1.2
References eina_error_set(), EINA_FALSE, and eina_model_child_count().
int eina_model_child_find | ( | const Eina_Model * | model, | |
unsigned int | start_position, | |||
const Eina_Model * | other | |||
) |
Returns the position of other amongst the children of model.
- Parameters:
-
model The parent model whose children will be searched. start_position The first children to be compared with other. other The model whose position is desired.
- Returns:
- The position of the searched for child, or -1 if not found.
- Since:
- 1.2
int eina_model_child_criteria_match | ( | const Eina_Model * | model, | |
unsigned int | start_position, | |||
Eina_Each_Cb | match, | |||
const void * | data | |||
) |
Returns the position of a child of model that mathes the criteria.
- Parameters:
-
model The model whose children will be searched. start_position The position of the first child to be checked. match The function used to check if a child matches the criteria. data Data given the to the match function.
- Returns:
- The position of the first child to match the criteria or -1 if no child matches it.
- Since:
- 1.2
Eina_Bool eina_model_child_sort | ( | Eina_Model * | model, | |
Eina_Compare_Cb | compare | |||
) |
Sorts the children of model according to compare.
- Parameters:
-
model The model instance. compare The function to be used in the comparison.
- Returns:
- EINA_TRUE on success, EINA_FALSE on failure.
- Since:
- 1.2
References EINA_FALSE, and EINA_TRUE.