Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
625fd9ff9e6f78841c04621d609939fb1502c81b
[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,
15                                       xbt_dict_t props)
16 {
17   surf_resource_t res = xbt_malloc0(childsize);
18   res->model = model;
19   res->name = name;
20   res->properties = props;
21   return res;
22 }
23
24 static XBT_INLINE void surf_resource_free(void *r)
25 {
26   surf_resource_t resource = r;
27   if (resource->name)
28     free(resource->name);
29   if (resource->properties)
30     xbt_dict_free(&resource->properties);
31   free(resource);
32 }
33
34 static XBT_INLINE const char *surf_resource_name(const void *resource)
35 {
36   return ((surf_resource_t) resource)->name;
37 }
38
39 static XBT_INLINE xbt_dict_t surf_resource_properties(const void *resource)
40 {
41   return ((surf_resource_t) resource)->properties;
42 }
43
44 #endif                          /* SURF_RESOURCE_H */