1 /* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "smpi_f2c.hpp"
8 #include "smpi_process.hpp"
15 std::unordered_map<std::string, F2C*>* F2C::f2c_lookup_ = nullptr;
18 std::unordered_map<std::string, F2C*>* F2C::f2c_lookup()
23 void F2C::set_f2c_lookup(std::unordered_map<std::string, F2C*>* map)
28 void F2C::f2c_id_increment(){
36 char* F2C::get_key(char* key, int id) {
37 std::snprintf(key, KEY_SIZE, "%x", static_cast<unsigned>(id));
41 char* F2C::get_key_id(char* key, int id) {
42 std::snprintf(key, KEY_SIZE, "%x_%d", static_cast<unsigned>(id), smpi_process()->index());
46 void F2C::delete_lookup(){
50 std::unordered_map<std::string, F2C*>* F2C::lookup()
55 void F2C::free_f(int id)
58 f2c_lookup_->erase(get_key(key, id));
63 if (f2c_lookup_ == nullptr)
64 f2c_lookup_ = new std::unordered_map<std::string, F2C*>;
67 (*f2c_lookup_)[get_key(key, f2c_id_)] = this;
74 if (f2c_lookup_ == nullptr) {
75 f2c_lookup_ = new std::unordered_map<std::string, F2C*>;
78 for (auto elm : *f2c_lookup_)
79 if (elm.second == this)
80 return std::stoi(elm.first);
82 /* this function wasn't found, add it */
88 if (f2c_lookup_ == nullptr)
89 f2c_lookup_ = new std::unordered_map<std::string, F2C*>;
94 return f2c_lookup_->at(get_key(key, id));
95 } catch (std::out_of_range& unfound) {