Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ok, I stop trying to please sonar.
[simgrid.git] / src / smpi / smpi_f2c.hpp
1 /* Handle Fortan - C conversion for MPI Types*/
2
3 /* Copyright (c) 2010, 2013-2015. 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 "private.h"
13
14
15 #define KEY_SIZE (sizeof(int) * 2 + 1)
16
17 namespace simgrid{
18 namespace smpi{
19
20 class F2C {
21   private:
22     // We use a single lookup table for every type. 
23     // Beware of collisions if id in mpif.h is not unique
24     static xbt_dict_t f2c_lookup_;
25     static int f2c_id_;
26   protected:
27     static xbt_dict_t f2c_lookup();
28     static void set_f2c_lookup(xbt_dict_t dict);
29     static int f2c_id();
30     static void f2c_id_increment();
31   public:
32     static char* get_key(char* key, int id);
33     static char* get_key_id(char* key, int id);
34     static void delete_lookup();
35     static xbt_dict_t lookup();
36
37     //Override these to handle specific values.
38     int add_f();
39     static void free_f(int id);
40     int c2f();
41
42     //This method should be overriden in all subclasses
43     //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