Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Ouups, forgot those two files, bummer
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 30 Jun 2009 23:34:26 +0000 (23:34 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 30 Jun 2009 23:34:26 +0000 (23:34 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6415 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/surf/surf_model.c [new file with mode: 0644]
src/surf/surf_resource.c [new file with mode: 0644]

diff --git a/src/surf/surf_model.c b/src/surf/surf_model.c
new file mode 100644 (file)
index 0000000..02104c2
--- /dev/null
@@ -0,0 +1,61 @@
+
+/* Copyright (c) 2009 The SimGrid Team. All rights reserved.                */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "surf_private.h"
+#include "xbt/dict.h"
+
+static void void_die_impossible_paction(surf_action_t action)
+{
+  DIE_IMPOSSIBLE;
+}
+
+static int int_die_impossible_paction(surf_action_t action)
+{
+  DIE_IMPOSSIBLE;
+}
+
+/** @brief initialize common datastructures to all models */
+surf_model_t surf_model_init(void)
+{
+  s_surf_action_t action;
+  surf_model_t model = xbt_new0(s_surf_model_t, 1);
+
+  model->model_private = xbt_new0(s_surf_model_private_t, 1);
+
+  model->states.ready_action_set =
+    xbt_swag_new(xbt_swag_offset(action, state_hookup));
+  model->states.running_action_set =
+    xbt_swag_new(xbt_swag_offset(action, state_hookup));
+  model->states.failed_action_set =
+    xbt_swag_new(xbt_swag_offset(action, state_hookup));
+  model->states.done_action_set =
+    xbt_swag_new(xbt_swag_offset(action, state_hookup));
+  model->resource_set = xbt_dict_new();
+
+  model->action_free = int_die_impossible_paction;
+  model->action_cancel = void_die_impossible_paction;
+  model->action_recycle = void_die_impossible_paction;
+
+  return model;
+}
+/** @brief finalize common datastructures to all models */
+void surf_model_exit(surf_model_t model)
+{
+  xbt_swag_free(model->states.ready_action_set);
+  xbt_swag_free(model->states.running_action_set);
+  xbt_swag_free(model->states.failed_action_set);
+  xbt_swag_free(model->states.done_action_set);
+  xbt_dict_free(&model->resource_set);
+  free(model->model_private);
+  free(model);
+}
+
+void *surf_model_resource_by_name(surf_model_t model, const char *name)
+{
+  return xbt_dict_get_or_null(model->resource_set, name);
+}
+
+
diff --git a/src/surf/surf_resource.c b/src/surf/surf_resource.c
new file mode 100644 (file)
index 0000000..111408b
--- /dev/null
@@ -0,0 +1,20 @@
+
+/* Copyright (c) 2009 The SimGrid Team. All rights reserved.                */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "surf_private.h"
+#include "xbt/dict.h"
+
+void surf_resource_free(void* r) {
+  surf_resource_t resource = r;
+  if (resource->name)
+    free(resource->name);
+  free(resource);
+}
+
+const char *surf_resource_name(const void *resource) {
+  return ((surf_resource_t)resource)->name;
+}
+