libpsynth 0.2.1
/home/raskolnikov/dev/psynth/trunk/src/psynth/graph/node_manager.hpp
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   PSYCHOSYNTH                                                           *
00004  *   ===========                                                           *
00005  *                                                                         *
00006  *   Copyright (C) Juan Pedro Bolivar Puente 2007                          *
00007  *                                                                         *
00008  *   This program is free software: you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation, either version 3 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 #ifndef PSYNTH_NODE_MANAGER_H
00024 #define PSYNTH_NODE_MANAGER_H
00025 
00026 #include <map>
00027 #include <thread>
00028 
00029 #include <psynth/base/pointer.hpp>
00030 #include <psynth/base/iterator.hpp>
00031 #include <psynth/graph/node_output.hpp>
00032 
00033 namespace psynth
00034 {
00035 namespace graph
00036 {
00037 
00038 class node_manager
00039 {
00040 public:
00041     typedef base::map_iterator <int, base::mgr_ptr<node>> iterator;
00042     typedef base::map_const_iterator <int, base::mgr_ptr<node>> const_iterator;
00043 
00044 private:
00045     base::mgr_assoc <std::map <int, base::mgr_ptr <node>>> m_node_map;
00046     std::list <node_output*> m_outputs;
00047     std::list <node*> m_delete_list;
00048     
00049     std::mutex m_update_mutex;
00050 
00051     void do_delete_node (iterator it);
00052 
00053 public:
00054     node_manager ();
00055     ~node_manager ();
00056         
00057     bool add_node (base::mgr_ptr<node> obj, int id);
00058 
00059     bool delete_node (int id);
00060     void delete_node (iterator it);
00061 
00062     const_iterator begin () const {
00063         return m_node_map.begin();
00064     }
00065     
00066     iterator begin () {
00067         return m_node_map.begin();
00068     }
00069 
00070     const_iterator end () const {
00071         return m_node_map.end();
00072     }
00073     
00074     iterator end () {
00075         return m_node_map.end();
00076     }
00077     
00078     iterator find (int id) {
00079         return m_node_map.find(id);
00080     }
00081 
00082     const_iterator find (int id) const {
00083         return m_node_map.find(id);
00084     }
00085 
00086     void set_info (const audio_info& info);
00087 
00099     void update ();
00100 };
00101 
00102 } /* namespace graph */
00103 } /* namespace psynth */
00104 
00105 #endif /* PSYNTH_NODE_MANAGER_H */