Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
replace SIMIX_process_count by simgrid_get_actor_count
[simgrid.git] / src / s4u / s4u_Engine.cpp
index c92bdaa..ba96fac 100644 (file)
@@ -29,11 +29,11 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_engine, s4u, "Logging specific to S4U (engin
 
 namespace simgrid {
 namespace s4u {
-xbt::signal<void()> on_platform_creation;
-xbt::signal<void()> on_platform_created;
-xbt::signal<void()> on_simulation_end;
-xbt::signal<void(double)> on_time_advance;
-xbt::signal<void(void)> on_deadlock;
+xbt::signal<void()> Engine::on_platform_creation;
+xbt::signal<void()> Engine::on_platform_created;
+xbt::signal<void()> Engine::on_simulation_end;
+xbt::signal<void(double)> Engine::on_time_advance;
+xbt::signal<void(void)> Engine::on_deadlock;
 
 Engine* Engine::instance_ = nullptr; /* That singleton is awful, but I don't see no other solution right now. */
 
@@ -74,16 +74,11 @@ double Engine::get_clock()
 }
 
 /**
- * @brief A platform loader.
+ * Creates a new platform, including hosts, links, and the routing table.
  *
- * Creates a new platform, including hosts, links, and the routing_table.
- * @param platf a filename of the XML description of a platform. This file follows this DTD :
- *
- *     @include src/surf/xml/simgrid.dtd
- *
- * Here is a small example of such a platform
- *
- *     @include examples/platforms/small_platform.xml
+ * \rst
+ * See also: :ref:`platform`.
+ * \endrst
  */
 void Engine::load_platform(const std::string& platf)
 {
@@ -98,23 +93,36 @@ void Engine::load_platform(const std::string& platf)
   XBT_DEBUG("PARSE TIME: %g", (end - start));
 }
 
+/** Registers the main function of an actor that will be launched from the deployment file */
 void Engine::register_function(const std::string& name, int (*code)(int, char**))
 {
   SIMIX_function_register(name, code);
 }
+/** Registers the main function of an actor that will be launched from the deployment file */
 void Engine::register_function(const std::string& name, void (*code)(std::vector<std::string>))
 {
   SIMIX_function_register(name, code);
 }
+/** Registers a function as the default main function of actors
+ *
+ * It will be used as fallback when the function requested from the deployment file was not registered.
+ * It is used for trace-based simulations (see examples/s4u/replay-comms and similar).
+ */
 void Engine::register_default(int (*code)(int, char**))
 {
   SIMIX_function_register_default(code);
 }
+/** Load a deployment file and launch the actors that it contains
+ *
+ * \rst
+ * See also: :ref:`deploy`.
+ * \endrst
+ */
 void Engine::load_deployment(const std::string& deploy)
 {
   SIMIX_launch_application(deploy);
 }
-/** @brief Returns the amount of hosts in the platform */
+/** Returns the amount of hosts in the platform */
 size_t Engine::get_host_count()
 {
   return pimpl->hosts_.size();
@@ -211,25 +219,6 @@ std::vector<Storage*> Engine::get_all_storages()
   return res;
 }
 
-/** @brief Find a disk from its name.
- *
- *  @throw std::invalid_argument if the searched disk does not exist.
- */
-Disk* Engine::disk_by_name(const std::string& name)
-{
-  if (pimpl->disks_.find(name) == pimpl->disks_.end())
-    throw std::invalid_argument(std::string("Disk not found: ") + name);
-
-  return pimpl->disks_.at(name);
-}
-
-/** @brief Find a disk from its name (or nullptr if that disk does not exist) */
-Disk* Engine::disk_by_name_or_null(const std::string& name)
-{
-  auto disk = pimpl->disks_.find(name);
-  return disk == pimpl->disks_.end() ? nullptr : disk->second;
-}
-
 /** @brief Find a storage from its name.
  *
  *  @throw std::invalid_argument if the searched storage does not exist.
@@ -259,16 +248,6 @@ void Engine::storage_unregister(const std::string& name)
   pimpl->storages_.erase(name);
 }
 
-void Engine::disk_register(const std::string& name, Disk* disk)
-{
-  pimpl->disks_[name] = disk;
-}
-
-void Engine::disk_unregister(const std::string& name)
-{
-  pimpl->disks_.erase(name);
-}
-
 /** @brief Returns the amount of links in the platform */
 size_t Engine::get_link_count()
 {
@@ -436,3 +415,7 @@ double simgrid_get_clock()
 {
   return simgrid::s4u::Engine::get_clock();
 }
+int simgrid_get_actor_count()
+{
+  return simgrid::s4u::Engine::get_instance()->get_actor_count();
+}