1 /* Copyright (c) 2014-2015. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_XBT_SIGNAL_HPP
7 #define SIMGRID_XBT_SIGNAL_HPP
9 #include "simgrid_config.h"
10 #if SIMGRID_HAVE_LIBSIG
11 #include <sigc++/sigc++.h>
13 #include <boost/signals2.hpp>
19 #if SIMGRID_HAVE_LIBSIG
21 // Wraps sigc++ signals with the interface of boost::signals2:
22 template<class T> class signal;
23 template<class R, class... P>
24 class signal<R(P...)> {
26 sigc::signal<R, P...> sig_;
28 template<class U> XBT_ALWAYS_INLINE
29 void connect(U&& slot)
31 sig_.connect(std::forward<U>(slot));
33 template<class Res, class... Args> XBT_ALWAYS_INLINE
34 void connect(Res(*slot)(Args...))
36 sig_.connect(sigc::ptr_fun(slot));
38 template<class... Args> XBT_ALWAYS_INLINE
39 R operator()(Args&&... args) const
41 return sig_.emit(std::forward<Args>(args)...);
43 void disconnect_all_slots()
52 using signal = ::boost::signals2::signal<T>;