[beast: 24/26] BSE: migrate all Project methods into bseapi.idl
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 24/26] BSE: migrate all Project methods into bseapi.idl
- Date: Fri, 14 Oct 2016 15:50:00 +0000 (UTC)
commit a7a4a105815df18529fc4d81e0e6bae61b1329e9
Author: Tim Janik <timj gnu org>
Date: Tue May 31 16:11:15 2016 +0200
BSE: migrate all Project methods into bseapi.idl
Signed-off-by: Tim Janik <timj gnu org>
bse/Makefile.am | 2 +-
bse/bseapi.idl | 14 ++--
bse/bseproject.cc | 120 +++++++++++++++++++++++-
bse/bseproject.hh | 7 ++
bse/bseproject.proc | 259 ---------------------------------------------------
5 files changed, 134 insertions(+), 268 deletions(-)
---
diff --git a/bse/Makefile.am b/bse/Makefile.am
index 95e249b..994ed58 100644
--- a/bse/Makefile.am
+++ b/bse/Makefile.am
@@ -116,7 +116,7 @@ idl_dummy_files = $(strip \
# BSE procedure sources
bse_proc_sources = $(strip \
bseeditablesample.proc \
- bsejanitor.proc bseproject.proc \
+ bsejanitor.proc \
bsesource.proc \
bseitem.proc bsewaveosc.proc \
)
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index 68edcc6..0379f34 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -850,13 +850,13 @@ interface Project : Container {
void clean_dirty (); ///< Clear a project's dirty flags.
bool is_dirty (); ///< Check whether a project needs saving.
SuperSeq get_supers (); ///< Retrieve all Super type objects of this project.
- //Error store_bse (Super super, String file_name, bool self_contained);
- //Song create_song (String name); ///< Create a song for this project.
- //WaveRepo get_wave_repo (); ///< Retrieve the project's unique wave repository.
- //CSynth create_csynth (String name); ///< Create a synthsizer network for this project.
- //MidiSynth create_midi_synth (String name); ///< Create a MIDI synthesizer network for this project.
- //MidiNotifier get_midi_notifier (); ///< Retrieve the project's midi notifier object.
- //void remove_snet (SNet snet); ///< Remove an existing synthesizer network from this
project.
+ Error store_bse (Super super, String file_name, bool self_contained);
+ Song create_song (String name); ///< Create a song for this project.
+ WaveRepo get_wave_repo (); ///< Retrieve the project's unique wave repository.
+ CSynth create_csynth (String name); ///< Create a synthsizer network for this project.
+ MidiSynth create_midi_synth (String name); ///< Create a MIDI synthesizer network for this project.
+ MidiNotifier get_midi_notifier (); ///< Retrieve the project's midi notifier object.
+ void remove_snet (SNet snet); ///< Remove an existing synthesizer network from this
project.
Error restore_from_file (String file_name); ///< Load a project from file.
/// Inject a MIDI control event into the project's MIDI receiver.
void inject_midi_control (int32 midi_channel, int32 midi_control, float64 control_value);
diff --git a/bse/bseproject.cc b/bse/bseproject.cc
index b102bbe..ef9d37f 100644
--- a/bse/bseproject.cc
+++ b/bse/bseproject.cc
@@ -1,6 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseproject.hh"
-
+#include "bsemidisynth.hh"
#include "bsesuper.hh"
#include "bsestorage.hh"
#include "bsesong.hh"
@@ -1191,4 +1191,122 @@ ProjectImpl::get_supers ()
return sseq;
}
+void
+ProjectImpl::remove_snet (SNetIface &snet_iface)
+{
+ BseProject *self = as<BseProject*>();
+ SNetImpl &snet = dynamic_cast<SNetImpl&> (snet_iface);
+ assert_return (snet.parent() == this);
+ return_unless (BSE_SOURCE_PREPARED (self) == false);
+ BseItem *child = snet.as<BseItem*>();
+ BseUndoStack *ustack = bse_item_undo_open (self, __func__);
+ // backup object references to undo stack
+ bse_container_uncross_undoable (BSE_CONTAINER (self), child);
+ // implement "undo" of bse_container_remove_backedup, i.e. redo
+ UndoDescriptor<SNetImpl> snet_descriptor = undo_descriptor (snet);
+ auto lambda = [snet_descriptor] (ProjectImpl &self, BseUndoStack *ustack) -> Error {
+ SNetImpl &snet = self.undo_resolve (snet_descriptor);
+ self.remove_snet (snet);
+ return Error::NONE;
+ };
+ push_undo_to_redo (__func__, *this, lambda);
+ // backup and remove (without redo queueing)
+ bse_container_remove_backedup (BSE_CONTAINER (self), child, ustack);
+ // done
+ bse_item_undo_close (ustack);
+}
+
+Error
+ProjectImpl::store_bse (SuperIface &super_iface, const String &file_name, bool self_contained)
+{
+ BseProject *self = as<BseProject*>();
+ SuperImpl *super = dynamic_cast<SuperImpl*> (&super_iface);
+ BseSuper *bsesuper = super ? super->as<BseSuper*>() : NULL;
+ if (super)
+ assert_return (super->parent() == this, Error::INTERNAL);
+ return bse_project_store_bse (self, bsesuper, file_name.c_str(), self_contained);
+}
+
+SongIfaceP
+ProjectImpl::create_song (const String &name)
+{
+ BseProject *self = as<BseProject*>();
+ BseUndoStack *ustack = bse_item_undo_open (self, __func__);
+ BseSong *song = (BseSong*) bse_container_new_child (self, BSE_TYPE_SONG, NULL);
+ if (song)
+ {
+ if (!name.empty())
+ bse_item_set (song, "uname", name.c_str(), NULL);
+ UndoDescriptor<SongImpl> song_descriptor = undo_descriptor (*song->as<SongImpl*>());
+ auto remove_song_lambda = [song_descriptor] (ProjectImpl &self, BseUndoStack *ustack) -> Error {
+ SongImpl &song = self.undo_resolve (song_descriptor);
+ self.remove_snet (song);
+ return Error::NONE;
+ };
+ push_undo (__func__, *this, remove_song_lambda);
+ }
+ bse_item_undo_close (ustack);
+ return song->as<SongIfaceP>();
+}
+
+CSynthIfaceP
+ProjectImpl::create_csynth (const String &name)
+{
+ BseProject *self = as<BseProject*>();
+ BseUndoStack *ustack = bse_item_undo_open (self, __func__);
+ BseCSynth *csynth = (BseCSynth*) bse_container_new_child (self, BSE_TYPE_CSYNTH, NULL);
+ if (csynth)
+ {
+ if (!name.empty())
+ bse_item_set (csynth, "uname", name.c_str(), NULL);
+ UndoDescriptor<CSynthImpl> csynth_descriptor = undo_descriptor (*csynth->as<CSynthImpl*>());
+ auto remove_csynth_lambda = [csynth_descriptor] (ProjectImpl &self, BseUndoStack *ustack) -> Error {
+ CSynthImpl &csynth = self.undo_resolve (csynth_descriptor);
+ self.remove_snet (csynth);
+ return Error::NONE;
+ };
+ push_undo (__func__, *this, remove_csynth_lambda);
+ }
+ bse_item_undo_close (ustack);
+ return csynth->as<CSynthIfaceP>();
+}
+
+MidiSynthIfaceP
+ProjectImpl::create_midi_synth (const String &name)
+{
+ BseProject *self = as<BseProject*>();
+ BseUndoStack *ustack = bse_item_undo_open (self, __func__);
+ BseMidiSynth *midi_synth = (BseMidiSynth*) bse_container_new_child (self, BSE_TYPE_MIDI_SYNTH, NULL);
+ if (midi_synth)
+ {
+ if (!name.empty())
+ bse_item_set (midi_synth, "uname", name.c_str(), NULL);
+ UndoDescriptor<MidiSynthImpl> midi_synth_descriptor = undo_descriptor
(*midi_synth->as<MidiSynthImpl*>());
+ auto remove_midi_synth_lambda = [midi_synth_descriptor] (ProjectImpl &self, BseUndoStack *ustack) ->
Error {
+ MidiSynthImpl &midi_synth = self.undo_resolve (midi_synth_descriptor);
+ self.remove_snet (midi_synth);
+ return Error::NONE;
+ };
+ push_undo (__func__, *this, remove_midi_synth_lambda);
+ }
+ bse_item_undo_close (ustack);
+ return midi_synth->as<MidiSynthIfaceP>();
+}
+
+WaveRepoIfaceP
+ProjectImpl::get_wave_repo ()
+{
+ BseProject *self = as<BseProject*>();
+ BseWaveRepo *wrepo = bse_project_get_wave_repo (self);
+ return wrepo ? wrepo->as<WaveRepoIfaceP>() : NULL;
+}
+
+MidiNotifierIfaceP
+ProjectImpl::get_midi_notifier ()
+{
+ BseProject *self = as<BseProject*>();
+ BseMidiNotifier *notifier = bse_project_get_midi_notifier (self);
+ return notifier ? notifier->as<MidiNotifierIfaceP>() : NULL;
+}
+
} // Bse
diff --git a/bse/bseproject.hh b/bse/bseproject.hh
index 1147b1c..2d6aa28 100644
--- a/bse/bseproject.hh
+++ b/bse/bseproject.hh
@@ -98,6 +98,13 @@ public:
virtual Error restore_from_file (const String &file_name) override;
virtual ProjectState get_state () override;
virtual SuperSeq get_supers () override;
+ virtual Error store_bse (SuperIface &super, const String &file_name, bool
self_contained) override;
+ virtual SongIfaceP create_song (const String &name) override;
+ virtual WaveRepoIfaceP get_wave_repo () override;
+ virtual CSynthIfaceP create_csynth (const String &name) override;
+ virtual MidiSynthIfaceP create_midi_synth (const String &name) override;
+ virtual MidiNotifierIfaceP get_midi_notifier () override;
+ virtual void remove_snet (SNetIface &snet) override;
};
} // Bse
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]