Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
whatever, eclipse
[simgrid.git] / src / simgrid / host.cpp
1 /* Copyright (c) 2013-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include "xbt/dict.h"
8 #include "simgrid/host.h"
9 #include "surf/surf_routing.h" // SIMIX_HOST_LEVEL and friends FIXME: make private here
10
11 sg_host_t sg_host_by_name(const char *name){
12   return xbt_lib_get_elm_or_null(host_lib, name);
13 }
14
15 // ========= Layering madness ==============
16
17 int SIMIX_HOST_LEVEL;
18 int MSG_HOST_LEVEL;
19 int SURF_CPU_LEVEL;
20
21 #include "simix/smx_host_private.h" // SIMIX_host_destroy. FIXME: killme
22 #include "msg/msg_private.h" // MSG_host_priv_free. FIXME: killme
23 #include "surf/cpu_interface.hpp"
24
25 static XBT_INLINE void surf_cpu_free(void *r) {
26   delete static_cast<CpuPtr>(r);
27 }
28
29
30 void sg_host_init() {
31   SIMIX_HOST_LEVEL = xbt_lib_add_level(host_lib,SIMIX_host_destroy);
32   MSG_HOST_LEVEL = xbt_lib_add_level(host_lib, (void_f_pvoid_t) __MSG_host_priv_free);
33   SURF_CPU_LEVEL = xbt_lib_add_level(host_lib,surf_cpu_free);
34 }
35
36
37 // ========== MSG Layer ==============
38 msg_host_priv_t sg_host_msg(sg_host_t host) {
39         return (msg_host_priv_t) xbt_lib_get_level(host, MSG_HOST_LEVEL);
40 }
41 void sg_host_msg_set(sg_host_t host, msg_host_priv_t smx_host) {
42           xbt_lib_set(host_lib,host->key,MSG_HOST_LEVEL,smx_host);
43 }
44 void sg_host_msg_destroy(sg_host_t host) {
45           xbt_lib_unset(host_lib,host->key,MSG_HOST_LEVEL,1);
46 }
47
48 // ========== Simix layer =============
49
50 smx_host_priv_t sg_host_simix(sg_host_t host){
51   return (smx_host_priv_t) xbt_lib_get_level(host, SIMIX_HOST_LEVEL);
52 }
53 void sg_host_simix_set(sg_host_t host, smx_host_priv_t smx_host) {
54         xbt_lib_set(host_lib,host->key,SIMIX_HOST_LEVEL,smx_host);
55 }
56 void sg_host_simix_destroy(sg_host_t host) {
57         xbt_lib_unset(host_lib,host->key,SIMIX_HOST_LEVEL,1);
58 }
59
60 // ========== SURF CPU ============
61 surf_cpu_t sg_host_surfcpu(sg_host_t host) {
62         return (surf_cpu_t) xbt_lib_get_level(host, SURF_CPU_LEVEL);
63 }
64 void sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu) {
65         xbt_lib_set(host_lib, host->key, SURF_CPU_LEVEL, cpu);
66 }
67 void sg_host_surfcpu_destroy(sg_host_t host) {
68         xbt_lib_unset(host_lib,host->key,SURF_CPU_LEVEL,1);
69 }
70
71
72
73 /*
74 host::host() {
75         // TODO Auto-generated constructor stub
76
77 }
78
79 host::~host() {
80         // TODO Auto-generated destructor stub
81 }*/
82