/* vim:set et ts=4 sts=4: * * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus * * Copyright (c) 2008-2010 Peng Huang * * This program 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, or (at your option) * any later version. * * This program 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 more 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __ZY_SIGNAL_H_ #define __ZY_SIGNAL_H_ #ifdef HAVE_CONFIG_H # include #endif #ifdef __GXX_EXPERIMENTAL_CXX0X__ # include namespace ZY { using namespace std::placeholders; // implement signal templates template struct signal { }; template struct signal< R(), T1, T2, T3> { typedef std::function func_type; void connect (func_type f) { m_func = f; } R operator ()() const { m_func (); } private: func_type m_func; }; template struct signal< R(T1), T2, T3> { typedef std::function func_type; void connect (func_type f) { m_func = f; } R operator ()(T1 a1) const { return m_func (a1); } private: func_type m_func; }; template struct signal< R(T1, T2), T3> { typedef std::function func_type; void connect (func_type f) { m_func = f; } R operator ()(T1 a1, T2 a2) const { return m_func (a1, a2); } private: func_type m_func; }; template struct signal< R(T1, T2, T3)> { typedef std::function func_type; void connect (func_type f) {m_func = f; } R operator ()(T1 a1, T2 a2, T3 a3) const { return m_func (a1, a2, a3); } private: func_type m_func; }; }; #else // __GXX_EXPERIMENTAL_CXX0X__ # include # include namespace std { // import boost::bind into std namespace using boost::bind; }; namespace ZY { // use boost::signal2 namespace bs2 = boost::signals2; template struct signal : public bs2::signal_type >::type { }; }; #endif // __GXX_EXPERIMENTAL_CXX0X__ #endif // __ZY_SIGNAL_H_