1 /* Copyright (c) 2007-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
14 xbt_dict_t F2C::f2c_lookup_=nullptr;
17 char* F2C::get_key(char* key, int id) {
18 snprintf(key, KEY_SIZE, "%x",id);
22 char* F2C::get_key_id(char* key, int id) {
23 snprintf(key, KEY_SIZE, "%x_%d",id, smpi_process_index());
27 void F2C::delete_lookup(){
28 xbt_dict_free(&f2c_lookup_);
31 xbt_dict_t F2C::lookup(){
35 void F2C::free_f(int id){
37 xbt_dict_remove(f2c_lookup_, get_key(key, id));
41 if(f2c_lookup_==nullptr){
42 f2c_lookup_=xbt_dict_new_homogeneous(nullptr);
45 xbt_dict_set(f2c_lookup_, get_key(key, f2c_id_), this, nullptr);
51 if(f2c_lookup_==nullptr){
52 f2c_lookup_=xbt_dict_new_homogeneous(nullptr);
55 char* existing_key = xbt_dict_get_key(f2c_lookup_, this);
56 if(existing_key!=nullptr){
57 return atoi(existing_key);}
59 return this->add_f();}
62 F2C* F2C::f2c(int id){
63 if(f2c_lookup_==nullptr){
64 f2c_lookup_=xbt_dict_new_homogeneous(nullptr);
68 return static_cast<F2C*>(xbt_dict_get_or_null(f2c_lookup_, get_key(key, id)));