X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/71d215251ec3eeb3e4192c0e14ec6dea8fd97007..cfbf3bda3a828313326d322fa92fb6719904d1a4:/src/smpi/mpi/smpi_info.cpp diff --git a/src/smpi/mpi/smpi_info.cpp b/src/smpi/mpi/smpi_info.cpp index 16b8c5355b..ed832a6e27 100644 --- a/src/smpi/mpi/smpi_info.cpp +++ b/src/smpi/mpi/smpi_info.cpp @@ -1,36 +1,29 @@ -/* Copyright (c) 2007-2018. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2007-2021. 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. */ #include "smpi_info.hpp" -#include "simgrid/exception.hpp" -#include "xbt/sysdep.h" +#include "simgrid/Exception.hpp" -namespace simgrid{ -namespace smpi{ +namespace simgrid { +namespace smpi { -Info::Info(Info* info) : map_(info->map_) +void Info::ref() { -} - -void Info::ref(){ refcount_++; } void Info::unref(Info* info){ info->refcount_--; if(info->refcount_==0){ + F2C::free_f(info->c2f()); delete info; } } -void Info::set(char *key, char *value){ - map_[key] = value; -} - -int Info::get(char *key, int valuelen, char *value, int *flag){ +int Info::get(const char* key, int valuelen, char* value, int* flag) const +{ *flag=false; auto val = map_.find(key); if (val != map_.end()) { @@ -40,25 +33,25 @@ int Info::get(char *key, int valuelen, char *value, int *flag){ memcpy(value, tmpvalue.c_str(), (tmpvalue.length() + 1 < static_cast(valuelen)) ? tmpvalue.length() + 1 : valuelen); *flag=true; - return MPI_SUCCESS; - } else { - return MPI_ERR_INFO_KEY; } + return MPI_SUCCESS; } -int Info::remove(char *key){ +int Info::remove(const char *key){ if (map_.erase(key) == 0) return MPI_ERR_INFO_NOKEY; else return MPI_SUCCESS; } -int Info::get_nkeys(int *nkeys){ +int Info::get_nkeys(int* nkeys) const +{ *nkeys = map_.size(); return MPI_SUCCESS; } -int Info::get_nthkey(int n, char *key){ +int Info::get_nthkey(int n, char* key) const +{ int num=0; for (auto const& elm : map_) { if (num == n) { @@ -70,16 +63,15 @@ int Info::get_nthkey(int n, char *key){ return MPI_ERR_ARG; } -int Info::get_valuelen(char *key, int *valuelen, int *flag){ +int Info::get_valuelen(const char* key, int* valuelen, int* flag) const +{ *flag=false; auto val = map_.find(key); if (val != map_.end()) { *valuelen = val->second.length(); *flag=true; - return MPI_SUCCESS; - } else { - return MPI_ERR_INFO_KEY; } + return MPI_SUCCESS; } Info* Info::f2c(int id){