Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow to specify the parameters on the command line, when the test is not run from...
[simgrid.git] / examples / cpp / actor-create / s4u-actor-create.cpp
index 1875ae3..a3c1f38 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2023. 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. */
@@ -90,7 +90,7 @@ int main(int argc, char** argv)
   sg4::Engine e(&argc, argv);
 
   /* Then you should load a platform file, describing your simulated platform */
-  e.load_platform("../../platforms/small_platform.xml");
+  e.load_platform(argc > 1 ? argv[1] : "../../platforms/small_platform.xml");
 
   /* And now you have to ask SimGrid to actually start your actors.
    *
@@ -98,15 +98,15 @@ int main(int argc, char** argv)
    * as we do here for the receiver actors. This function can take any kind of parameters, as
    * long as the last parameters of Actor::create() match what your function expects.
    */
-  sg4::Actor::create("receiver", sg4::Host::by_name("Fafard"), &receiver, "mb42");
+  sg4::Actor::create("receiver", e.host_by_name("Fafard"), &receiver, "mb42");
 
   /* If your actor is getting more complex, you probably want to implement it as a class instead,
    * as we do here for the sender actors. The main behavior goes into operator()() of the class.
    *
    * You can then directly start your actor, as follows: */
-  sg4::Actor::create("sender1", sg4::Host::by_name("Tremblay"), Sender());
+  sg4::Actor::create("sender1", e.host_by_name("Tremblay"), Sender());
   /* If you want to pass parameters to your class, that's very easy: just use your constructors */
-  sg4::Actor::create("sender2", sg4::Host::by_name("Jupiter"), Sender("GloubiBoulga"));
+  sg4::Actor::create("sender2", e.host_by_name("Jupiter"), Sender("GloubiBoulga"));
 
   /* But starting actors directly is considered as a bad experimental habit, since it ties the code
    * you want to test with the experimental scenario. Starting your actors from an external deployment
@@ -118,7 +118,7 @@ int main(int argc, char** argv)
   e.register_actor<Sender>("sender"); // The sender class is passed as a template parameter here
   e.register_function("forwarder", &forwarder);
   /* Once actors and functions are registered, just load the deployment file */
-  e.load_deployment("s4u-actor-create_d.xml");
+  e.load_deployment(argc > 2 ? argv[2] : "s4u-actor-create_d.xml");
 
   /* Once every actors are started in the engine, the simulation can start */
   e.run();