summaryrefslogtreecommitdiffstats
path: root/src/client/BlockModel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/BlockModel.cpp')
-rw-r--r--src/client/BlockModel.cpp72
1 files changed, 40 insertions, 32 deletions
diff --git a/src/client/BlockModel.cpp b/src/client/BlockModel.cpp
index aa4ef663..beef0117 100644
--- a/src/client/BlockModel.cpp
+++ b/src/client/BlockModel.cpp
@@ -14,18 +14,23 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/client/BlockModel.hpp"
-
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/PluginModel.hpp"
-#include "ingen/client/PortModel.hpp"
-#include "lilv/lilv.h"
-#include "lv2/core/lv2.h"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
-
+#include <ingen/client/BlockModel.hpp>
+
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <ingen/client/PluginModel.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <lilv/lilv.h>
+#include <lv2/core/lv2.h>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
+
+#include <sigc++/signal.h>
+
+#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
@@ -34,8 +39,7 @@
#include <string>
#include <utility>
-namespace ingen {
-namespace client {
+namespace ingen::client {
BlockModel::BlockModel(URIs& uris,
const std::shared_ptr<PluginModel>& plugin,
@@ -75,23 +79,26 @@ BlockModel::~BlockModel()
void
BlockModel::remove_port(const std::shared_ptr<PortModel>& port)
{
- for (auto i = _ports.begin(); i != _ports.end(); ++i) {
- if ((*i) == port) {
- _ports.erase(i);
- break;
- }
+ const auto i = std::find_if(_ports.begin(),
+ _ports.end(),
+ [&port](const auto& p) { return p == port; });
+
+ if (i != _ports.end()) {
+ _ports.erase(i);
+ _signal_removed_port.emit(port);
}
- _signal_removed_port.emit(port);
}
void
BlockModel::remove_port(const raul::Path& port_path)
{
- for (auto i = _ports.begin(); i != _ports.end(); ++i) {
- if ((*i)->path() == port_path) {
- _ports.erase(i);
- break;
- }
+ const auto i =
+ std::find_if(_ports.begin(), _ports.end(), [&port_path](const auto& p) {
+ return p->path() == port_path;
+ });
+
+ if (i != _ports.end()) {
+ _ports.erase(i);
}
}
@@ -203,8 +210,9 @@ BlockModel::default_port_value_range(
}
if (port->port_property(_uris.lv2_sampleRate)) {
- min *= srate;
- max *= srate;
+ const auto frate = static_cast<float>(srate);
+ min *= frate;
+ max *= frate;
}
}
@@ -218,7 +226,7 @@ BlockModel::port_value_range(const std::shared_ptr<const PortModel>& port,
default_port_value_range(port, min, max);
- // Possibly overriden
+ // Possibly overridden
const Atom& min_atom = port->get_property(_uris.lv2_minimum);
const Atom& max_atom = port->get_property(_uris.lv2_maximum);
if (min_atom.type() == _uris.forge.Float) {
@@ -233,8 +241,9 @@ BlockModel::port_value_range(const std::shared_ptr<const PortModel>& port,
}
if (port->port_property(_uris.lv2_sampleRate)) {
- min *= srate;
- max *= srate;
+ const auto frate = static_cast<float>(srate);
+ min *= frate;
+ max *= frate;
}
}
@@ -292,5 +301,4 @@ BlockModel::set(const std::shared_ptr<ObjectModel>& model)
ObjectModel::set(model);
}
-} // namespace client
-} // namespace ingen
+} // namespace ingen::client