Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add surf_cpu_init_im_bypass to be used to bypass the parser without passing through...
[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, char *name, xbt_dict_t props) {
15   surf_resource_t res = xbt_malloc0(childsize);
16   res->model = model;
17   res->name = name;
18   res->properties = props;
19   return res;
20 }
21
22 static XBT_INLINE void surf_resource_free(void* r) {
23   surf_resource_t resource = r;
24   if (resource->name)
25     free(resource->name);
26   if (resource->properties)
27     xbt_dict_free(&resource->properties);
28   free(resource);
29 }
30
31 static XBT_INLINE const char *surf_resource_name(const void *resource) {
32   return ((surf_resource_t)resource)->name;
33 }
34
35 static XBT_INLINE xbt_dict_t surf_resource_properties(const void *resource) {
36   return ((surf_resource_t)resource)->properties;
37 }
38
39 #endif /* SURF_RESOURCE_H */