1 /* Copyright (c) 2007-2017. 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 xbt_dict_t F2C::f2c_lookup(){
21 void F2C::set_f2c_lookup(xbt_dict_t dict){
25 void F2C::f2c_id_increment(){
33 char* F2C::get_key(char* key, int id) {
34 snprintf(key, KEY_SIZE, "%x",id);
38 char* F2C::get_key_id(char* key, int id) {
39 snprintf(key, KEY_SIZE, "%x_%d",id, smpi_process()->index());
43 void F2C::delete_lookup(){
44 xbt_dict_free(&f2c_lookup_);
47 xbt_dict_t F2C::lookup(){
51 void F2C::free_f(int id){
53 xbt_dict_remove(f2c_lookup_, get_key(key, id));
57 if(f2c_lookup_==nullptr){
58 f2c_lookup_=xbt_dict_new_homogeneous(nullptr);
61 xbt_dict_set(f2c_lookup_, get_key(key, f2c_id_), this, nullptr);
67 if(f2c_lookup_==nullptr){
68 f2c_lookup_=xbt_dict_new_homogeneous(nullptr);
71 char* existing_key = xbt_dict_get_key(f2c_lookup_, this);
72 if(existing_key!=nullptr){
73 return atoi(existing_key);}
75 return this->add_f();}
78 F2C* F2C::f2c(int id){
79 if(f2c_lookup_==nullptr){
80 f2c_lookup_=xbt_dict_new_homogeneous(nullptr);
84 return static_cast<F2C*>(xbt_dict_get_or_null(f2c_lookup_, get_key(key, id)));