1 /* Handle Fortan - C conversion for MPI Types*/
3 /* Copyright (c) 2010-2019. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #ifndef SMPI_F2C_HPP_INCLUDED
10 #define SMPI_F2C_HPP_INCLUDED
12 #include <unordered_map>
15 #define KEY_SIZE (sizeof(int) * 2 + 1)
22 // We use a single lookup table for every type.
23 // Beware of collisions if id in mpif.h is not unique
24 static std::unordered_map<std::string, F2C*>* f2c_lookup_;
29 static std::unordered_map<std::string, F2C*>* f2c_lookup();
30 static void set_f2c_lookup(std::unordered_map<std::string, F2C*>* map);
32 static void f2c_id_increment();
35 char* get_my_key(char* key);
36 static char* get_key(char* key, int id);
37 static void delete_lookup();
38 static std::unordered_map<std::string, F2C*>* lookup();
39 F2C() : my_f2c_id_(-1){}
40 virtual ~F2C() = default;
42 //Override these to handle specific values.
44 static void free_f(int id);
46 static void print_f2c_lookup();
47 // This method should be overridden in all subclasses to avoid casting the result when calling it.
48 // For the default one, the MPI_*_NULL returned is assumed to be NULL.
49 static F2C* f2c(int id);