summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-01-11 05:40:18 +0000
committerDavid Robillard <d@drobilla.net>2013-01-11 05:40:18 +0000
commitd443ddb053141510311e002c59746a2dd9ba8b16 (patch)
tree6bbe7b6532824117dc9a1ca25d7a09ef3601c2cc /src/server
parent10e9a3a800a35916872abf9e354be4c554338e4e (diff)
downloadingen-d443ddb053141510311e002c59746a2dd9ba8b16.tar.gz
ingen-d443ddb053141510311e002c59746a2dd9ba8b16.tar.bz2
ingen-d443ddb053141510311e002c59746a2dd9ba8b16.zip
Use range-based for loops where possible.
Mmm, shiny. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4919 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server')
-rw-r--r--src/server/BlockFactory.cpp8
-rw-r--r--src/server/Broadcaster.cpp8
-rw-r--r--src/server/Broadcaster.hpp4
-rw-r--r--src/server/CompiledGraph.hpp8
-rw-r--r--src/server/Engine.cpp10
-rw-r--r--src/server/GraphImpl.cpp55
-rw-r--r--src/server/InputPort.cpp4
-rw-r--r--src/server/JackDriver.cpp22
-rw-r--r--src/server/events/CreateBlock.cpp4
-rw-r--r--src/server/events/Delta.cpp38
-rw-r--r--src/server/events/DisconnectAll.cpp32
-rw-r--r--src/server/events/Get.cpp10
-rw-r--r--src/server/ingen_lv2.cpp20
13 files changed, 108 insertions, 115 deletions
diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp
index 9f5b93d8..61237ee4 100644
--- a/src/server/BlockFactory.cpp
+++ b/src/server/BlockFactory.cpp
@@ -49,8 +49,8 @@ BlockFactory::BlockFactory(Ingen::World* world)
BlockFactory::~BlockFactory()
{
- for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i)
- delete i->second;
+ for (auto& p : _plugins)
+ delete p.second;
_plugins.clear();
}
@@ -162,8 +162,8 @@ BlockFactory::load_lv2_plugins()
for (uint32_t p = 0; p < n_ports; ++p) {
const LilvPort* port = lilv_plugin_get_port_by_index(lv2_plug, p);
supported = false;
- for (Types::const_iterator t = types.begin(); t != types.end(); ++t) {
- if (lilv_port_is_a(lv2_plug, port, t->get())) {
+ for (const auto& t : types) {
+ if (lilv_port_is_a(lv2_plug, port, t.get())) {
supported = true;
break;
}
diff --git a/src/server/Broadcaster.cpp b/src/server/Broadcaster.cpp
index 6c111a1c..49bc68ae 100644
--- a/src/server/Broadcaster.cpp
+++ b/src/server/Broadcaster.cpp
@@ -73,8 +73,8 @@ void
Broadcaster::send_plugins(const BlockFactory::Plugins& plugins)
{
Glib::Mutex::Lock lock(_clients_mutex);
- for (Clients::const_iterator c = _clients.begin(); c != _clients.end(); ++c) {
- send_plugins_to((*c).second.get(), plugins);
+ for (const auto& c : _clients) {
+ send_plugins_to(c.second.get(), plugins);
}
}
@@ -84,8 +84,8 @@ Broadcaster::send_plugins_to(Interface* client,
{
client->bundle_begin();
- for (BlockFactory::Plugins::const_iterator i = plugins.begin(); i != plugins.end(); ++i) {
- const PluginImpl* const plugin = i->second;
+ for (const auto& p : plugins) {
+ const PluginImpl* const plugin = p.second;
client->put(plugin->uri(), plugin->properties());
}
diff --git a/src/server/Broadcaster.hpp b/src/server/Broadcaster.hpp
index 78419991..559bf709 100644
--- a/src/server/Broadcaster.hpp
+++ b/src/server/Broadcaster.hpp
@@ -75,8 +75,8 @@ public:
#define BROADCAST(msg, ...) \
Glib::Mutex::Lock lock(_clients_mutex); \
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) \
- (*i).second->msg(__VA_ARGS__)
+ for (const auto& c : _clients) \
+ c.second->msg(__VA_ARGS__)
void bundle_begin() { BROADCAST(bundle_begin); }
void bundle_end() { BROADCAST(bundle_end); }
diff --git a/src/server/CompiledGraph.hpp b/src/server/CompiledGraph.hpp
index 024aa919..ee02a24e 100644
--- a/src/server/CompiledGraph.hpp
+++ b/src/server/CompiledGraph.hpp
@@ -33,15 +33,15 @@ class BlockImpl;
*/
class CompiledBlock {
public:
- CompiledBlock(BlockImpl* b, size_t np, const std::list<BlockImpl*>& d)
+ CompiledBlock(BlockImpl* b, size_t np, const std::list<BlockImpl*>& deps)
: _block(b), _n_providers(np)
{
// Copy to a vector for maximum iteration speed and cache optimization
// (Need to take a copy anyway)
- _dependants.reserve(d.size());
- for (std::list<BlockImpl*>::const_iterator i = d.begin(); i != d.end(); ++i)
- _dependants.push_back(*i);
+ _dependants.reserve(deps.size());
+ for (const auto& d : deps)
+ _dependants.push_back(d);
}
BlockImpl* block() const { return _block; }
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index ce84de4d..5002feca 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -82,11 +82,11 @@ Engine::~Engine()
_root_graph = NULL;
deactivate();
- const SharedPtr<Store> s = this->store();
- if (s) {
- for (Store::iterator i = s->begin(); i != s->end(); ++i) {
- if (!PtrCast<NodeImpl>(i->second)->parent()) {
- i->second.reset();
+ const SharedPtr<Store> store = this->store();
+ if (store) {
+ for (auto& s : *store.get()) {
+ if (!PtrCast<NodeImpl>(s.second)->parent()) {
+ s.second.reset();
}
}
}
diff --git a/src/server/GraphImpl.cpp b/src/server/GraphImpl.cpp
index 5859d071..14af654c 100644
--- a/src/server/GraphImpl.cpp
+++ b/src/server/GraphImpl.cpp
@@ -68,8 +68,8 @@ GraphImpl::activate(BufferFactory& bufs)
{
BlockImpl::activate(bufs);
- for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
- i->activate(bufs);
+ for (auto& b : _blocks) {
+ b.activate(bufs);
}
assert(_activated);
@@ -81,9 +81,9 @@ GraphImpl::deactivate()
if (_activated) {
BlockImpl::deactivate();
- for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
- if (i->activated()) {
- i->deactivate();
+ for (auto& b : _blocks) {
+ if (b.activated()) {
+ b.deactivate();
}
}
}
@@ -93,8 +93,8 @@ void
GraphImpl::disable(ProcessContext& context)
{
_process = false;
- for (Ports::iterator i = _outputs.begin(); i != _outputs.end(); ++i) {
- i->clear_buffers();
+ for (auto& o : _outputs) {
+ o.clear_buffers();
}
}
@@ -105,8 +105,8 @@ GraphImpl::prepare_internal_poly(BufferFactory& bufs, uint32_t poly)
// TODO: Subgraph dynamic polyphony (i.e. changing port polyphony)
- for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
- i->prepare_poly(bufs, poly);
+ for (auto& b : _blocks) {
+ b.prepare_poly(bufs, poly);
}
_poly_pre = poly;
@@ -121,13 +121,13 @@ GraphImpl::apply_internal_poly(ProcessContext& context,
{
// TODO: Subgraph dynamic polyphony (i.e. changing port polyphony)
- for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
- i->apply_poly(context, maid, poly);
+ for (auto& b : _blocks) {
+ b.apply_poly(context, maid, poly);
}
- for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
- for (uint32_t j = 0; j < i->num_ports(); ++j) {
- PortImpl* const port = i->port_impl(j);
+ for (auto& b : _blocks) {
+ for (uint32_t j = 0; j < b.num_ports(); ++j) {
+ PortImpl* const port = b.port_impl(j);
if (port->is_input() && dynamic_cast<InputPort*>(port)->direct_connect())
port->setup_buffers(bufs, port->poly(), true);
port->connect_buffers();
@@ -135,8 +135,8 @@ GraphImpl::apply_internal_poly(ProcessContext& context,
}
const bool polyphonic = parent_graph() && (poly == parent_graph()->internal_poly_process());
- for (Ports::iterator i = _outputs.begin(); i != _outputs.end(); ++i)
- i->setup_buffers(bufs, polyphonic ? poly : 1, true);
+ for (auto& o : _outputs)
+ o.setup_buffers(bufs, polyphonic ? poly : 1, true);
_poly_process = poly;
return true;
@@ -331,10 +331,9 @@ compile_recursive(BlockImpl* n, CompiledGraph* output)
n->traversed(true);
assert(output != NULL);
- for (std::list<BlockImpl*>::iterator i = n->providers().begin();
- i != n->providers().end(); ++i)
- if (!(*i)->traversed())
- compile_recursive(*i, output);
+ for (auto& p : n->providers())
+ if (!p->traversed())
+ compile_recursive(p, output);
output->push_back(CompiledBlock(n, n->providers().size(), n->dependants()));
}
@@ -356,21 +355,21 @@ GraphImpl::compile()
CompiledGraph* const compiled_graph = new CompiledGraph();
- for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
- i->traversed(false);
+ for (auto& b : _blocks) {
+ b.traversed(false);
}
- for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
+ for (auto& b : _blocks) {
// Either a sink or connected to our output ports:
- if (!i->traversed() && i->dependants().empty()) {
- compile_recursive(&*i, compiled_graph);
+ if (!b.traversed() && b.dependants().empty()) {
+ compile_recursive(&b, compiled_graph);
}
}
// Traverse any blocks we didn't hit yet
- for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
- if (!i->traversed()) {
- compile_recursive(&*i, compiled_graph);
+ for (auto& b : _blocks) {
+ if (!b.traversed()) {
+ compile_recursive(&b, compiled_graph);
}
}
diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp
index fe534eb0..94e451c0 100644
--- a/src/server/InputPort.cpp
+++ b/src/server/InputPort.cpp
@@ -211,8 +211,8 @@ InputPort::pre_process(Context& context)
for (uint32_t v = 0; v < _poly; ++v) {
// Get all the sources for this voice
uint32_t num_srcs = 0;
- for (Arcs::iterator e = _arcs.begin(); e != _arcs.end(); ++e) {
- get_sources(context, *e, v, srcs, max_num_srcs, num_srcs);
+ for (const auto& a : _arcs) {
+ get_sources(context, a, v, srcs, max_num_srcs, num_srcs);
}
// Then mix them into out buffer for this voice
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp
index 3afbd51c..33d11e92 100644
--- a/src/server/JackDriver.cpp
+++ b/src/server/JackDriver.cpp
@@ -134,8 +134,8 @@ JackDriver::attach(const std::string& server_name,
jack_set_session_callback(_client, session_cb, this);
#endif
- for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
- register_port(*i);
+ for (auto& p : _ports) {
+ register_port(p);
}
return true;
@@ -176,8 +176,8 @@ JackDriver::deactivate()
_is_activated = false;
_sem.wait();
- for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
- unregister_port(*i);
+ for (auto& p : _ports) {
+ unregister_port(p);
}
if (_client) {
@@ -193,9 +193,9 @@ JackDriver::deactivate()
EnginePort*
JackDriver::get_port(const Raul::Path& path)
{
- for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
- if (i->graph_port()->path() == path) {
- return &*i;
+ for (auto& p : _ports) {
+ if (p.graph_port()->path() == path) {
+ return &p;
}
}
@@ -417,15 +417,15 @@ JackDriver::_process_cb(jack_nframes_t nframes)
_engine.process_context().locate(start_of_current_cycle, nframes);
// Read input
- for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
- pre_process_port(_engine.process_context(), &*i);
+ for (auto& p : _ports) {
+ pre_process_port(_engine.process_context(), &p);
}
_engine.run(nframes);
// Write output
- for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
- post_process_port(_engine.process_context(), &*i);
+ for (auto& p : _ports) {
+ post_process_port(_engine.process_context(), &p);
}
// Update expected transport frame for next cycle to detect changes
diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp
index 65e24bfd..90a76c1d 100644
--- a/src/server/events/CreateBlock.cpp
+++ b/src/server/events/CreateBlock.cpp
@@ -140,8 +140,8 @@ CreateBlock::post_process()
{
Broadcaster::Transfer t(*_engine.broadcaster());
if (respond() == Status::SUCCESS) {
- for (Update::const_iterator i = _update.begin(); i != _update.end(); ++i) {
- _engine.broadcaster()->put(i->first, i->second);
+ for (const auto& u : _update) {
+ _engine.broadcaster()->put(u.first, u.second);
}
}
}
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index 0f854096..352aa56c 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -65,10 +65,8 @@ Delta::Delta(Engine& engine,
, _create(create)
{
if (context != Resource::Graph::DEFAULT) {
- for (Properties::iterator i = _properties.begin();
- i != _properties.end();
- ++i) {
- i->second.set_context(context);
+ for (auto& p : _properties) {
+ p.second.set_context(context);
}
}
@@ -94,8 +92,8 @@ Delta::Delta(Engine& engine,
Delta::~Delta()
{
- for (SetEvents::iterator i = _set_events.begin(); i != _set_events.end(); ++i)
- delete *i;
+ for (auto& s : _set_events)
+ delete s;
delete _create_event;
}
@@ -149,9 +147,9 @@ Delta::pre_process()
NodeImpl* obj = dynamic_cast<NodeImpl*>(_object);
- for (Properties::const_iterator p = _remove.begin(); p != _remove.end(); ++p) {
- const Raul::URI& key = p->first;
- const Raul::Atom& value = p->second;
+ for (const auto& r : _remove) {
+ const Raul::URI& key = r.first;
+ const Raul::Atom& value = r.second;
if (key == uris.ingen_controlBinding && value == uris.wildcard) {
PortImpl* port = dynamic_cast<PortImpl*>(_object);
if (port)
@@ -160,9 +158,9 @@ Delta::pre_process()
_object->remove_property(key, value);
}
- for (Properties::const_iterator p = _properties.begin(); p != _properties.end(); ++p) {
- const Raul::URI& key = p->first;
- const Resource::Property& value = p->second;
+ for (const auto& p : _properties) {
+ const Raul::URI& key = p.first;
+ const Resource::Property& value = p.second;
SpecialType op = SpecialType::NONE;
if (obj) {
Resource& resource = *obj;
@@ -273,9 +271,9 @@ Delta::execute(ProcessContext& context)
_create_event->execute(context);
}
- for (SetEvents::iterator i = _set_events.begin(); i != _set_events.end(); ++i) {
- (*i)->set_time(_time);
- (*i)->execute(context);
+ for (auto& s : _set_events) {
+ s->set_time(_time);
+ s->execute(context);
}
NodeImpl* const object = dynamic_cast<NodeImpl*>(_object);
@@ -283,9 +281,9 @@ Delta::execute(ProcessContext& context)
PortImpl* const port = dynamic_cast<PortImpl*>(_object);
std::vector<SpecialType>::const_iterator t = _types.begin();
- for (Properties::const_iterator p = _properties.begin(); p != _properties.end(); ++p, ++t) {
- const Raul::URI& key = p->first;
- const Raul::Atom& value = p->second;
+ for (const auto& p : _properties) {
+ const Raul::URI& key = p.first;
+ const Raul::Atom& value = p.second;
switch (*t) {
case SpecialType::ENABLE_BROADCAST:
if (port) {
@@ -346,8 +344,8 @@ Delta::post_process()
{
Broadcaster::Transfer t(*_engine.broadcaster());
- for (SetEvents::iterator i = _set_events.begin(); i != _set_events.end(); ++i)
- (*i)->post_process();
+ for (auto& s : _set_events)
+ s->post_process();
if (_status == Status::SUCCESS) {
if (_create_event) {
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index a6022410..a3df4e77 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -75,8 +75,8 @@ DisconnectAll::DisconnectAll(Engine& engine,
DisconnectAll::~DisconnectAll()
{
- for (Impls::iterator i = _impls.begin(); i != _impls.end(); ++i)
- delete (*i);
+ for (auto& i : _impls)
+ delete i;
}
bool
@@ -116,28 +116,26 @@ DisconnectAll::pre_process()
// Find set of arcs to remove
std::set<ArcImpl*> to_remove;
- for (Node::Arcs::const_iterator i = _parent->arcs().begin();
- i != _parent->arcs().end(); ++i) {
- ArcImpl* const c = (ArcImpl*)i->second.get();
+ for (const auto& a : _parent->arcs()) {
+ ArcImpl* const arc = (ArcImpl*)a.second.get();
if (_block) {
- if (c->tail()->parent_block() == _block
- || c->head()->parent_block() == _block) {
- to_remove.insert(c);
+ if (arc->tail()->parent_block() == _block
+ || arc->head()->parent_block() == _block) {
+ to_remove.insert(arc);
}
} else if (_port) {
- if (c->tail() == _port || c->head() == _port) {
- to_remove.insert(c);
+ if (arc->tail() == _port || arc->head() == _port) {
+ to_remove.insert(arc);
}
}
}
// Create disconnect events (which erases from _parent->arcs())
- for (std::set<ArcImpl*>::const_iterator i = to_remove.begin();
- i != to_remove.end(); ++i) {
+ for (const auto& a : to_remove) {
_impls.push_back(new Disconnect::Impl(
_engine, _parent,
- dynamic_cast<OutputPort*>((*i)->tail()),
- dynamic_cast<InputPort*>((*i)->head())));
+ dynamic_cast<OutputPort*>(a->tail()),
+ dynamic_cast<InputPort*>(a->head())));
}
if (!_deleting && _parent->enabled())
@@ -150,9 +148,9 @@ void
DisconnectAll::execute(ProcessContext& context)
{
if (_status == Status::SUCCESS) {
- for (Impls::iterator i = _impls.begin(); i != _impls.end(); ++i) {
- (*i)->execute(context,
- !_deleting || ((*i)->head()->parent_block() != _block));
+ for (auto& i : _impls) {
+ i->execute(context,
+ !_deleting || (i->head()->parent_block() != _block));
}
}
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index 67b68de9..f16654f7 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -111,9 +111,8 @@ send_graph(Interface* client, const GraphImpl* graph)
Resource::Graph::EXTERNAL);
// Send blocks
- for (GraphImpl::Blocks::const_iterator j = graph->blocks().begin();
- j != graph->blocks().end(); ++j) {
- send_block(client, &*j);
+ for (const auto& b : graph->blocks()) {
+ send_block(client, &b);
}
// Send ports
@@ -122,9 +121,8 @@ send_graph(Interface* client, const GraphImpl* graph)
}
// Send arcs
- for (GraphImpl::Arcs::const_iterator j = graph->arcs().begin();
- j != graph->arcs().end(); ++j) {
- client->connect(j->second->tail_path(), j->second->head_path());
+ for (const auto& a : graph->arcs()) {
+ client->connect(a.second->tail_path(), a.second->head_path());
}
}
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index f8f4b7c3..e866ea0e 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -183,8 +183,8 @@ public:
// Notify buffer is a Chunk with size set to the available space
_notify_capacity = ((LV2_Atom_Sequence*)_ports[1]->buffer())->atom.size;
- for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
- pre_process_port(_engine.process_context(), *i);
+ for (auto& p : _ports) {
+ pre_process_port(_engine.process_context(), p);
}
_engine.run(nframes);
@@ -194,8 +194,8 @@ public:
flush_to_ui(_engine.process_context());
- for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
- post_process_port(_engine.process_context(), *i);
+ for (auto& p : _ports) {
+ post_process_port(_engine.process_context(), p);
}
_frame_time += nframes;
@@ -210,9 +210,9 @@ public:
virtual GraphImpl* root_graph() { return _root_graph; }
virtual EnginePort* get_port(const Raul::Path& path) {
- for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
- if ((*i)->graph_port()->path() == path) {
- return *i;
+ for (auto& p : _ports) {
+ if (p->graph_port()->path() == path) {
+ return p;
}
}
@@ -508,9 +508,9 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
Glib::filename_to_uri(Ingen::bundle_file_path("manifest.ttl")));
const LV2Graph* graph = NULL;
- for (Lib::Graphs::iterator i = graphs.begin(); i != graphs.end(); ++i) {
- if ((*i)->uri == descriptor->URI) {
- graph = (*i).get();
+ for (const auto& g : graphs) {
+ if (g->uri == descriptor->URI) {
+ graph = g.get();
break;
}
}