Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Public simgrid::xbt:signal<F> class
authorGabriel Corona <gabriel.corona@loria.fr>
Wed, 13 Jan 2016 10:24:21 +0000 (11:24 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Wed, 13 Jan 2016 10:31:51 +0000 (11:31 +0100)
It is either an alias for boost::signals2::signal<F> or a wrapper
around sigc::signal<R, Args...>. We are going to need it in order to
exposer the signals to users and move them in simgrid::Host.

18 files changed:
include/simgrid_config.h.in
include/xbt/signal.hpp [new file with mode: 0644]
src/simix/libsmx.cpp
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp
src/surf/host_interface.cpp
src/surf/host_interface.hpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/storage_interface.cpp
src/surf/storage_interface.hpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp
src/surf/surf_routing.cpp
src/surf/surf_routing.hpp
src/surf/virtual_machine.cpp
src/surf/virtual_machine.hpp
tools/cmake/MakeLib.cmake

index ba2e972..1ee0a15 100644 (file)
@@ -90,4 +90,6 @@
 /* If Model-Checking support was requested */
 #cmakedefine HAVE_MC @HAVE_MC@
 
 /* If Model-Checking support was requested */
 #cmakedefine HAVE_MC @HAVE_MC@
 
+#cmakedefine SIMGRID_HAVE_LIBSIG @SIMGRID_HAVE_LIBSIG@
+
 #endif /* SIMGRID_PUBLIC_CONFIG_H */
 #endif /* SIMGRID_PUBLIC_CONFIG_H */
diff --git a/include/xbt/signal.hpp b/include/xbt/signal.hpp
new file mode 100644 (file)
index 0000000..2068546
--- /dev/null
@@ -0,0 +1,52 @@
+/* Copyright (c) 2014-2015. The SimGrid Team. All rights reserved.          */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef SIMGRID_XBT_SIGNAL_HPP
+#define SIMGRID_XBT_SIGNAL_HPP
+
+#ifdef SIMGRID_HAVE_LIBSIG
+#include <sigc++/sigc++.h>
+
+namespace simgrid {
+namespace xbt {
+  // Wraps sigc++ signals with the interface of boost::signals2:
+  template<class T> class signal;
+  template<class R, class... P>
+  class signal<R(P...)> {
+  private:
+    sigc::signal<R, P...> sig_;
+  public:
+    template<class U> XBT_ALWAYS_INLINE
+    void connect(U&& slot)
+    {
+      sig_.connect(std::forward<U>(slot));
+    }
+    template<class Res, class... Args> XBT_ALWAYS_INLINE
+    void connect(Res(*slot)(Args...))
+    {
+      sig_.connect(sigc::ptr_fun(slot));
+    }
+    template<class... Args> XBT_ALWAYS_INLINE
+    R operator()(Args&&... args) const
+    {
+      return sig_.emit(std::forward<Args>(args)...);
+    }
+  };
+}
+}
+
+#else
+
+#include <boost/signals2.hpp>
+namespace simgrid {
+namespace xbt {
+  template<class T>
+  using signal = ::boost::signals2::signal<T>;
+}
+}
+
+#endif
+
+#endif
index 7d8618a..32194f9 100644 (file)
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include <cmath>         /* std::isfinite() */
+
 #include <functional>
 
 #include "src/mc/mc_replay.h"
 #include "smx_private.h"
 #include "src/mc/mc_forward.h"
 #include "xbt/ex.h"
 #include <functional>
 
 #include "src/mc/mc_replay.h"
 #include "smx_private.h"
 #include "src/mc/mc_forward.h"
 #include "xbt/ex.h"
-#include <math.h>         /* isfinite() */
 #include "mc/mc.h"
 #include "src/simix/smx_host_private.h"
 #include "src/simix/smx_private.hpp"
 #include "mc/mc.h"
 #include "src/simix/smx_host_private.h"
 #include "src/simix/smx_private.hpp"
@@ -122,8 +123,8 @@ smx_synchro_t simcall_process_execute(const char *name,
                                     double priority, double bound, unsigned long affinity_mask)
 {
   /* checking for infinite values */
                                     double priority, double bound, unsigned long affinity_mask)
 {
   /* checking for infinite values */
-  xbt_assert(isfinite(flops_amount), "flops_amount is not finite!");
-  xbt_assert(isfinite(priority), "priority is not finite!");
+  xbt_assert(std::isfinite(flops_amount), "flops_amount is not finite!");
+  xbt_assert(std::isfinite(priority), "priority is not finite!");
 
   return simcall_BODY_process_execute(name, flops_amount, priority, bound, affinity_mask);
 }
 
   return simcall_BODY_process_execute(name, flops_amount, priority, bound, affinity_mask);
 }
@@ -154,15 +155,15 @@ smx_synchro_t simcall_process_parallel_execute(const char *name,
   int i,j;
   /* checking for infinite values */
   for (i = 0 ; i < host_nb ; ++i) {
   int i,j;
   /* checking for infinite values */
   for (i = 0 ; i < host_nb ; ++i) {
-     xbt_assert(isfinite(flops_amount[i]), "flops_amount[%d] is not finite!", i);
+     xbt_assert(std::isfinite(flops_amount[i]), "flops_amount[%d] is not finite!", i);
      for (j = 0 ; j < host_nb ; ++j) {
      for (j = 0 ; j < host_nb ; ++j) {
-        xbt_assert(isfinite(bytes_amount[i + host_nb * j]),
+        xbt_assert(std::isfinite(bytes_amount[i + host_nb * j]),
              "bytes_amount[%d+%d*%d] is not finite!", i, host_nb, j);
      }
   }
 
              "bytes_amount[%d+%d*%d] is not finite!", i, host_nb, j);
      }
   }
 
-  xbt_assert(isfinite(amount), "amount is not finite!");
-  xbt_assert(isfinite(rate), "rate is not finite!");
+  xbt_assert(std::isfinite(amount), "amount is not finite!");
+  xbt_assert(std::isfinite(rate), "rate is not finite!");
 
   return simcall_BODY_process_parallel_execute(name, host_nb, host_list,
                                             flops_amount,
 
   return simcall_BODY_process_parallel_execute(name, host_nb, host_list,
                                             flops_amount,
@@ -230,7 +231,7 @@ e_smx_state_t simcall_process_execution_get_state(smx_synchro_t execution)
 void simcall_process_execution_set_priority(smx_synchro_t execution, double priority)
 {
   /* checking for infinite values */
 void simcall_process_execution_set_priority(smx_synchro_t execution, double priority)
 {
   /* checking for infinite values */
-  xbt_assert(isfinite(priority), "priority is not finite!");
+  xbt_assert(std::isfinite(priority), "priority is not finite!");
 
   simcall_BODY_process_execution_set_priority(execution, priority);
 }
 
   simcall_BODY_process_execution_set_priority(execution, priority);
 }
@@ -720,7 +721,7 @@ XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process)
 e_smx_state_t simcall_process_sleep(double duration)
 {
   /* checking for infinite values */
 e_smx_state_t simcall_process_sleep(double duration)
 {
   /* checking for infinite values */
-  xbt_assert(isfinite(duration), "duration is not finite!");
+  xbt_assert(std::isfinite(duration), "duration is not finite!");
   return (e_smx_state_t) simcall_BODY_process_sleep(duration);
 }
 
   return (e_smx_state_t) simcall_BODY_process_sleep(duration);
 }
 
@@ -804,9 +805,9 @@ void simcall_comm_send(smx_process_t sender, smx_rdv_t rdv, double task_size, do
                          double timeout)
 {
   /* checking for infinite values */
                          double timeout)
 {
   /* checking for infinite values */
-  xbt_assert(isfinite(task_size), "task_size is not finite!");
-  xbt_assert(isfinite(rate), "rate is not finite!");
-  xbt_assert(isfinite(timeout), "timeout is not finite!");
+  xbt_assert(std::isfinite(task_size), "task_size is not finite!");
+  xbt_assert(std::isfinite(rate), "rate is not finite!");
+  xbt_assert(std::isfinite(timeout), "timeout is not finite!");
 
   xbt_assert(rdv, "No rendez-vous point defined for send");
 
 
   xbt_assert(rdv, "No rendez-vous point defined for send");
 
@@ -836,8 +837,8 @@ smx_synchro_t simcall_comm_isend(smx_process_t sender, smx_rdv_t rdv, double tas
                               int detached)
 {
   /* checking for infinite values */
                               int detached)
 {
   /* checking for infinite values */
-  xbt_assert(isfinite(task_size), "task_size is not finite!");
-  xbt_assert(isfinite(rate), "rate is not finite!");
+  xbt_assert(std::isfinite(task_size), "task_size is not finite!");
+  xbt_assert(std::isfinite(rate), "rate is not finite!");
 
   xbt_assert(rdv, "No rendez-vous point defined for isend");
 
 
   xbt_assert(rdv, "No rendez-vous point defined for isend");
 
@@ -854,7 +855,7 @@ void simcall_comm_recv(smx_process_t receiver, smx_rdv_t rdv, void *dst_buff, si
                        void (*copy_data_fun)(smx_synchro_t, void*, size_t),
                        void *data, double timeout, double rate)
 {
                        void (*copy_data_fun)(smx_synchro_t, void*, size_t),
                        void *data, double timeout, double rate)
 {
-  xbt_assert(isfinite(timeout), "timeout is not finite!");
+  xbt_assert(std::isfinite(timeout), "timeout is not finite!");
   xbt_assert(rdv, "No rendez-vous point defined for recv");
 
   if (MC_is_active() || MC_record_replay_is_active()) {
   xbt_assert(rdv, "No rendez-vous point defined for recv");
 
   if (MC_is_active() || MC_record_replay_is_active()) {
@@ -926,7 +927,7 @@ int simcall_comm_testany(xbt_dynar_t comms)
  */
 void simcall_comm_wait(smx_synchro_t comm, double timeout)
 {
  */
 void simcall_comm_wait(smx_synchro_t comm, double timeout)
 {
-  xbt_assert(isfinite(timeout), "timeout is not finite!");
+  xbt_assert(std::isfinite(timeout), "timeout is not finite!");
   simcall_BODY_comm_wait(comm, timeout);
 }
 
   simcall_BODY_comm_wait(comm, timeout);
 }
 
@@ -1108,7 +1109,7 @@ void simcall_cond_wait_timeout(smx_cond_t cond,
                                  smx_mutex_t mutex,
                                  double timeout)
 {
                                  smx_mutex_t mutex,
                                  double timeout)
 {
-  xbt_assert(isfinite(timeout), "timeout is not finite!");
+  xbt_assert(std::isfinite(timeout), "timeout is not finite!");
   simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
 }
 
   simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
 }
 
@@ -1172,7 +1173,7 @@ void simcall_sem_acquire(smx_sem_t sem)
  */
 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
 {
  */
 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
 {
-  xbt_assert(isfinite(timeout), "timeout is not finite!");
+  xbt_assert(std::isfinite(timeout), "timeout is not finite!");
   simcall_BODY_sem_acquire_timeout(sem, timeout);
 }
 
   simcall_BODY_sem_acquire_timeout(sem, timeout);
 }
 
index e50e704..d8fd429 100644 (file)
@@ -31,7 +31,7 @@ Cpu *getActionCpu(CpuAction *action) {
                                         action->getVariable(), 0)));
 }
 
                                         action->getVariable(), 0)));
 }
 
-simgrid::surf::signal<void(CpuAction*, e_surf_action_state_t, e_surf_action_state_t)> cpuActionStateChangedCallbacks;
+simgrid::xbt::signal<void(CpuAction*, e_surf_action_state_t, e_surf_action_state_t)> cpuActionStateChangedCallbacks;
 
 void cpu_add_traces(){
   surf_cpu_model_pm->addTraces();
 
 void cpu_add_traces(){
   surf_cpu_model_pm->addTraces();
@@ -349,7 +349,7 @@ void CpuAction::setAffinity(Cpu *cpu, unsigned long mask)
   XBT_OUT();
 }
 
   XBT_OUT();
 }
 
-simgrid::surf::signal<void(simgrid::surf::CpuAction*, e_surf_action_state_t, e_surf_action_state_t)> CpuAction::onStateChange;
+simgrid::xbt::signal<void(simgrid::surf::CpuAction*, e_surf_action_state_t, e_surf_action_state_t)> CpuAction::onStateChange;
 
 void CpuAction::setState(e_surf_action_state_t state){
   e_surf_action_state_t old = getState();
 
 void CpuAction::setState(e_surf_action_state_t state){
   e_surf_action_state_t old = getState();
index 861ab24..38c6c70 100644 (file)
@@ -178,7 +178,7 @@ public:
 /** @brief Callbacks handler which emit the callbacks after CpuAction State changed *
  * @details Callback functions have the following signature: `void(CpuAction *action, e_surf_action_state_t old, e_surf_action_state_t current)`
  */
 /** @brief Callbacks handler which emit the callbacks after CpuAction State changed *
  * @details Callback functions have the following signature: `void(CpuAction *action, e_surf_action_state_t old, e_surf_action_state_t current)`
  */
-  static simgrid::surf::signal<void(simgrid::surf::CpuAction*, e_surf_action_state_t, e_surf_action_state_t)> onStateChange;
+  static simgrid::xbt::signal<void(simgrid::surf::CpuAction*, e_surf_action_state_t, e_surf_action_state_t)> onStateChange;
 
   /** @brief CpuAction constructor */
   CpuAction(simgrid::surf::Model *model, double cost, bool failed)
 
   /** @brief CpuAction constructor */
   CpuAction(simgrid::surf::Model *model, double cost, bool failed)
index 9fa8022..ae57db2 100644 (file)
@@ -82,9 +82,9 @@ void HostModel::adjustWeightOfDummyCpuActions()
 /************
  * Resource *
  ************/
 /************
  * Resource *
  ************/
-simgrid::surf::signal<void(simgrid::surf::Host*)> Host::onCreation;
-simgrid::surf::signal<void(simgrid::surf::Host*)> Host::onDestruction;
-simgrid::surf::signal<void(simgrid::surf::Host*)> Host::onStateChange;
+simgrid::xbt::signal<void(simgrid::surf::Host*)> Host::onCreation;
+simgrid::xbt::signal<void(simgrid::surf::Host*)> Host::onDestruction;
+simgrid::xbt::signal<void(simgrid::surf::Host*)> Host::onStateChange;
 
 void Host::classInit()
 {
 
 void Host::classInit()
 {
index 16bdb11..02f977f 100644 (file)
@@ -79,9 +79,9 @@ public:
   static simgrid::xbt::Extension<simgrid::Host, Host> EXTENSION_ID;
 
   /* callbacks */
   static simgrid::xbt::Extension<simgrid::Host, Host> EXTENSION_ID;
 
   /* callbacks */
-  static simgrid::surf::signal<void(Host*)> onCreation;    /** Called on each newly created object */
-  static simgrid::surf::signal<void(Host*)> onDestruction; /** Called just before destructing an object */
-  static simgrid::surf::signal<void(Host*)> onStateChange; /** Called when the machine is turned on or off */
+  static simgrid::xbt::signal<void(Host*)> onCreation;    /** Called on each newly created object */
+  static simgrid::xbt::signal<void(Host*)> onDestruction; /** Called just before destructing an object */
+  static simgrid::xbt::signal<void(Host*)> onStateChange; /** Called when the machine is turned on or off */
 
 public:
   static void classInit(); // must be called before the first use of that class
 
 public:
   static void classInit(); // must be called before the first use of that class
index 236a8ac..c7a81c5 100644 (file)
@@ -95,12 +95,12 @@ void Link::linksExit() {
  * Callbacks *
  *************/
 
  * Callbacks *
  *************/
 
-simgrid::surf::signal<void(simgrid::surf::Link*)> Link::onCreation;
-simgrid::surf::signal<void(simgrid::surf::Link*)> Link::onDestruction;
-simgrid::surf::signal<void(simgrid::surf::Link*, int, int)> Link::onStateChange; // signature: wasOn, currentlyOn
+simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onCreation;
+simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onDestruction;
+simgrid::xbt::signal<void(simgrid::surf::Link*, int, int)> Link::onStateChange; // signature: wasOn, currentlyOn
 
 
-simgrid::surf::signal<void(simgrid::surf::NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)> networkActionStateChangedCallbacks;
-simgrid::surf::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, double size, double rate)> networkCommunicateCallbacks;
+simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)> networkActionStateChangedCallbacks;
+simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, double size, double rate)> networkCommunicateCallbacks;
 
 }
 }
 
 }
 }
index cf080ee..a229068 100644 (file)
@@ -36,11 +36,11 @@ class NetworkAction;
 
 /** @brief Callback signal fired when the state of a NetworkAction changes
  *  Signature: `void(NetworkAction *action, e_surf_action_state_t old, e_surf_action_state_t current)` */
 
 /** @brief Callback signal fired when the state of a NetworkAction changes
  *  Signature: `void(NetworkAction *action, e_surf_action_state_t old, e_surf_action_state_t current)` */
-XBT_PUBLIC_DATA(simgrid::surf::signal<void(simgrid::surf::NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)>) networkActionStateChangedCallbacks;
+XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)>) networkActionStateChangedCallbacks;
 
 /** @brief Callback signal fired when a NetworkAction is created (when a communication starts)
  *  Signature: `void(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst, double size, double rate)` */
 
 /** @brief Callback signal fired when a NetworkAction is created (when a communication starts)
  *  Signature: `void(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst, double size, double rate)` */
-XBT_PUBLIC_DATA(simgrid::surf::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, double size, double rate)>) networkCommunicateCallbacks;
+XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, double size, double rate)>) networkCommunicateCallbacks;
 
 }
 }
 
 }
 }
@@ -207,15 +207,15 @@ private:
 public:
   /** @brief Callback signal fired when a new Link is created.
    *  Signature: void(Link*) */
 public:
   /** @brief Callback signal fired when a new Link is created.
    *  Signature: void(Link*) */
-  static simgrid::surf::signal<void(simgrid::surf::Link*)> onCreation;
+  static simgrid::xbt::signal<void(simgrid::surf::Link*)> onCreation;
 
   /** @brief Callback signal fired when a Link is destroyed.
    *  Signature: void(Link*) */
 
   /** @brief Callback signal fired when a Link is destroyed.
    *  Signature: void(Link*) */
-  static simgrid::surf::signal<void(simgrid::surf::Link*)> onDestruction;
+  static simgrid::xbt::signal<void(simgrid::surf::Link*)> onDestruction;
 
   /** @brief Callback signal fired when the state of a Link changes
    *  Signature: `void(LinkAction *action, int previouslyOn, int currentlyOn)` */
 
   /** @brief Callback signal fired when the state of a Link changes
    *  Signature: `void(LinkAction *action, int previouslyOn, int currentlyOn)` */
-  static simgrid::surf::signal<void(simgrid::surf::Link*, int, int)> onStateChange;
+  static simgrid::xbt::signal<void(simgrid::surf::Link*, int, int)> onStateChange;
 
 
   /** @brief Get the bandwidth in bytes per second of current Link */
 
 
   /** @brief Get the bandwidth in bytes per second of current Link */
index e9a35b7..d0d1cb9 100644 (file)
@@ -28,10 +28,10 @@ namespace surf {
  * Callbacks *
  *************/
 
  * Callbacks *
  *************/
 
-simgrid::surf::signal<void(simgrid::surf::Storage*)> storageCreatedCallbacks;
-simgrid::surf::signal<void(simgrid::surf::Storage*)> storageDestructedCallbacks;
-simgrid::surf::signal<void(simgrid::surf::Storage*, int, int)> storageStateChangedCallbacks; // signature: wasOn, isOn
-simgrid::surf::signal<void(simgrid::surf::StorageAction*, e_surf_action_state_t, e_surf_action_state_t)> storageActionStateChangedCallbacks;
+simgrid::xbt::signal<void(simgrid::surf::Storage*)> storageCreatedCallbacks;
+simgrid::xbt::signal<void(simgrid::surf::Storage*)> storageDestructedCallbacks;
+simgrid::xbt::signal<void(simgrid::surf::Storage*, int, int)> storageStateChangedCallbacks; // signature: wasOn, isOn
+simgrid::xbt::signal<void(simgrid::surf::StorageAction*, e_surf_action_state_t, e_surf_action_state_t)> storageActionStateChangedCallbacks;
 
 /*********
  * Model *
 
 /*********
  * Model *
index 125962e..545cb1b 100644 (file)
@@ -5,6 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <xbt/base.h>
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <xbt/base.h>
+#include <xbt/signal.hpp>
 
 #include "surf_interface.hpp"
 #include "src/surf/PropertyHolder.hpp"
 
 #include "surf_interface.hpp"
 #include "src/surf/PropertyHolder.hpp"
@@ -33,25 +34,25 @@ class StorageAction;
  * @brief Callbacks handler which emit the callbacks after Storage creation *
  * @details Callback functions have the following signature: `void(Storage*)`
  */
  * @brief Callbacks handler which emit the callbacks after Storage creation *
  * @details Callback functions have the following signature: `void(Storage*)`
  */
-XBT_PUBLIC_DATA(simgrid::surf::signal<void(simgrid::surf::Storage*)>) storageCreatedCallbacks;
+XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::Storage*)>) storageCreatedCallbacks;
 
 /** @ingroup SURF_callbacks
  * @brief Callbacks handler which emit the callbacks after Storage destruction *
  * @details Callback functions have the following signature: `void(StoragePtr)`
  */
 
 /** @ingroup SURF_callbacks
  * @brief Callbacks handler which emit the callbacks after Storage destruction *
  * @details Callback functions have the following signature: `void(StoragePtr)`
  */
-XBT_PUBLIC_DATA(simgrid::surf::signal<void(simgrid::surf::Storage*)>) storageDestructedCallbacks;
+XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::Storage*)>) storageDestructedCallbacks;
 
 /** @ingroup SURF_callbacks
  * @brief Callbacks handler which emit the callbacks after Storage State changed *
  * @details Callback functions have the following signature: `void(StorageAction *action, int previouslyOn, int currentlyOn)`
  */
 
 /** @ingroup SURF_callbacks
  * @brief Callbacks handler which emit the callbacks after Storage State changed *
  * @details Callback functions have the following signature: `void(StorageAction *action, int previouslyOn, int currentlyOn)`
  */
-XBT_PUBLIC_DATA(simgrid::surf::signal<void(simgrid::surf::Storage*, int, int)>) storageStateChangedCallbacks;
+XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::Storage*, int, int)>) storageStateChangedCallbacks;
 
 /** @ingroup SURF_callbacks
  * @brief Callbacks handler which emit the callbacks after StorageAction State changed *
  * @details Callback functions have the following signature: `void(StorageAction *action, e_surf_action_state_t old, e_surf_action_state_t current)`
  */
 
 /** @ingroup SURF_callbacks
  * @brief Callbacks handler which emit the callbacks after StorageAction State changed *
  * @details Callback functions have the following signature: `void(StorageAction *action, e_surf_action_state_t old, e_surf_action_state_t current)`
  */
-XBT_PUBLIC_DATA(simgrid::surf::signal<void(simgrid::surf::StorageAction*, e_surf_action_state_t, e_surf_action_state_t)>) storageActionStateChangedCallbacks;
+XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::StorageAction*, e_surf_action_state_t, e_surf_action_state_t)>) storageActionStateChangedCallbacks;
 
 /*********
  * Model *
 
 /*********
  * Model *
index b8d0eaf..6a004ce 100644 (file)
@@ -38,7 +38,7 @@ xbt_dict_t watched_hosts_lib;
 namespace simgrid {
 namespace surf {
 
 namespace simgrid {
 namespace surf {
 
-simgrid::surf::signal<void(void)> surfExitCallbacks;
+simgrid::xbt::signal<void(void)> surfExitCallbacks;
 
 }
 }
 
 }
 }
index ea0d647..f450f3b 100644 (file)
@@ -14,6 +14,9 @@
 
 #include <boost/function.hpp>
 #include <boost/intrusive/list.hpp>
 
 #include <boost/function.hpp>
 #include <boost/intrusive/list.hpp>
+
+#include <xbt/signal.hpp>
+
 #include "surf/trace_mgr.h"
 #include "xbt/lib.h"
 #include "surf/surf_routing.h"
 #include "surf/trace_mgr.h"
 #include "xbt/lib.h"
 #include "surf/surf_routing.h"
 #include "src/surf/surf_private.h"
 #include "src/internal_config.h"
 
 #include "src/surf/surf_private.h"
 #include "src/internal_config.h"
 
-#ifdef LIBSIGC
-#include <sigc++/sigc++.h>
-namespace simgrid {
-namespace surf {
-  // Wraps sigc++ signals with the interface of boost::signals2:
-  template<class T> class signal;
-  template<class R, class... P>
-  class signal<R(P...)> {
-  private:
-    sigc::signal<R, P...> sig_;
-  public:
-    template<class U> XBT_ALWAYS_INLINE
-    void connect(U&& slot)
-    {
-      sig_.connect(std::forward<U>(slot));
-    }
-    template<class Res, class... Args> XBT_ALWAYS_INLINE
-    void connect(Res(*slot)(Args...))
-    {
-      sig_.connect(sigc::ptr_fun(slot));
-    }
-    template<class... Args> XBT_ALWAYS_INLINE
-    R operator()(Args&&... args) const
-    {
-      return sig_.emit(std::forward<Args>(args)...);
-    }
-  };
-}
-}
-#else
-#include <boost/signals2.hpp>
-namespace simgrid {
-namespace surf {
-  template<class T>
-  using signal = ::boost::signals2::signal<T>;
-}
-}
-#endif
-
 extern XBT_PRIVATE tmgr_history_t history;
 #define NO_MAX_DURATION -1.0
 
 extern XBT_PRIVATE tmgr_history_t history;
 #define NO_MAX_DURATION -1.0
 
@@ -86,7 +50,7 @@ extern XBT_PRIVATE double sg_sender_gap;
 namespace simgrid {
 namespace surf {
 
 namespace simgrid {
 namespace surf {
 
-extern XBT_PRIVATE simgrid::surf::signal<void(void)> surfExitCallbacks;
+extern XBT_PRIVATE simgrid::xbt::signal<void(void)> surfExitCallbacks;
 
 }
 }
 
 }
 }
index b79cae7..af1ceee 100644 (file)
@@ -23,8 +23,8 @@
 namespace simgrid {
 namespace surf {
 
 namespace simgrid {
 namespace surf {
 
-simgrid::surf::signal<void(simgrid::surf::NetCard*)> routingEdgeCreatedCallbacks;
-simgrid::surf::signal<void(simgrid::surf::As*)> asCreatedCallbacks;
+simgrid::xbt::signal<void(simgrid::surf::NetCard*)> routingEdgeCreatedCallbacks;
+simgrid::xbt::signal<void(simgrid::surf::As*)> asCreatedCallbacks;
 
 }
 }
 
 }
 }
index 721888d..c5d0d5d 100644 (file)
@@ -8,6 +8,7 @@
 #define NETWORK_ROUTING_HPP_
 
 #include <xbt/base.h>
 #define NETWORK_ROUTING_HPP_
 
 #include <xbt/base.h>
+#include <xbt/signal.hpp>
 
 #include "surf_interface.hpp"
 #include <float.h>
 
 #include "surf_interface.hpp"
 #include <float.h>
@@ -149,8 +150,8 @@ public:
  * Callbacks *
  *************/
 
  * Callbacks *
  *************/
 
-XBT_PUBLIC_DATA(simgrid::surf::signal<void(NetCard*)>) routingEdgeCreatedCallbacks;
-XBT_PUBLIC_DATA(simgrid::surf::signal<void(As*)>) asCreatedCallbacks;
+XBT_PUBLIC_DATA(simgrid::xbt::signal<void(NetCard*)>) routingEdgeCreatedCallbacks;
+XBT_PUBLIC_DATA(simgrid::xbt::signal<void(As*)>) asCreatedCallbacks;
 
 }
 }
 
 }
 }
index 87755ce..4c25e53 100644 (file)
@@ -19,9 +19,9 @@ namespace surf {
  * Callbacks *
  *************/
 
  * Callbacks *
  *************/
 
-simgrid::surf::signal<void(simgrid::surf::VirtualMachine*)> VMCreatedCallbacks;
-simgrid::surf::signal<void(simgrid::surf::VirtualMachine*)> VMDestructedCallbacks;
-simgrid::surf::signal<void(simgrid::surf::VirtualMachine*)> VMStateChangedCallbacks;
+simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> VMCreatedCallbacks;
+simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> VMDestructedCallbacks;
+simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> VMStateChangedCallbacks;
 
 /*********
  * Model *
 
 /*********
  * Model *
index c28b44d..99f1e39 100644 (file)
@@ -31,17 +31,17 @@ class XBT_PRIVATE VirtualMachine;
 /** @ingroup SURF_callbacks
  * @brief Callbacks fired after VM creation. Signature: `void(VirtualMachine*)`
  */
 /** @ingroup SURF_callbacks
  * @brief Callbacks fired after VM creation. Signature: `void(VirtualMachine*)`
  */
-extern XBT_PRIVATE simgrid::surf::signal<void(simgrid::surf::VirtualMachine*)> VMCreatedCallbacks;
+extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> VMCreatedCallbacks;
 
 /** @ingroup SURF_callbacks
  * @brief Callbacks fired after VM destruction. Signature: `void(VirtualMachine*)`
  */
 
 /** @ingroup SURF_callbacks
  * @brief Callbacks fired after VM destruction. Signature: `void(VirtualMachine*)`
  */
-extern XBT_PRIVATE simgrid::surf::signal<void(simgrid::surf::VirtualMachine*)> VMDestructedCallbacks;
+extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> VMDestructedCallbacks;
 
 /** @ingroup SURF_callbacks
  * @brief Callbacks after VM State changes. Signature: `void(VirtualMachine*)`
  */
 
 /** @ingroup SURF_callbacks
  * @brief Callbacks after VM State changes. Signature: `void(VirtualMachine*)`
  */
-extern XBT_PRIVATE simgrid::surf::signal<void(simgrid::surf::VirtualMachine*)> VMStateChangedCallbacks;
+extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> VMStateChangedCallbacks;
 
 /************
  * Resource *
 
 /************
  * Resource *
index 2dbc52e..b21a0ce 100644 (file)
@@ -73,6 +73,7 @@ endif()
 if(HAVE_LIBSIGC++)
   SET(SIMGRID_DEP "${SIMGRID_DEP} -lsigc-2.0")
   add_definitions(-DLIBSIGC)
 if(HAVE_LIBSIGC++)
   SET(SIMGRID_DEP "${SIMGRID_DEP} -lsigc-2.0")
   add_definitions(-DLIBSIGC)
+  set(SIMGRID_HAVE_LIBSIG 1)
 endif()
 
 if(HAVE_MC)
 endif()
 
 if(HAVE_MC)