From 671f6b557aceba0ffa82b0107e692e2a667b0965 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 13 Aug 2008 19:14:47 +0000 Subject: Move crap (now) only used internally by deprecated loader to DeprecatedLoader.cpp. git-svn-id: http://svn.drobilla.net/lad/ingen@1352 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/DeprecatedLoader.cpp | 60 +++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) (limited to 'src/libs/client/DeprecatedLoader.cpp') diff --git a/src/libs/client/DeprecatedLoader.cpp b/src/libs/client/DeprecatedLoader.cpp index e5179fa0..d064830b 100644 --- a/src/libs/client/DeprecatedLoader.cpp +++ b/src/libs/client/DeprecatedLoader.cpp @@ -35,7 +35,6 @@ #include "NodeModel.hpp" #include "ConnectionModel.hpp" #include "PortModel.hpp" -#include "PresetModel.hpp" #include "PluginModel.hpp" #include "DeprecatedLoader.hpp" @@ -44,6 +43,65 @@ using namespace std; namespace Ingen { namespace Client { + +/** A single port's control setting (in a preset). + * + * \ingroup IngenClient + */ +class ControlModel +{ +public: + ControlModel(const Path& port_path, float value) + : _port_path(port_path) + , _value(value) + { + assert(_port_path.find("//") == string::npos); + } + + const Path& port_path() const { return _port_path; } + void port_path(const string& p) { _port_path = p; } + float value() const { return _value; } + void value(float v) { _value = v; } + +private: + Path _port_path; + float _value; +}; + + +/** Model of a preset (a collection of control settings). + * + * \ingroup IngenClient + */ +class PresetModel +{ +public: + PresetModel(const string& base_path) : _base_path(base_path) {} + + /** Add a control value to this preset. An empty string for a node_name + * means the port is on the patch itself (not a node in the patch). */ + void add_control(const string& node_name, string port_name, float value) { + if (port_name == "note_number") // FIXME: filthy kludge + port_name = "note"; + + if (node_name != "") + _controls.push_back(ControlModel(_base_path + node_name +"/"+ port_name, value)); + else + _controls.push_back(ControlModel(_base_path + port_name, value)); + } + + const string& name() const { return _name; } + void name(const string& n) { _name = n; } + + const list& controls() const { return _controls; } + +private: + string _name; + string _base_path; + list _controls; +}; + + string DeprecatedLoader::nameify_if_invalid(const string& name) { -- cgit v1.2.1