diff options
author | David Robillard <d@drobilla.net> | 2006-09-13 06:11:25 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-09-13 06:11:25 +0000 |
commit | e5675ebfeb93175e16762d0a078bd51d15d05f63 (patch) | |
tree | 189249ed9014e4c482cfaed0d6af28ced68570ca /src/libs/client/ObjectModel.h | |
parent | 23b7568ab7a87a79c186b8ddf3d3db4f1f934b06 (diff) | |
download | ingen-e5675ebfeb93175e16762d0a078bd51d15d05f63.tar.gz ingen-e5675ebfeb93175e16762d0a078bd51d15d05f63.tar.bz2 ingen-e5675ebfeb93175e16762d0a078bd51d15d05f63.zip |
Heavy-duty redesign of client library and GUI (now fully signal driven with clean Model/View separation).
Smarter, centralized window creation/management (should make window unification easy (panes?)).
Typed metadata system, no more fugly string conversion of floats. Supports OSC fundamental
types string, int, float, blob for now (though blob isn't working over the wire yet).
git-svn-id: http://svn.drobilla.net/lad/ingen@131 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client/ObjectModel.h')
-rw-r--r-- | src/libs/client/ObjectModel.h | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/src/libs/client/ObjectModel.h b/src/libs/client/ObjectModel.h index da3764d1..79d551f5 100644 --- a/src/libs/client/ObjectModel.h +++ b/src/libs/client/ObjectModel.h @@ -24,59 +24,66 @@ #include <algorithm> #include <cassert> #include <sigc++/sigc++.h> +#include "util/Atom.h" #include "util/Path.h" #include "util/CountedPtr.h" -#include "ObjectController.h" using std::string; using std::map; using std::find; using std::cout; using std::cerr; using std::endl; namespace Ingen { namespace Client { -class ObjectController; +typedef map<string, Atom> MetadataMap; + - /** Base class for all GraphObject models (NodeModel, PatchModel, PortModel). * + * There are no non-const public methods intentionally, models are not allowed + * to be manipulated directly by anything (but the Store) because of the + * asynchronous nature of engine control. To change something, use the + * controller (which the model probably shouldn't have a reference to but oh + * well, it reduces Collection Hell) and wait for the result (as a signal + * from this Model). + * * \ingroup IngenClient */ class ObjectModel { public: ObjectModel(const Path& path); - ObjectModel() : m_path("/UNINITIALIZED") {} // FIXME: remove virtual ~ObjectModel(); - - const map<string, string>& metadata() const { return m_metadata; } - string get_metadata(const string& key) const; - void set_metadata(const string& key, const string& value) - { assert(value.length() > 0); m_metadata[key] = value; metadata_update_sig.emit(key, value); } - - inline const Path& path() const { return m_path; } - virtual void set_path(const Path& p) { m_path = p; } - - CountedPtr<ObjectModel> parent() const { return m_parent; } - virtual void set_parent(CountedPtr<ObjectModel> p) { m_parent = p; } - - virtual void add_child(CountedPtr<ObjectModel> c) = 0; - virtual void remove_child(CountedPtr<ObjectModel> c) = 0; - CountedPtr<ObjectController> controller() const { return m_controller; } - - void set_controller(CountedPtr<ObjectController> c); + const Atom& get_metadata(const string& key) const; + void add_metadata(const MetadataMap& data); + + const MetadataMap& metadata() const { return _metadata; } + inline const Path& path() const { return _path; } + CountedPtr<ObjectModel> parent() const { return _parent; } void assimilate(CountedPtr<ObjectModel> model); // Signals - sigc::signal<void, const string&, const string&> metadata_update_sig; - sigc::signal<void> destroyed_sig; + sigc::signal<void, const string&, const Atom&> metadata_update_sig; + sigc::signal<void> destroyed_sig; + + // FIXME: make private + void set_metadata(const string& key, const Atom& value) + { _metadata[key] = value; metadata_update_sig.emit(key, value); } + + protected: - Path m_path; - CountedPtr<ObjectModel> m_parent; - CountedPtr<ObjectController> m_controller; + friend class Store; + friend class PatchLibrarian; // FIXME: remove + virtual void set_path(const Path& p) { _path = p; } + virtual void set_parent(CountedPtr<ObjectModel> p) { _parent = p; } + virtual void add_child(CountedPtr<ObjectModel> c) = 0; + virtual void remove_child(CountedPtr<ObjectModel> c) = 0; + + Path _path; + CountedPtr<ObjectModel> _parent; - map<string,string> m_metadata; + MetadataMap _metadata; private: // Prevent copies (undefined) |