libpsynth 0.2.1
/home/raskolnikov/dev/psynth/trunk/src/psynth/new_graph/event.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_EVENT_HPP_
00032 #define PSYNTH_GRAPH_EVENT_HPP_
00033 
00034 #include <psynth/base/functor.hpp>
00035 #include <psynth/new_graph/processor_fwd.hpp>
00036 
00037 namespace psynth
00038 {
00039 namespace graph
00040 {
00041 
00042 typedef base::dynamic_functor<void, rt_process_context&> rt_event;
00043 typedef base::dynamic_functor<void, async_process_context&> async_event;
00044 
00048 template <typename Fn>
00049 struct fn_rt_event : public base::fn_dynamic_functor <
00050     Fn, void, rt_process_context&>
00051 {
00052     typedef base::fn_dynamic_functor <Fn, void, rt_process_context&> base;
00053     
00054     fn_rt_event (const Fn& f)
00055         : base (f) {}
00056     fn_rt_event (Fn&& f)
00057         : base (std::move (f)) {}
00058 };
00059 
00060 template <typename Fn>
00061 struct fn_async_event : base::fn_dynamic_functor <
00062     Fn, void, async_process_context&>
00063 {
00064     typedef base::fn_dynamic_functor <Fn, void, async_process_context&> base;
00065     
00066     fn_async_event (const Fn& f)
00067         : base (f) {}
00068     fn_async_event (Fn&& f)
00069         : base (std::move (f)) {}
00070 };
00071 
00072 template <class Fn>
00073 fn_rt_event<Fn> make_rt_event (Fn&& f)
00074 {
00075     return fn_rt_event<Fn> (f);
00076 }
00077 
00078 template <class Fn>
00079 fn_async_event<Fn> make_async_event (Fn&& f)
00080 {
00081     return fn_async_event<Fn> (f);
00082 }
00083 
00084 } /* namespace graph */
00085 } /* namespace psynth */
00086 
00087 #endif /* PSYNTH_GRAPH_EVENT_HPP_ */