Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into fix/execute_benched
[simgrid.git] / src / smpi / include / smpi_f2c.hpp
1 /* Handle Fortan - C conversion for MPI Types*/
2
3 /* Copyright (c) 2010, 2013-2017. The SimGrid Team.
4  * All rights reserved.                                                     */
5
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. */
8
9 #ifndef SMPI_F2C_HPP_INCLUDED
10 #define SMPI_F2C_HPP_INCLUDED
11
12 #include <unordered_map>
13
14 #define KEY_SIZE (sizeof(int) * 2 + 1)
15
16 namespace simgrid{
17 namespace smpi{
18
19 class F2C {
20   private:
21     // We use a single lookup table for every type.
22     // Beware of collisions if id in mpif.h is not unique
23     static std::unordered_map<std::string, F2C*>* f2c_lookup_;
24     static int f2c_id_;
25   protected:
26     static std::unordered_map<std::string, F2C*>* f2c_lookup();
27     static void set_f2c_lookup(std::unordered_map<std::string, F2C*>* map);
28     static int f2c_id();
29     static void f2c_id_increment();
30   public:
31     static char* get_key(char* key, int id);
32     static char* get_key_id(char* key, int id);
33     static void delete_lookup();
34     static std::unordered_map<std::string, F2C*>* lookup();
35
36     virtual ~F2C() = default;
37
38     //Override these to handle specific values.
39     virtual int add_f();
40     static void free_f(int id);
41     virtual int c2f();
42
43     // This method should be overridden in all subclasses to avoid casting the result when calling it.
44     // For the default one, the MPI_*_NULL returned is assumed to be NULL.
45     static F2C* f2c(int id);
46 };
47
48 }
49 }
50
51 #endif