/* This file is part of Om. Copyright (C) 2006 Dave Robillard. * * Om is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. * * Om is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef PATCH_H #define PATCH_H #include #include #include "NodeBase.h" #include "Plugin.h" #include "List.h" using std::string; template class Array; namespace Om { class Connection; class InternalNode; namespace Shared { class ClientInterface; } using Shared::ClientInterface; /** A group of nodes in a graph, possibly polyphonic. * * Note that this is also a Node, just one which contains Nodes. * Therefore infinite subpatching is possible, of polyphonic * patches of polyphonic nodes etc. etc. * * \ingroup engine */ class Patch : public NodeBase { public: Patch(const string& name, size_t poly, Patch* parent, samplerate srate, size_t buffer_size, size_t local_poly); virtual ~Patch(); Patch* as_patch() { return static_cast(this); } void activate(); void deactivate(); void run(size_t nframes); size_t num_ports() const; //void send_creation_messages(ClientInterface* client) const; void add_to_store(); void remove_from_store(); void set_path(const Path& new_path); // Patch specific stuff not inherited from Node void add_node(ListNode* tn); ListNode* remove_node(const string& name); List& nodes() { return m_nodes; } List& connections() { return m_connections; } const List& nodes() const { return m_nodes; } const List& connections() const { return m_connections; } void add_bridge_node(ListNode* n) { m_bridge_nodes.push_back(n); } ListNode* remove_bridge_node(const InternalNode* n); void add_connection(ListNode* c) { m_connections.push_back(c); } ListNode* remove_connection(const Port* src_port, const Port* dst_port); Array* process_order() { return m_process_order; } void process_order(Array* po) { m_process_order = po; } Array* build_process_order() const; inline void build_process_order_recursive(Node* n, Array* order) const; /** Whether to run this patch's DSP in the audio thread */ bool process() const { return m_process; } void process(bool b); size_t internal_poly() const { return m_internal_poly; } const Plugin* plugin() const { return &m_plugin; } void plugin(const Plugin* const) { exit(EXIT_FAILURE); } private: // Prevent copies (undefined) Patch(const Patch&); Patch& operator=(const Patch&); size_t m_internal_poly; Array* m_process_order; List m_connections; List m_bridge_nodes; ///< Inputs and outputs List m_nodes; bool m_process; Plugin m_plugin; }; /** Private helper for build_process_order */ inline void Patch::build_process_order_recursive(Node* n, Array* order) const { if (n == NULL || n->traversed()) return; n->traversed(true); assert(order != NULL); for (List::iterator i = n->providers()->begin(); i != n->providers()->end(); ++i) if ( ! (*i)->traversed() ) build_process_order_recursive((*i), order); order->push_back(n); } } // namespace Om #endif // PATCH_H