Interface Efl.IModel
Basic Model abstraction. A model in EFL can have a set of key-value properties, where key can only be a string. The value can be anything within an Eina_Value. If a property is not yet available EAGAIN is returned.
Additionally a model can have a list of children. The fetching of the children is asynchronous, this has the advantage of having as few data sets as possible in the memory itself.
Syntax
public interface IModel : IWrapper, IDisposable
Properties
ChildrenCount
Number of children. After @[.properties,changed] is emitted, Efl.IModel.GetChildrenCount() can be used to get the number of children. Efl.IModel.GetChildrenCount() can also be used before calling Efl.IModel.GetChildrenSlice(System.UInt32, System.UInt32) so a valid range is known. Event Efl.IModel.ChildrenCountChangedEvent is emitted when count is finished.
See also Efl.IModel.GetChildrenSlice(System.UInt32, System.UInt32).
Declaration
uint ChildrenCount { get; }
Property Value
Type | Description |
---|---|
System.UInt32 | Current known children count |
Properties
Get properties from model. Properties_get is due to provide callers a way the fetch the current properties implemented/used by the model. The event Efl.IModel.PropertiesChangedEvent will be raised to notify listeners of any modifications in the properties.
See also Efl.IModel.PropertiesChangedEvent.
Declaration
Iterator<string> Properties { get; }
Property Value
Type | Description |
---|---|
Eina.Iterator<System.String> | Array of current properties |
Methods
AddChild()
Add a new child. Add a new child, possibly dummy, depending on the implementation, of a internal keeping. When the child is effectively added the event Efl.IModel.ChildAddedEvent (object still in beta stage) is then raised and the new child is kept along with other children.
Declaration
Object AddChild()
Returns
Type | Description |
---|---|
Efl.Object | Child object |
DelChild(Object)
Remove a child. Remove a child of a internal keeping. When the child is effectively removed the event Efl.IModel.ChildRemovedEvent (object still in beta stage) is then raised to give a chance for listeners to perform any cleanup and/or update references.
Declaration
void DelChild(Object child)
Parameters
Type | Name | Description |
---|---|---|
Efl.Object | child | Child to be removed |
GetChildrenCount()
Number of children. After @[.properties,changed] is emitted, Efl.IModel.GetChildrenCount() can be used to get the number of children. Efl.IModel.GetChildrenCount() can also be used before calling Efl.IModel.GetChildrenSlice(System.UInt32, System.UInt32) so a valid range is known. Event Efl.IModel.ChildrenCountChangedEvent is emitted when count is finished.
See also Efl.IModel.GetChildrenSlice(System.UInt32, System.UInt32).
Declaration
uint GetChildrenCount()
Returns
Type | Description |
---|---|
System.UInt32 | Current known children count |
GetChildrenSlice(UInt32, UInt32)
Get children slice OR full range.
Efl.IModel.GetChildrenSlice(System.UInt32, System.UInt32) behaves in two different ways, it may provide the slice if count
is non-zero OR full range otherwise.
Since 'slice' is a range, for example if we have 20 children a slice could be the range from 3(start) with 4(count), see:
child 0 [no] child 1 [no] child 2 [no] child 3 [yes] child 4 [yes] child 5 [yes] child 6 [yes] child 7 [no]
Optionally the user can call Efl.IModel.GetChildrenCount() to know the number of children so a valid range can be known in advance.
See Efl.IModel.GetChildrenCount()
Note: The returned children will live only as long as the future itself. Once the future is done, if you want to keep the object alive, you need to take a reference for yourself.
Declaration
Future GetChildrenSlice(uint start, uint count)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | start | Range begin - start from here. |
System.UInt32 | count | Range size. If count is 0, start is ignored. |
Returns
Type | Description |
---|---|
Eina.Future | Array of children |
GetChildrenSliceAsync(UInt32, UInt32, CancellationToken)
Async wrapper for Efl.IModel.GetChildrenSlice(System.UInt32, System.UInt32).
Declaration
Task<Value> GetChildrenSliceAsync(uint start, uint count, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | start | Range begin - start from here. |
System.UInt32 | count | Range size. If count is 0, start is ignored. |
System.Threading.CancellationToken | token | Token to notify the async operation of external request to cancel. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Eina.Value> | An async task wrapping the result of the operation. |
GetProperties()
Get properties from model. Properties_get is due to provide callers a way the fetch the current properties implemented/used by the model. The event Efl.IModel.PropertiesChangedEvent will be raised to notify listeners of any modifications in the properties.
See also Efl.IModel.PropertiesChangedEvent.
Declaration
Iterator<string> GetProperties()
Returns
Type | Description |
---|---|
Eina.Iterator<System.String> | Array of current properties |
GetProperty(String)
Retrieve the value of a given property name. At this point the caller is free to get values from properties. The event Efl.IModel.PropertiesChangedEvent may be raised to notify listeners of the property/value.
See Efl.IModel.GetProperties(), Efl.IModel.PropertiesChangedEvent
Declaration
Value GetProperty(string property)
Parameters
Type | Name | Description |
---|---|---|
System.String | property | Property name |
Returns
Type | Description |
---|---|
Eina.Value | Property value |
GetPropertyReady(String)
Get a future value when it changes to something that is not error:EAGAIN Efl.IModel.GetProperty(System.String) can return an error with code EAGAIN when it doesn't have any meaningful value. To make life easier, this future will resolve when the error:EAGAIN disappears. Either into a failed future in case the error code changed to something else or a success with the value of the property whenever the property finally changes.
The future can also be canceled if the model itself gets destroyed.
Declaration
Future GetPropertyReady(string property)
Parameters
Type | Name | Description |
---|---|---|
System.String | property | Property name. |
Returns
Type | Description |
---|---|
Eina.Future | Future to be resolved when the property changes to anything other than error:EAGAIN |
GetPropertyReadyAsync(String, CancellationToken)
Async wrapper for Efl.IModel.GetPropertyReady(System.String).
Declaration
Task<Value> GetPropertyReadyAsync(string property, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | property | Property name. |
System.Threading.CancellationToken | token | Token to notify the async operation of external request to cancel. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Eina.Value> | An async task wrapping the result of the operation. |
SetProperty(String, Value)
Set a property value of a given property name. The caller must first read Efl.IModel.GetProperties() to obtain the list of available properties before being able to access them through Efl.IModel.GetProperty(System.String). This function sets a new property value into given property name. Once the operation is completed the concrete implementation should raise Efl.IModel.PropertiesChangedEvent event in order to notify listeners of the new value of the property.
If the model doesn't have the property then there are two possibilities, either raise an error or create the new property in model
See Efl.IModel.GetProperty(System.String), Efl.IModel.PropertiesChangedEvent
Declaration
Future SetProperty(string property, Value value)
Parameters
Type | Name | Description |
---|---|---|
System.String | property | Property name |
Eina.Value | value | Property value |
Returns
Type | Description |
---|---|
Eina.Future | Return an error in case the property could not be set, or the value that was set otherwise. |
SetPropertyAsync(String, Value, CancellationToken)
Async wrapper for Efl.IModel.SetProperty(System.String, Eina.Value).
Declaration
Task<Value> SetPropertyAsync(string property, Value value, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | property | Property name |
Eina.Value | value | Property value |
System.Threading.CancellationToken | token | Token to notify the async operation of external request to cancel. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Eina.Value> | An async task wrapping the result of the operation. |
Events
ChildrenCountChangedEvent
Event dispatched when children count is finished.
Declaration
event EventHandler ChildrenCountChangedEvent
Event Type
Type | Description |
---|---|
System.EventHandler |
PropertiesChangedEvent
Event dispatched when properties list is available.
Declaration
event EventHandler<ModelPropertiesChangedEventArgs> PropertiesChangedEvent
Event Type
Type | Description |
---|---|
System.EventHandler<Efl.ModelPropertiesChangedEventArgs> |