Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify the API between Engine and EngineImpl when registering functions
[simgrid.git] / include / simgrid / s4u / Engine.hpp
index 234a82b..e2e0c86 100644 (file)
@@ -25,6 +25,8 @@ namespace s4u {
  * This is a singleton containing all the main functions of the simulation.
  */
 class XBT_PUBLIC Engine {
+  friend simgrid::kernel::EngineImpl;
+
 public:
   /** Constructor, taking the command line parameters of your main function */
   explicit Engine(int* argc, char** argv);
@@ -48,24 +50,31 @@ public:
 
   void load_platform(const std::string& platf);
 
-  void register_function(const std::string& name, int (*code)(int, char**));
+  XBT_ATTRIB_DEPRECATED_v330("Please change the return code of your actors to void") void register_function(
+      const std::string& name, int (*code)(int, char**));
+
+  void register_function(const std::string& name, void (*code)(int, char**));
   void register_function(const std::string& name, void (*code)(std::vector<std::string>));
-  void register_default(int (*code)(int, char**));
 
+  XBT_ATTRIB_DEPRECATED_v330("Please change the return code of your actors to void") void register_default(
+      int (*code)(int, char**));
+  void register_default(void (*code)(int, char**));
+  void register_default(kernel::actor::ActorCodeFactory factory);
+
+  void register_function(const std::string& name, kernel::actor::ActorCodeFactory factory);
   template <class F> void register_actor(const std::string& name)
   {
-    simix::register_function(name, [](std::vector<std::string> args) {
-      return simix::ActorCode([args] {
+    register_function(name, [](std::vector<std::string> args) {
+      return kernel::actor::ActorCode([args] {
         F code(std::move(args));
         code();
       });
     });
   }
-
   template <class F> void register_actor(const std::string& name, F code)
   {
-    simix::register_function(name, [code](std::vector<std::string> args) {
-      return simix::ActorCode([code, args] { code(std::move(args)); });
+    register_function(name, [code](std::vector<std::string> args) {
+      return kernel::actor::ActorCode([code, args] { code(std::move(args)); });
     });
   }
 
@@ -91,8 +100,13 @@ protected:
 #endif /*DOXYGEN*/
 
 public:
+  /** Returns the amount of hosts existing in the platform. */
   size_t get_host_count();
-  /** @brief Returns the list of all hosts found in the platform */
+  /** Returns a vector of all hosts found in the platform.
+   *
+   * The order is generally different from the creation/declaration order in the XML platform because we use a hash
+   * table internally.
+   */
   std::vector<Host*> get_all_hosts();
   std::vector<Host*> get_filtered_hosts(const std::function<bool(Host*)>& filter);
   Host* host_by_name(const std::string& name);