#ifndef lite__signals__Connection__hpp_ #define lite__signals__Connection__hpp_ #include "boost/any.hpp" namespace lite { namespace signals { class Connection { public: Connection() : disconnect_(0) , replace_(0) , token_() { } Connection( void (*disconnect)( boost::any const & token), void (*replace)( boost::any const & token, boost::any const & function), boost::any const & token) : disconnect_(disconnect) , replace_(replace) , token_(token) { } void disconnect() { if (disconnect_) { disconnect_(token_); disconnect_ = 0; replace_ = 0; token_ = boost::any(); } } void replace_any( boost::any const & function) { if (replace_) { replace_(token_, function); } } boost::any const & token() const { return token_; } protected: void (*disconnect_)(boost::any const & token); void (*replace_)(boost::any const & token, boost::any const & func); boost::any token_; }; template class Typed_Connection : public Connection { public: Typed_Connection() : Connection() { } Typed_Connection( boost::any const & token) : Connection( &SIGNAL::disconnect_any_token, &SIGNAL::replace_any_token, token) { } void replace( typename SIGNAL::Function_Type const & func) { replace_any(func); } }; } // end signals namespace } // end lite namespace #endif // lite__signals__Connection__hpp_