- auto* zone = sg4::create_full_zone("AS0");
- auto* host1 = zone->create_host("Host1", "1f");
- auto* host2 = zone->create_host("Host2", "1f");
+ auto* zone = sg4::create_full_zone("world");
+ std::vector<sg4::Host*> hosts;
+ for (const auto* name : {"Host1", "Host2", "Host3"}) {
+ auto* host = zone->create_host(name, "1f");
+ hosts.push_back(host);
+ }
+ /* Attaching a state profile (ie a list of events changing the on/off state of the resource) to host3.
+ * The syntax of the profile (second parameter) is a list of: "date state\n"
+ * The R"( )" thing is the C++ way of writing multiline strings, including literals \n.
+ * You'd have the same behavior by using "12 0\n20 1\n" instead.
+ * So here, the link is turned off at t=12 and back on at t=20.
+ * The last parameter is the period of that profile, meaning that it loops after 30 seconds.
+ */
+ hosts[1]->set_state_profile(simgrid::kernel::profile::ProfileBuilder::from_string("profile name", R"(
+12 0
+20 1
+)", 30));
+