2 /* Copyright (c) 2009 The SimGrid Team. All rights reserved. */
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. */
7 #include "surf_private.h"
10 static void void_die_impossible_paction(surf_action_t action)
15 static int int_die_impossible_paction(surf_action_t action)
20 /** @brief initialize common datastructures to all models */
21 surf_model_t surf_model_init(void)
23 s_surf_action_t action;
24 surf_model_t model = xbt_new0(s_surf_model_t, 1);
26 model->model_private = xbt_new0(s_surf_model_private_t, 1);
28 model->states.ready_action_set =
29 xbt_swag_new(xbt_swag_offset(action, state_hookup));
30 model->states.running_action_set =
31 xbt_swag_new(xbt_swag_offset(action, state_hookup));
32 model->states.failed_action_set =
33 xbt_swag_new(xbt_swag_offset(action, state_hookup));
34 model->states.done_action_set =
35 xbt_swag_new(xbt_swag_offset(action, state_hookup));
36 model->resource_set = xbt_dict_new();
38 model->action_unref = int_die_impossible_paction;
39 model->action_cancel = void_die_impossible_paction;
40 model->action_recycle = void_die_impossible_paction;
42 model->action_state_get = surf_action_state_get;
43 model->action_state_set = surf_action_state_set;
44 model->action_get_start_time = surf_action_get_start_time;
45 model->action_get_finish_time = surf_action_get_finish_time;
46 model->action_data_set = surf_action_data_set;
51 /** @brief finalize common datastructures to all models */
52 void surf_model_exit(surf_model_t model)
54 xbt_swag_free(model->states.ready_action_set);
55 xbt_swag_free(model->states.running_action_set);
56 xbt_swag_free(model->states.failed_action_set);
57 xbt_swag_free(model->states.done_action_set);
58 xbt_dict_free(&model->resource_set);
59 free(model->model_private);
63 void *surf_model_resource_by_name(surf_model_t model, const char *name)
65 return xbt_dict_get_or_null(model->resource_set, name);