From 6f93b3d7c80f9dee2d95fac1bbc4f781a6f45979 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 18 Sep 2006 06:24:53 +0000 Subject: Work on loading old (deprecated) patches. More error tolerance in Store, related bugfixes. Patch port adding (threading) bug fixed (made event blocking). Better PatchView cacheing. Moved generic things from engine to util (shared) Bug fixes, features, etc. git-svn-id: http://svn.drobilla.net/lad/ingen@142 a436a847-0d15-0410-975c-d299462d15a1 --- src/progs/ingenuity/Loader.h | 120 ++++++++----------------------------------- 1 file changed, 22 insertions(+), 98 deletions(-) (limited to 'src/progs/ingenuity/Loader.h') diff --git a/src/progs/ingenuity/Loader.h b/src/progs/ingenuity/Loader.h index 58c301af..a33945a1 100644 --- a/src/progs/ingenuity/Loader.h +++ b/src/progs/ingenuity/Loader.h @@ -19,97 +19,23 @@ #include #include +#include "util/Thread.h" +#include "util/Slave.h" +#include "util/Mutex.h" +#include "util/Condition.h" #include "ModelEngineInterface.h" +#include "ObjectModel.h" using std::string; namespace Ingen { namespace Client { class PatchLibrarian; class PatchModel; - class ModelEngineInterface; } } using namespace Ingen::Client; namespace Ingenuity { -/** Event to run in the Loader thread. - * - * \ingroup Ingenuity - */ -class LoaderEvent -{ -public: - virtual void execute() = 0; - virtual ~LoaderEvent() {} -protected: - LoaderEvent() {} -}; - - -/** Loader thread patch loading event. - * - * \ingroup Ingenuity - */ -class LoadPatchEvent : public LoaderEvent -{ -public: - LoadPatchEvent(PatchLibrarian* pl, CountedPtr model, bool wait, bool merge) - : m_patch_librarian(pl), m_patch_model(model), m_wait(wait), m_merge(merge) {} - virtual ~LoadPatchEvent() {} - void execute(); -private: - PatchLibrarian* m_patch_librarian; - CountedPtr m_patch_model; - bool m_wait; - bool m_merge; -}; - - -/** Loader thread patch loading event. - * - * \ingroup Ingenuity - */ -class SavePatchEvent : public LoaderEvent -{ -public: - SavePatchEvent(PatchLibrarian* pl, CountedPtr pm, const string& filename, bool recursive) - : m_patch_librarian(pl), m_patch_model(pm), m_filename(filename), m_recursive(recursive) {} - virtual ~SavePatchEvent() {} - void execute(); -private: - PatchLibrarian* m_patch_librarian; - CountedPtr m_patch_model; - string m_filename; - bool m_recursive; -}; - -/* -class LoadSessionEvent : public LoaderEvent -{ -public: - LoadSessionEvent(PatchLibrarian* pl, const string& filename) - : m_patch_librarian(pl), m_filename(filename) {} - virtual ~LoadSessionEvent() {} - void execute(); -private: - PatchLibrarian* m_patch_librarian; - string m_filename; -}; - - -class SaveSessionEvent : public LoaderEvent -{ -public: - SaveSessionEvent(PatchLibrarian* pl, const string& filename) - : m_patch_librarian(pl), m_filename(filename) {} - virtual ~SaveSessionEvent() {} - void execute(); -private: - PatchLibrarian* m_patch_librarian; - string m_filename; -}; -*/ - /** Thread for loading patch files. * * This is a seperate thread so it can send all the loading message without @@ -118,37 +44,35 @@ private: * * \ingroup Ingenuity */ -class Loader +class Loader : public Slave { public: Loader(CountedPtr engine); ~Loader(); - PatchLibrarian& librarian() { return *m_patch_librarian; } + PatchLibrarian& librarian() { return *_patch_librarian; } - void launch(); - void exit() { m_thread_exit_flag = true; } + void load_patch(const string& filename, + const string& parent_path, + const string& name, + size_t poly, + const MetadataMap& initial_data, + bool merge = false); - void load_patch(CountedPtr model, bool wait, bool merge); void save_patch(CountedPtr model, const string& filename, bool recursive); - - //void load_session(const string& filename); - //void save_session(const string& filename); - - static void* thread_function(void* me); + private: - void* m_thread_function(void*); - - void set_event(LoaderEvent* ev); - PatchLibrarian* const m_patch_librarian; - LoaderEvent* m_event; - bool m_thread_exit_flag; - pthread_t m_thread; - pthread_mutex_t m_mutex; - pthread_cond_t m_cond; + /** Returns nothing and takes no parameters (because they have all been bound) */ + typedef sigc::slot Closure; + + void _whipped(); + PatchLibrarian* const _patch_librarian; + Mutex _mutex; + Condition _cond; + Closure _event; }; -- cgit v1.2.1