diff options
author | David Robillard <d@drobilla.net> | 2010-12-15 20:10:41 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-15 20:10:41 +0000 |
commit | f4f74f3316b474096f164aa33c9d2e8965a545c3 (patch) | |
tree | 49ed4402f138d17592d7a33a35fde7232f799bff /src/PatchageCanvas.hpp | |
parent | aea13cac2a4106bbca28fc062d60e18ca4990c6c (diff) | |
download | patchage-f4f74f3316b474096f164aa33c9d2e8965a545c3.tar.gz patchage-f4f74f3316b474096f164aa33c9d2e8965a545c3.tar.bz2 patchage-f4f74f3316b474096f164aa33c9d2e8965a545c3.zip |
Improve performance for setups with many apps or ports.
(Eliminate all linear searches for items, except one case for Jack
ports which is unavoidable due to the Jack API, but is memoized,
so each port will only be searched for once between refreshes).
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@2712 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/PatchageCanvas.hpp')
-rw-r--r-- | src/PatchageCanvas.hpp | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/PatchageCanvas.hpp b/src/PatchageCanvas.hpp index ef599ba..6d0ac9f 100644 --- a/src/PatchageCanvas.hpp +++ b/src/PatchageCanvas.hpp @@ -18,7 +18,7 @@ #ifndef PATCHAGE_PATCHAGECANVAS_HPP #define PATCHAGE_PATCHAGECANVAS_HPP -#include <string> +#include <map> #include "patchage-config.h" @@ -29,29 +29,48 @@ #include "flowcanvas/Canvas.hpp" #include "PatchageEvent.hpp" +#include "PatchageModule.hpp" +#include "PortID.hpp" #include "StateManager.hpp" class Patchage; class PatchageModule; class PatchagePort; -using std::string; -using namespace FlowCanvas; - -class PatchageCanvas : public Canvas { +class PatchageCanvas : public FlowCanvas::Canvas { public: PatchageCanvas(Patchage* _app, int width, int height); - boost::shared_ptr<PatchageModule> find_module(const string& name, ModuleType type); + boost::shared_ptr<PatchageModule> find_module(const std::string& name, ModuleType type); boost::shared_ptr<PatchagePort> find_port(const PortID& id); - void connect(boost::shared_ptr<Connectable> port1, boost::shared_ptr<Connectable> port2); - void disconnect(boost::shared_ptr<Connectable> port1, boost::shared_ptr<Connectable> port2); + void connect(boost::shared_ptr<FlowCanvas::Connectable> port1, + boost::shared_ptr<FlowCanvas::Connectable> port2); + + void disconnect(boost::shared_ptr<FlowCanvas::Connectable> port1, + boost::shared_ptr<FlowCanvas::Connectable> port2); + + void status_message(const std::string& msg); + + void index_port(const PortID& id, boost::shared_ptr<PatchagePort> port) { + _port_index.insert(std::make_pair(id, port)); + } - void status_message(const string& msg); + void add_module(const std::string& name, boost::shared_ptr<PatchageModule> module) { + _module_index.insert(std::make_pair(name, module)); + add_item(module); + } + + void destroy(); private: Patchage* _app; + + typedef std::map< const PortID, boost::shared_ptr<PatchagePort> > PortIndex; + PortIndex _port_index; + + typedef std::multimap< const std::string, boost::shared_ptr<PatchageModule> > ModuleIndex; + ModuleIndex _module_index; }; |