Ticket #975 (closed defect: fixed)
[API] Common API interface pattern for list-implementations
| Reported by: | dgollub | Owned by: | bricks |
|---|---|---|---|
| Priority: | high | Milestone: | OpenSync 0.39 |
| Component: | OpenSync | Version: | 0.38 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
Some "objects"/modules provide a list-(like) interface. Those interface should be across the entire osync_ name consistent. Some return OSyncList * some provide direct list manipulation "methos"/functions:
* osync_xyz_add_yx/osync_xyz_insert_yx/osync_xyz_append_yx * osync_yxz_remove_yx / osync_yxz_delete_yx * osync_yxz_length_yx / osync_yxz_size_yx
Tasks would be:
- define a consistent interface pattern for "list-like" implementation
- no current pattern defined, is up to the ticket-owner to draft something!
- document this pattern in source:/trunk/CODING
- apply interfaces changes to OpenSync public API
Attachments
Change History
Changed 3 years ago by bricks
-
attachment
opensync_list_pattern_new.diff
added
first patch for plugin env
comment:4 Changed 3 years ago by bricks
- Status changed from new to assigned
I would like to propose the following api:
- All lists in a public api interface will use OSyncList.
- There will be an function which returns a shallow copy of the internal list like OSyncList *osync_xyz_get_yx (e.g. OSyncList *osync_plugin_env_get_plugins)
- A new entry will be inserted by a osync_xyz_add_yx function
- An entry will be removed by osync_yxz_remove_yx
- osync_yxz_length_yx/osync_yxz_size_yx/osync_yxz_num_yx will be removed completely. It will be possible to get the size/number of entries via the returned list. E.g. OSyncList list = osync_xyz_get_yx(...); unsigned int num = osync_list_length(list);
Comments are requested ;)
comment:5 Changed 3 years ago by dgollub
The opensync_list_pattern_new.diff looks fine - only one minor thing:
osync_plugin_env_num_plugins got moved to an internal/private API - but still gets exported with OSYNC_EXPORT public. Please change this to OSYNC_TEST_EXPORT and remove this interface from opesnsync.sym
comment:10 Changed 3 years ago by bricks
comment:11 Changed 3 years ago by bricks
comment:12 Changed 3 years ago by bricks
comment:13 Changed 3 years ago by bricks
comment:14 Changed 3 years ago by bricks
(In [5430]) OSyncObjTypeSink had a osync_objtype_sink_get_objformat_sinks functions Changed this function to return a copy of the list Therefore other functions which depend on the list had to be changed too removed osync_objtype_sink_num_objformat_sinks and osync_objtype_sink_nth_objformat_sink from public api refs #975
comment:15 Changed 3 years ago by dgollub
comment:16 Changed 3 years ago by bricks
- Status changed from assigned to closed
- Resolution set to fixed
We decided to keep the last missing interfaces as they are because they depend on libxml2 functions and don't use a OSyncList internally. These functions are:
osync_xmlfield_get_nth_attr_name osync_xmlfield_get_nth_attr_value osync_xmlfield_get_nth_key_name osync_xmlfield_get_nth_key_value osync_xmlfield_set_nth_key_value osync_xmlfield_get_attr_count osync_xmlfield_get_key_count osync_capability_get_nth_key
