Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
aa72c4cfaf0d0e555f74aef0077e9a1b1535b020
[simgrid.git] / src / include / surf / surf_resource.h
1
2 /* Copyright (c) 2009, 2010. The SimGrid Team.
3  * All rights reserved.                                                     */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #include "surf/surf.h"
9 #ifndef SURF_RESOURCE_H
10 #define SURF_RESOURCE_H
11
12 static XBT_INLINE
13     surf_resource_t surf_resource_new(size_t childsize,
14                                       surf_model_t model, const char *name,
15                                       xbt_dict_t props)
16 {
17   surf_resource_t res = xbt_malloc0(childsize);
18   res->model = model;
19   res->name = xbt_strdup(name);
20   res->properties = props;
21   return res;
22 }
23 static XBT_INLINE void routing_storage_type_free(void *r)
24 {
25   storage_type_t stype = r;
26   free(stype->model);
27   free(stype->type_id);
28   xbt_dict_free(&(stype->properties));
29   xbt_dict_free(&(stype->content));
30   free(stype);
31 }
32
33 static XBT_INLINE void routing_storage_host_free(void *r)
34 {
35   xbt_dynar_t dyn = r;
36   xbt_dynar_free(&dyn);
37 }
38
39 static XBT_INLINE void surf_resource_free(void *r)
40 {
41   surf_resource_t resource = r;
42   free(resource->name);
43   xbt_dict_free(&resource->properties);
44   free(resource);
45 }
46
47 static XBT_INLINE const char *surf_resource_name(const void *resource)
48 {
49   return ((surf_resource_t) resource)->name;
50 }
51
52 static XBT_INLINE xbt_dict_t surf_resource_properties(const void *resource)
53 {
54   return ((surf_resource_t) resource)->properties;
55 }
56
57 #endif                          /* SURF_RESOURCE_H */