Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove a level of indirection, and custom destructors for instr/jedule.
[simgrid.git] / src / instr / jedule / jedule_events.cpp
index afe12f3..2744fcd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2016. The SimGrid Team.
+/* Copyright (c) 2010-2019. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
 namespace simgrid{
 namespace jedule{
 
-Event::Event(std::string name, double start_time, double end_time, std::string type)
-  : name(name), start_time(start_time), end_time(end_time), type(type)
+void Event::add_resources(const std::vector<sg_host_t>& host_selection)
 {
-  this->resource_subsets = new std::vector<jed_subset_t>();
+  get_resource_selection_by_hosts(this->resource_subsets_, host_selection);
 }
 
-Event::~Event()
-{
-  if (not this->resource_subsets->empty()) {
-    for (auto subset: *this->resource_subsets)
-      delete subset;
-    delete this->resource_subsets;
-  }
-}
-
-void Event::addResources(std::vector<sg_host_t> *host_selection)
-{
-  get_resource_selection_by_hosts(this->resource_subsets, host_selection);
-}
-
-void Event::addCharacteristic(char *characteristic)
+void Event::add_characteristic(char* characteristic)
 {
   xbt_assert( characteristic != nullptr );
-  this->characteristics_list.push_back(characteristic);
+  this->characteristics_list_.push_back(characteristic);
 }
 
-void Event::addInfo(char* key, char *value) {
+void Event::add_info(char* key, char* value)
+{
   xbt_assert((key != nullptr) && value != nullptr);
-  this->info_map.insert({key, value});
+  this->info_map_.insert({key, value});
 }
 
-void Event::print(FILE *jed_file)
+void Event::print(FILE* jed_file) const
 {
   fprintf(jed_file, "    <event>\n");
-  fprintf(jed_file, "      <prop key=\"name\" value=\"%s\" />\n", this->name.c_str());
-  fprintf(jed_file, "      <prop key=\"start\" value=\"%g\" />\n", this->start_time);
-  fprintf(jed_file, "      <prop key=\"end\" value=\"%g\" />\n", this->end_time);
-  fprintf(jed_file, "      <prop key=\"type\" value=\"%s\" />\n", this->type.c_str());
+  fprintf(jed_file, "      <prop key=\"name\" value=\"%s\" />\n", this->name_.c_str());
+  fprintf(jed_file, "      <prop key=\"start\" value=\"%g\" />\n", this->start_time_);
+  fprintf(jed_file, "      <prop key=\"end\" value=\"%g\" />\n", this->end_time_);
+  fprintf(jed_file, "      <prop key=\"type\" value=\"%s\" />\n", this->type_.c_str());
 
-  xbt_assert(not this->resource_subsets->empty());
+  xbt_assert(not this->resource_subsets_.empty());
   fprintf(jed_file, "      <res_util>\n");
-  for (auto subset: *this->resource_subsets) {
+  for (auto const& subset : this->resource_subsets_) {
     fprintf(jed_file, "        <select resources=\"");
-    fprintf(jed_file, "%s", subset->parent->getHierarchyAsString().c_str());
-    fprintf(jed_file, ".[%d-%d]", subset->start_idx, subset->start_idx + subset->nres-1);
+    fprintf(jed_file, "%s", subset.parent->get_hierarchy_as_string().c_str());
+    fprintf(jed_file, ".[%d-%d]", subset.start_idx, subset.start_idx + subset.nres - 1);
     fprintf(jed_file, "\" />\n");
   }
   fprintf(jed_file, "      </res_util>\n");
 
-  if (not this->characteristics_list.empty()) {
+  if (not this->characteristics_list_.empty()) {
     fprintf(jed_file, "      <characteristics>\n");
-    for (auto ch: this->characteristics_list)
-      fprintf(jed_file, "          <characteristic name=\"%s\" />\n", ch);
+    for (auto const& ch : this->characteristics_list_)
+      fprintf(jed_file, "          <characteristic name=\"%s\" />\n", ch.c_str());
     fprintf(jed_file, "      </characteristics>\n");
   }
 
-  if (not this->info_map.empty()) {
+  if (not this->info_map_.empty()) {
     fprintf(jed_file, "      <info>\n");
-    for (auto elm: this->info_map)
-      fprintf(jed_file, "        <prop key=\"%s\" value=\"%s\" />\n",elm.first,elm.second);
+    for (auto const& elm : this->info_map_)
+      fprintf(jed_file, "        <prop key=\"%s\" value=\"%s\" />\n", elm.first.c_str(), elm.second.c_str());
     fprintf(jed_file, "      </info>\n");
   }