Ticket #975 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

[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:

  1. define a consistent interface pattern for "list-like" implementation
    1. no current pattern defined, is up to the ticket-owner to draft something!
  2. document this pattern in source:/trunk/CODING
  3. apply interfaces changes to OpenSync public API

Attachments

opensync_list_pattern_new.diff Download (4.2 KB) - added by bricks 3 years ago.
first patch for plugin env
opensync_list_pattern.diff Download (19.9 KB) - added by bricks 3 years ago.
opensync_list_pattern.2.diff Download (19.8 KB) - added by bricks 3 years ago.

Change History

comment:1 Changed 3 years ago by bricks

  • Owner changed from dgollub to bricks

comment:2 Changed 3 years ago by tuju

  • Cc tuju added

comment:3 Changed 3 years ago by tuju

  • Cc tuju removed

Changed 3 years ago by bricks

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:6 Changed 3 years ago by bricks

  • Milestone changed from OpenSync 0.40 to OpenSync 0.39

Changed 3 years ago by bricks

Changed 3 years ago by bricks

comment:7 Changed 3 years ago by bricks

(In [5383]) changed list pattern for all plugin related interfaces refs #975

comment:8 Changed 3 years ago by dgollub

(In [5403]) Ported file-sync plugin to OSyncPlugin list pattern API cleanup r5382

refs #975

comment:9 Changed 3 years ago by dgollub

(In [5404]) Fix build of osynctool. Replaced opensync-merger.h include with opensync-capabilities.h Ported OSyncPluginEnv API use to latest list interface pattern cleanup

refs #975

comment:10 Changed 3 years ago by bricks

(In [5417]) changed list pattern for all engine related interfaces refs #975

comment:11 Changed 3 years ago by bricks

(In [5421]) changed list pattern for all format related interfaces refs #975

comment:12 Changed 3 years ago by bricks

(In [5425]) changed list pattern for all group related interfaces refs #975

comment:13 Changed 3 years ago by bricks

(In [5429]) changed list pattern for all mapping related interfaces refs #975

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

(In [5448]) Ported osynctool to latest API-list-pattern redesign.

refs #975

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

comment:17 Changed 3 years ago by bricks

(In [5581]) return a copy of objformats instead of the original list spotted by Chris Frey refs #975

comment:18 Changed 3 years ago by bricks

(In [5582]) return a copy of advancedoption parameters refs #975

comment:19 Changed 3 years ago by bricks

(In [5583]) return a copy of plugin advancedoption valenums refs #975

comment:20 Changed 3 years ago by bricks

(In [5584]) return a copy of plugin advancedoption paramater valenums refs #975

comment:21 Changed 3 years ago by bricks

(In [5585]) return copy of plugin config advancedoption refs #975

Note: See TracTickets for help on using tickets.