[beast: 3/26] BSE: move Container.list_children() into bseapi.idl



commit 32c6bf8c395facdd7ec194fc2e353edb5c65f1fe
Author: Tim Janik <timj gnu org>
Date:   Fri May 27 11:51:18 2016 +0200

    BSE: move Container.list_children() into bseapi.idl
    
    Signed-off-by: Tim Janik <timj gnu org>

 bse/Makefile.am       |    2 +-
 bse/bseapi.idl        |    6 ++++++
 bse/bsecontainer.cc   |   47 ++++++++++++++++++-----------------------------
 bse/bsecontainer.hh   |    2 +-
 bse/bsecontainer.proc |   32 --------------------------------
 5 files changed, 26 insertions(+), 63 deletions(-)
---
diff --git a/bse/Makefile.am b/bse/Makefile.am
index b6a445e..9d114bb 100644
--- a/bse/Makefile.am
+++ b/bse/Makefile.am
@@ -115,7 +115,7 @@ idl_dummy_files = $(strip   \
 )
 # BSE procedure sources
 bse_proc_sources = $(strip \
-       bsecategories.proc      bsecontainer.proc                               bseeditablesample.proc  \
+       bsecategories.proc      bseeditablesample.proc  \
        bsejanitor.proc                                                         bseproject.proc         \
                                bsesong.proc                                    bsesource.proc          \
                                bseitem.proc            bsewave.proc            bsewaveosc.proc         
bsewaverepo.proc \
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index ff70311..3236686 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -496,6 +496,11 @@ interface Item : Object {
   // int32 seqid = Range ("Sequential ID", "", ":readwrite", 0, MAXINT31, 1);
 };
 
+/// A list of part note events.
+sequence ItemSeq {
+  Item items;
+};
+
 /// Part specific note event representation.
 record PartNote
 {
@@ -615,6 +620,7 @@ interface ContextMerger : Source {
 interface Container : Source {
   Item lookup_item (String uname); ///< Find an immediate child of a container by name (unique per container 
child).
   Item get_item    (String item_type, int32 seq_id); ///< Retrieve the immediate child of type @a item_type 
by its sequential id (the 'nth' child).
+  ItemSeq list_children (); ///< List all immediate children of a container.
 };
 
 /// Base interface type for Item managers.
diff --git a/bse/bsecontainer.cc b/bse/bsecontainer.cc
index 1f5ac68..7405086 100644
--- a/bse/bsecontainer.cc
+++ b/bse/bsecontainer.cc
@@ -381,35 +381,6 @@ bse_container_forall_items (BseContainer      *container,
 }
 
 static gboolean
-list_items (BseItem *item,
-            gpointer data)
-{
-  BseIt3mSeq *iseq = (BseIt3mSeq*) data;
-
-  bse_it3m_seq_append (iseq, item);
-
-  return TRUE;
-}
-
-BseIt3mSeq*
-bse_container_list_children (BseContainer *container)
-{
-  BseIt3mSeq *iseq;
-
-  assert_return (BSE_IS_CONTAINER (container), NULL);
-
-  iseq = bse_it3m_seq_new ();
-  if (container->n_items)
-    {
-      assert_return (BSE_CONTAINER_GET_CLASS (container)->forall_items != NULL, NULL); /* paranoid */
-
-      BSE_CONTAINER_GET_CLASS (container)->forall_items (container, list_items, iseq);
-    }
-
-  return iseq;
-}
-
-static gboolean
 count_item_seqid (BseItem *item,
                   gpointer data_p)
 {
@@ -1369,4 +1340,22 @@ ContainerImpl::get_item (const String &item_type, int seq_id)
   return child->as<ItemIfaceP>();
 }
 
+static gboolean
+item_seq_add (BseItem *item, void *data)
+{
+  ItemSeq *iseq = (ItemSeq*) data;
+  iseq->push_back (item->as<ItemIfaceP>());
+  return TRUE;
+}
+
+ItemSeq
+ContainerImpl::list_children()
+{
+  BseContainer *self = as<BseContainer*>();
+  ItemSeq iseq;
+  if (self->n_items)
+    BSE_CONTAINER_GET_CLASS (self)->forall_items (self, item_seq_add, &iseq);
+  return iseq;
+}
+
 } // Bse
diff --git a/bse/bsecontainer.hh b/bse/bsecontainer.hh
index 2050f8e..0da2a65 100644
--- a/bse/bsecontainer.hh
+++ b/bse/bsecontainer.hh
@@ -48,7 +48,6 @@ struct BseContainerClass : BseSourceClass {
 void           bse_container_forall_items      (BseContainer   *container,
                                                 BseForallItemsFunc func,
                                                 gpointer        data);
-BseIt3mSeq*    bse_container_list_children     (BseContainer   *container);
 guint          bse_container_get_item_seqid    (BseContainer   *container,
                                                 BseItem        *item);
 BseItem*       bse_container_get_item          (BseContainer   *container,
@@ -112,6 +111,7 @@ public:
   explicit           ContainerImpl  (BseObject*);
   virtual ItemIfaceP lookup_item    (const String &uname) override;
   virtual ItemIfaceP get_item       (const String &item_type, int seq_id) override;
+  virtual ItemSeq    list_children  ();
 };
 
 } // Bse


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]