X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fa15ed6668695b02e85ec71de10240199df84cc4..ea74f5d95928a521a588737e81f1de94eef25d19:/examples/cpp/actor-create/s4u-actor-create.cpp diff --git a/examples/cpp/actor-create/s4u-actor-create.cpp b/examples/cpp/actor-create/s4u-actor-create.cpp index 3373d82a03..15059a7471 100644 --- a/examples/cpp/actor-create/s4u-actor-create.cpp +++ b/examples/cpp/actor-create/s4u-actor-create.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2006-2022. 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. */ @@ -45,9 +45,9 @@ static void receiver(const std::string& mailbox_name) static void forwarder(int argc, char** argv) { xbt_assert(argc >= 3, "Actor forwarder requires 2 parameters, but got only %d", argc - 1); - sg4::Mailbox* in = sg4::Mailbox::by_name(argv[1]); - sg4::Mailbox* out = sg4::Mailbox::by_name(argv[2]); - auto* msg = in->get(); + sg4::Mailbox* in = sg4::Mailbox::by_name(argv[1]); + sg4::Mailbox* out = sg4::Mailbox::by_name(argv[2]); + auto* msg = in->get(); XBT_INFO("Forward '%s'.", msg->c_str()); out->put(msg, msg->size()); } @@ -60,11 +60,9 @@ static void forwarder(int argc, char** argv) class Sender { public: std::string mbox = "mb42"; - std::string msg = "GaBuZoMeu"; + std::string msg = "GaBuZoMeu"; explicit Sender() = default; /* Sending the default message */ - explicit Sender(const std::string& arg) : msg(arg) - { /* Sending the specified message */ - } + explicit Sender(const std::string& arg) : msg(arg) { /* Sending the specified message */} explicit Sender(std::vector args) { /* This constructor is used when we start the actor from the deployment file */ @@ -92,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(argv[1]); + e.load_platform("../../platforms/small_platform.xml"); /* And now you have to ask SimGrid to actually start your actors. * @@ -100,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