libpsynth 0.2.1
/home/raskolnikov/dev/psynth/trunk/src/psynth/new_graph/core/patch.hpp
Go to the documentation of this file.
00001 
00011 /*
00012  *  Copyright (C) 2011 Juan Pedro BolĂ­var Puente
00013  *
00014  *  This file is part of Psychosynth.
00015  *   
00016  *  Psychosynth is free software: you can redistribute it and/or modify
00017  *  it under the terms of the GNU General Public License as published by
00018  *  the Free Software Foundation, either version 3 of the License, or
00019  *  (at your option) any later version.
00020  *
00021  *  Psychosynth is distributed in the hope that it will be useful,
00022  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  *  GNU General Public License for more details.
00025  *
00026  *  You should have received a copy of the GNU General Public License
00027  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00028  *
00029  */
00030 
00031 #ifndef PSYNTH_GRAPH_PATCH_HPP_
00032 #define PSYNTH_GRAPH_PATCH_HPP_
00033 
00034 #include <list>
00035 
00036 #include <boost/range/iterator_range.hpp>
00037 #include <boost/intrusive/list.hpp>
00038 
00039 #include <psynth/new_graph/node.hpp>
00040 #include <psynth/new_graph/core/patch_fwd.hpp>
00041 #include <psynth/new_graph/core/patch_port.hpp>
00042 
00043 namespace psynth
00044 {
00045 namespace graph
00046 {
00047 namespace core
00048 {
00049 
00050 PSYNTH_DECLARE_ERROR (error, patch_child_error);
00051 
00052 class patch : public node
00053 {
00054 public:
00055     typedef std::list<graph::node_ptr> child_list;
00056     
00057     typedef boost::intrusive::list<
00058         node,
00059         boost::intrusive::member_hook<
00060             node,
00061             patch_child_hook,
00062             &node::_patch_child_hook> >
00063     rt_child_list;
00064 
00065     typedef boost::intrusive::list<
00066         patch_out_port_base,
00067         boost::intrusive::member_hook<
00068             patch_out_port_base,
00069             patch_output_hook,
00070             &patch_out_port_base::_patch_output_hook> >
00071     rt_output_list;
00072 
00073     typedef child_list::iterator child_iterator;
00074     typedef child_list::const_iterator child_const_iterator;
00075     typedef boost::iterator_range<child_iterator> child_range;
00076     typedef boost::iterator_range<child_const_iterator> child_const_range;
00077 
00078     typedef rt_child_list::iterator rt_child_iterator;
00079     typedef rt_child_list::const_iterator rt_child_const_iterator;
00080     typedef boost::iterator_range<rt_child_iterator> rt_child_range;
00081     typedef boost::iterator_range<rt_child_const_iterator> rt_child_const_range;
00082 
00083     void rt_process (rt_process_context& ctx);
00084     void rt_context_update (rt_process_context& ctx);
00085     void rt_advance ();
00086     
00087     node_ptr add (node_ptr child);
00088     void remove (node_ptr child);
00089     
00090     child_range childs ()
00091     { return boost::make_iterator_range (_childs); }
00092     child_const_range cchilds () const
00093     { return boost::make_iterator_range (_childs); }
00094 
00095     
00096     rt_child_range rt_childs ()
00097     { return boost::make_iterator_range (_rt_childs); }
00098     rt_child_const_range rt_cchilds () const
00099     { return boost::make_iterator_range (_rt_childs); }
00100     
00101 protected:
00102     child_list _childs;
00103     rt_child_list _rt_childs;
00104     rt_output_list _rt_outputs;
00105 };
00106 
00107 } /* namespace core */
00108 } /* namespace graph */
00109 } /* namespace psynth */
00110 
00111 #endif /* PSYNTH_GRAPH_PATCH_HPP_ */