and finally, ref-ify all the range-fors
parent
042e13eefb
commit
5f1b9d03b4
|
@ -44,7 +44,7 @@ void Graph::saveData(QCborMap& m) const {
|
||||||
QCborArray c;
|
QCborArray c;
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (auto ch : children) {
|
for (auto& ch : children) {
|
||||||
if (!ch->plugin) continue;
|
if (!ch->plugin) continue;
|
||||||
indices[ch.get()] = idx++;
|
indices[ch.get()] = idx++;
|
||||||
c << ch->toCbor();
|
c << ch->toCbor();
|
||||||
|
@ -58,14 +58,14 @@ void Graph::saveData(QCborMap& m) const {
|
||||||
// array { oIdx, dataType, pIdx, iIdx, dataType, pIdx }
|
// array { oIdx, dataType, pIdx, iIdx, dataType, pIdx }
|
||||||
QCborArray cn;
|
QCborArray cn;
|
||||||
|
|
||||||
for (auto ch : children) {
|
for (auto& ch : children) {
|
||||||
if (!ch->plugin) continue; // already skipped over
|
if (!ch->plugin) continue; // already skipped over
|
||||||
int idx = indices[ch.get()];
|
int idx = indices[ch.get()];
|
||||||
for (auto dt : ch->outputs) {
|
for (auto& dt : ch->outputs) {
|
||||||
for (auto op : dt.second) {
|
for (auto& op : dt.second) {
|
||||||
auto o = op.second;
|
auto o = op.second;
|
||||||
o->cleanConnections(); // let's just do some groundskeeping here
|
o->cleanConnections(); // let's just do some groundskeeping here
|
||||||
for (auto iw : o->connections) {
|
for (auto& iw : o->connections) {
|
||||||
auto i = iw.lock();
|
auto i = iw.lock();
|
||||||
QCborArray c;
|
QCborArray c;
|
||||||
c << idx;
|
c << idx;
|
||||||
|
|
|
@ -48,7 +48,7 @@ bool Port::connect(std::shared_ptr<Port> p) {
|
||||||
// actual processing is always done on the input port, since that's where any limits are
|
// actual processing is always done on the input port, since that's where any limits are
|
||||||
if (type == Output) return p->type == Input && p->connect(shared_from_this());
|
if (type == Output) return p->type == Input && p->connect(shared_from_this());
|
||||||
if (!canConnectTo(p->dataType())) return false; // can't hook up to an incompatible data type
|
if (!canConnectTo(p->dataType())) return false; // can't hook up to an incompatible data type
|
||||||
for (auto c : connections) if (c.lock() == p) return true; // I guess report success if already connected?
|
for (auto& c : connections) if (c.lock() == p) return true; // I guess report success if already connected?
|
||||||
if (singleInput() && connections.size() > 0) return false; // reject multiple connections on single-input ports
|
if (singleInput() && connections.size() > 0) return false; // reject multiple connections on single-input ports
|
||||||
if (auto o = owner.lock(), po = p->owner.lock(); !o || !po || po->dependsOn(o)) return false; // no dependency loops!
|
if (auto o = owner.lock(), po = p->owner.lock(); !o || !po || po->dependsOn(o)) return false; // no dependency loops!
|
||||||
// actually hook up
|
// actually hook up
|
||||||
|
@ -118,7 +118,7 @@ QCborMap Node::multiToCbor(std::vector<std::shared_ptr<Node>>& v) {
|
||||||
{ /* nodes */ } {
|
{ /* nodes */ } {
|
||||||
QCborArray nm;
|
QCborArray nm;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (auto n : v) {
|
for (auto& n : v) {
|
||||||
if (n->isVolatile()) continue; // skip things with volatile locality (i/o ports etc.)
|
if (n->isVolatile()) continue; // skip things with volatile locality (i/o ports etc.)
|
||||||
indices[n.get()] = idx++;
|
indices[n.get()] = idx++;
|
||||||
nm << n->toCbor();
|
nm << n->toCbor();
|
||||||
|
@ -129,21 +129,21 @@ QCborMap Node::multiToCbor(std::vector<std::shared_ptr<Node>>& v) {
|
||||||
// exported samples
|
// exported samples
|
||||||
if (auto v = Sample::finishExport(); !v.empty()) {
|
if (auto v = Sample::finishExport(); !v.empty()) {
|
||||||
QCborMap smp;
|
QCborMap smp;
|
||||||
for (auto s : v) smp[QCborValue(s->uuid)] = s->toCbor();
|
for (auto& s : v) smp[QCborValue(s->uuid)] = s->toCbor();
|
||||||
m[qs("samples")] = smp;
|
m[qs("samples")] = smp;
|
||||||
}
|
}
|
||||||
|
|
||||||
{ /* connections */ } {
|
{ /* connections */ } {
|
||||||
QCborArray cm;
|
QCborArray cm;
|
||||||
|
|
||||||
for (auto n : v) {
|
for (auto& n : v) {
|
||||||
if (n->isVolatile()) continue; // already skipped
|
if (n->isVolatile()) continue; // already skipped
|
||||||
int idx = indices[n.get()];
|
int idx = indices[n.get()];
|
||||||
for (auto dt : n->outputs) {
|
for (auto& dt : n->outputs) {
|
||||||
for (auto op : dt.second) {
|
for (auto& op : dt.second) {
|
||||||
auto o = op.second;
|
auto o = op.second;
|
||||||
o->cleanConnections(); // let's just do some groundskeeping here
|
o->cleanConnections(); // let's just do some groundskeeping here
|
||||||
for (auto iw : o->connections) {
|
for (auto& iw : o->connections) {
|
||||||
auto i = iw.lock();
|
auto i = iw.lock();
|
||||||
if (auto in = indices.find(i->owner.lock().get()); in != indices.end()) { // only connections within the collection
|
if (auto in = indices.find(i->owner.lock().get()); in != indices.end()) { // only connections within the collection
|
||||||
QCborArray c;
|
QCborArray c;
|
||||||
|
@ -166,7 +166,7 @@ QCborMap Node::multiToCbor(std::vector<std::shared_ptr<Node>>& v) {
|
||||||
{ /* center */ } {
|
{ /* center */ } {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
QPoint center;
|
QPoint center;
|
||||||
for (auto n : v) {
|
for (auto& n : v) {
|
||||||
if (n->isVolatile()) continue;
|
if (n->isVolatile()) continue;
|
||||||
center += QPoint(n->x, n->y);
|
center += QPoint(n->x, n->y);
|
||||||
count++;
|
count++;
|
||||||
|
@ -227,7 +227,7 @@ std::vector<std::shared_ptr<Node>> Node::multiFromCbor(const QCborMap& m, std::s
|
||||||
|
|
||||||
if (!cp.isNull()) { // offset and such
|
if (!cp.isNull()) { // offset and such
|
||||||
QPoint off = cp - center;
|
QPoint off = cp - center;
|
||||||
for (auto n : v) {
|
for (auto& n : v) {
|
||||||
n->x += off.x();
|
n->x += off.x();
|
||||||
n->y += off.y();
|
n->y += off.y();
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ void Node::collapsePorts(Port::Type t, Port::DataType dt) {
|
||||||
if (mdt == m.end()) return; // nothing there
|
if (mdt == m.end()) return; // nothing there
|
||||||
auto& mm = mdt->second;
|
auto& mm = mdt->second;
|
||||||
uint8_t maxIdx = 0;
|
uint8_t maxIdx = 0;
|
||||||
for (auto p : mm) maxIdx = std::max(maxIdx, p.first);
|
for (auto& p : mm) maxIdx = std::max(maxIdx, p.first);
|
||||||
uint8_t firstUnused = 255;
|
uint8_t firstUnused = 255;
|
||||||
for (uint8_t i = 0; i <= maxIdx; i++) {
|
for (uint8_t i = 0; i <= maxIdx; i++) {
|
||||||
if (auto pi = mm.find(i); pi != mm.end()) {
|
if (auto pi = mm.find(i); pi != mm.end()) {
|
||||||
|
@ -347,7 +347,7 @@ bool Node::try_process(bool checkDependencies) {
|
||||||
|
|
||||||
if (checkDependencies) { // check if dependencies are done
|
if (checkDependencies) { // check if dependencies are done
|
||||||
auto checkInput = Util::yCombinator([tick_this](auto checkInput, std::shared_ptr<Port> p) -> bool {
|
auto checkInput = Util::yCombinator([tick_this](auto checkInput, std::shared_ptr<Port> p) -> bool {
|
||||||
for (auto c : p->connections) { // check each connection; if node valid...
|
for (auto& c : p->connections) { // check each connection; if node valid...
|
||||||
if (auto cp = c.lock(); cp) {
|
if (auto cp = c.lock(); cp) {
|
||||||
if (auto n = cp->owner.lock(); n) {
|
if (auto n = cp->owner.lock(); n) {
|
||||||
if (n->tick_last != tick_this) return false; // if node itself not yet processed, check failed
|
if (n->tick_last != tick_this) return false; // if node itself not yet processed, check failed
|
||||||
|
@ -363,7 +363,7 @@ bool Node::try_process(bool checkDependencies) {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
for (auto t : inputs) for (auto p : t.second) if (!checkInput(p.second)) return false;
|
for (auto& t : inputs) for (auto& p : t.second) if (!checkInput(p.second)) return false;
|
||||||
|
|
||||||
/*for (auto& t : inputs) {
|
/*for (auto& t : inputs) {
|
||||||
for (auto& p : t.second) {
|
for (auto& p : t.second) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ void AudioPort::pull() {
|
||||||
bufR = &bufL[ts]; // for some reason just adding the size wonks out
|
bufR = &bufL[ts]; // for some reason just adding the size wonks out
|
||||||
memset(bufL, 0, s*2); // clear buffers
|
memset(bufL, 0, s*2); // clear buffers
|
||||||
|
|
||||||
for (auto c : connections) { // mix
|
for (auto& c : connections) { // mix
|
||||||
if (auto p = std::static_pointer_cast<AudioPort>(c.lock()); p && p->dataType() == Audio) {
|
if (auto p = std::static_pointer_cast<AudioPort>(c.lock()); p && p->dataType() == Audio) {
|
||||||
p->pull();
|
p->pull();
|
||||||
for (size_t i = 0; i < ts; i++) {
|
for (size_t i = 0; i < ts; i++) {
|
||||||
|
@ -62,7 +62,7 @@ void CommandPort::pull() {
|
||||||
|
|
||||||
size = 0;
|
size = 0;
|
||||||
if (type == Input) {
|
if (type == Input) {
|
||||||
for (auto c : connections) {
|
for (auto& c : connections) {
|
||||||
if (auto p = std::static_pointer_cast<CommandPort>(c.lock()); p && p->dataType() == Command) {
|
if (auto p = std::static_pointer_cast<CommandPort>(c.lock()); p && p->dataType() == Command) {
|
||||||
p->pull();
|
p->pull();
|
||||||
data = p->data; // just repoint to input's buffer
|
data = p->data; // just repoint to input's buffer
|
||||||
|
|
|
@ -138,7 +138,7 @@ void SampleSelectorGadget::mousePressEvent(QGraphicsSceneMouseEvent* e) {
|
||||||
m->addAction("(no sample)", this, [this] { setSample(nullptr); });
|
m->addAction("(no sample)", this, [this] { setSample(nullptr); });
|
||||||
m->addSeparator();
|
m->addSeparator();
|
||||||
DirectoryNode root;
|
DirectoryNode root;
|
||||||
for (auto s : qAsConst(project->samples)) root.placeData(s->name, s->uuid);
|
for (auto& s : qAsConst(project->samples)) root.placeData(s->name, s->uuid);
|
||||||
root.sortTree();
|
root.sortTree();
|
||||||
|
|
||||||
buildSubmenu(&root, m);
|
buildSubmenu(&root, m);
|
||||||
|
|
|
@ -57,7 +57,7 @@ void SelectorGadget::mousePressEvent(QGraphicsSceneMouseEvent* e) {
|
||||||
std::vector<Entry> v = fGetList ? fGetList() : std::vector<Entry>();
|
std::vector<Entry> v = fGetList ? fGetList() : std::vector<Entry>();
|
||||||
if (v.empty()) m->addAction("(no entries)")->setDisabled(true);
|
if (v.empty()) m->addAction("(no entries)")->setDisabled(true);
|
||||||
else {
|
else {
|
||||||
for (auto e : v) {
|
for (auto& e : v) {
|
||||||
if (_entry.first == e.first) {
|
if (_entry.first == e.first) {
|
||||||
m->addAction(e.second)->setDisabled(true);
|
m->addAction(e.second)->setDisabled(true);
|
||||||
} else m->addAction(e.second, this, [this, e] {
|
} else m->addAction(e.second, this, [this, e] {
|
||||||
|
|
|
@ -115,7 +115,7 @@ PatchboardScene::PatchboardScene(QGraphicsView* parent, const std::shared_ptr<Xy
|
||||||
auto v = Node::multiFromCbor(QCborValue::fromCbor(data->data("xybrid-internal/x-graph-copy")), graph, center);
|
auto v = Node::multiFromCbor(QCborValue::fromCbor(data->data("xybrid-internal/x-graph-copy")), graph, center);
|
||||||
|
|
||||||
setSelectionArea(QPainterPath()); // deselect all
|
setSelectionArea(QPainterPath()); // deselect all
|
||||||
for (auto n : v) { // and select pasted objects
|
for (auto& n : v) { // and select pasted objects
|
||||||
auto o = new NodeObject(n);
|
auto o = new NodeObject(n);
|
||||||
addItem(o);
|
addItem(o);
|
||||||
o->setSelected(true);
|
o->setSelected(true);
|
||||||
|
@ -225,7 +225,7 @@ void PatchboardScene::refresh() {
|
||||||
// build scene from graph
|
// build scene from graph
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
for (auto n : graph->children) {
|
for (auto& n : graph->children) {
|
||||||
auto* o = new NodeObject(n);
|
auto* o = new NodeObject(n);
|
||||||
addItem(o);
|
addItem(o);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ void SampleListModel::refresh() {
|
||||||
root = std::make_shared<DirectoryNode>();
|
root = std::make_shared<DirectoryNode>();
|
||||||
auto* project = window->getProject().get();
|
auto* project = window->getProject().get();
|
||||||
if (!project) return;
|
if (!project) return;
|
||||||
for (auto s : qAsConst(project->samples)) root->placeData(s->name, s->uuid);
|
for (auto& s : qAsConst(project->samples)) root->placeData(s->name, s->uuid);
|
||||||
root->sortTree();
|
root->sortTree();
|
||||||
|
|
||||||
view->setCurrentIndex(QModelIndex());
|
view->setCurrentIndex(QModelIndex());
|
||||||
|
@ -237,7 +237,7 @@ bool SampleListModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||||
|
|
||||||
QList<QUrl> urls = data->urls();
|
QList<QUrl> urls = data->urls();
|
||||||
bool success = false;
|
bool success = false;
|
||||||
for (auto u : urls) {
|
for (auto& u : urls) {
|
||||||
if (!u.isLocalFile()) continue;
|
if (!u.isLocalFile()) continue;
|
||||||
auto smp = Sample::fromFile(u.toLocalFile());
|
auto smp = Sample::fromFile(u.toLocalFile());
|
||||||
if (smp) { // valid sample returned
|
if (smp) { // valid sample returned
|
||||||
|
|
Loading…
Reference in New Issue