[beast: 12/49] BSE: bseapi.idl: introduce Item
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 12/49] BSE: bseapi.idl: introduce Item
- Date: Wed, 1 Jul 2015 11:30:06 +0000 (UTC)
commit b371d954a1d124060eabc5d4ff15b0f963589cd8
Author: Tim Janik <timj gnu org>
Date: Mon Jun 22 03:34:09 2015 +0200
BSE: bseapi.idl: introduce Item
bse/bseapi.idl | 19 ++++++++++++-------
bse/bseitem.cc | 20 ++++++++++++++++++++
bse/bseitem.hh | 13 +++++++++++++
bse/bseitem.proc | 26 --------------------------
bse/bseproject.cc | 2 +-
bse/bseproject.hh | 2 +-
6 files changed, 47 insertions(+), 35 deletions(-)
---
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index bfd91ac..8f8c88a 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -85,12 +85,6 @@ enum ErrorType {
ERROR_INVALID_OVERLAP = Enum (67, "Invalid overlap"),
};
-/// Basic object type for all BSE objects.
-interface Object {
- String debug_name (); ///< Object name useful for debugging output.
- int64 proxy_id (); ///< Retrieve the BseObject proxy ID for an Object.
-};
-
/// Object to carry out IDL, API, signal, etc tests.
interface TestObject {
int32 echo_test (String msg); ///< Echo custom message to stdout.
@@ -114,8 +108,19 @@ record UserMessage {
String label; ///< Message class label, used to enable/disable this type of message.
};
+/// Basic object type for all BSE objects.
+interface Object {
+ String debug_name (); ///< Object name useful for debugging output.
+ int64 proxy_id (); ///< Retrieve the BseObject proxy ID for an Object.
+};
+
+/// Base type for objects that can be added to a container.
+interface Item : Object {
+ Item common_ancestor (Item other); ///< Find a common container (parent or grand-parent) of two items
if any.
+};
+
/// Projects support loading, saving, playback and act as containers for all other sound objects.
-interface Project : Object {
+interface Project : Item {
void change_name (String name); ///< Change a project name without recording undo steps.
ErrorType play(); ///< Activate a project and start project playback (an already playing project is
first halted).
ErrorType activate(); ///< Activate a project, precondition to start playback.
diff --git a/bse/bseitem.cc b/bse/bseitem.cc
index 1c58d54..6ad6e10 100644
--- a/bse/bseitem.cc
+++ b/bse/bseitem.cc
@@ -1237,3 +1237,23 @@ bse_item_backup_to_undo (BseItem *self,
g_object_unref (storage);
}
}
+
+namespace Bse {
+
+ItemImpl::ItemImpl (BseObject *bobj) :
+ ObjectImpl (bobj)
+{}
+
+ItemImpl::~ItemImpl ()
+{}
+
+ItemIfaceP
+ItemImpl::common_ancestor (ItemIface &other)
+{
+ BseItem *self = as<BseItem*>();
+ BseItem *bo = other.as<BseItem*>();
+ BseItem *common = bse_item_common_ancestor (self, bo);
+ return common ? shared_ptr_cast<ItemIface> (common->as<ItemIface*>()) : ItemIfaceP();
+}
+
+} // Bse
diff --git a/bse/bseitem.hh b/bse/bseitem.hh
index f207d24..aefd423 100644
--- a/bse/bseitem.hh
+++ b/bse/bseitem.hh
@@ -147,4 +147,17 @@ BseMusicalTuningType bse_item_current_musical_tuning (BseItem *self);
G_END_DECLS
+namespace Bse {
+
+class ItemImpl : public ObjectImpl, public virtual ItemIface {
+ friend class FriendAllocator<ItemImpl>; // provide make_shared for non-public ctor
+protected:
+ virtual ~ItemImpl ();
+public:
+ explicit ItemImpl (BseObject*);
+ virtual ItemIfaceP common_ancestor (ItemIface &other) override;
+};
+
+} // Bse
+
#endif /* __BSE_ITEM_H__ */
diff --git a/bse/bseitem.proc b/bse/bseitem.proc
index 4dcfdd6..17e03e1 100644
--- a/bse/bseitem.proc
+++ b/bse/bseitem.proc
@@ -354,32 +354,6 @@ METHOD (BseItem, get-name-or-type) {
return BSE_ERROR_NONE;
}
-METHOD (BseItem, common-ancestor) {
- HELP = "Retrieve the common ancestor of two items if there's any.";
- IN = bse_param_spec_object ("item", "Item", "First item",
- BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
- IN = bse_param_spec_object ("item2", "Item2", "Second item",
- BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
- OUT = bse_param_spec_object ("ancestor", "ancestor", "Common ancestor of both items",
- BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
- const GValue *in_values,
- GValue *out_values)
-{
- /* extract parameter values */
- BseItem *item = (BseItem*) bse_value_get_object (in_values++);
- BseItem *item2 = (BseItem*) bse_value_get_object (in_values++);
-
- /* check parameters */
- if (!BSE_IS_ITEM (item) || !BSE_IS_ITEM (item2))
- return BSE_ERROR_PROC_PARAM_INVAL;
-
- /* set output parameters */
- bse_value_set_object (out_values++, bse_item_common_ancestor (item, item2));
-
- return BSE_ERROR_NONE;
-}
-
METHOD (BseItem, get-seqid) {
HELP = ("Retrieve an item's sequential ID. The sequential ID depends "
"on the item's type an it's position inbetween siblings "
diff --git a/bse/bseproject.cc b/bse/bseproject.cc
index adab3fe..09c9dd4 100644
--- a/bse/bseproject.cc
+++ b/bse/bseproject.cc
@@ -968,7 +968,7 @@ bse_project_deactivate (BseProject *self)
namespace Bse {
ProjectImpl::ProjectImpl (BseObject *bobj) :
- ObjectImpl (bobj)
+ ItemImpl (bobj)
{}
ProjectImpl::~ProjectImpl ()
diff --git a/bse/bseproject.hh b/bse/bseproject.hh
index 2384cba..8bb10cf 100644
--- a/bse/bseproject.hh
+++ b/bse/bseproject.hh
@@ -79,7 +79,7 @@ void bse_project_push_undo_silent_deactivate (BseProject *self);
namespace Bse {
-class ProjectImpl : public virtual ProjectIface, public virtual ObjectImpl {
+class ProjectImpl : public ItemImpl, public virtual ProjectIface {
friend class FriendAllocator<ProjectImpl>; // provide make_shared for non-public ctor
protected:
virtual ~ProjectImpl ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]