qom: Introduce ObjectPropertyIterator struct for iteration
commita00c94824126901168bca5b89147f9e334a49e87
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 13 Oct 2015 12:37:40 +0000 (13 13:37 +0100)
committerAndreas Färber <afaerber@suse.de>
Wed, 18 Nov 2015 20:13:38 +0000 (18 21:13 +0100)
tree2ac521e8e942a8bd81bfd1254e0288be434da792
parent3b6ca4022d150ad273d4cd9556c2f4873389f965
qom: Introduce ObjectPropertyIterator struct for iteration

Some users of QOM need to be able to iterate over properties
defined against an object instance. Currently they are just
directly using the QTAIL macros against the object properties
data structure.

This is bad because it exposes them to changes in the data
structure used to store properties, as well as changes in
functionality such as ability to register properties against
the class.

This provides an ObjectPropertyIterator struct which will
insulate the callers from the particular data structure
used to store properties. It can be used thus

  ObjectProperty *prop;
  ObjectPropertyIterator *iter;

  iter = object_property_iter_init(obj);
  while ((prop = object_property_iter_next(iter))) {
      ... do something with prop ...
  }
  object_property_iter_free(iter);

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Tested-by: Pavel Fedin <p.fedin@samsung.com>
[AF: Fixed examples, style cleanups]
Signed-off-by: Andreas Färber <afaerber@suse.de>
include/qom/object.h
qom/object.c
tests/check-qom-proplist.c