Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reimplement SIMIX_host_get_dict.
authornavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 24 Mar 2011 10:36:31 +0000 (10:36 +0000)
committernavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 24 Mar 2011 10:36:31 +0000 (10:36 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9845 48e7efb5-ca39-0410-a469-dd3cf9ba447f

include/simix/simix.h
src/simix/smx_host.c

index 3c810e3..967dd5d 100644 (file)
@@ -51,6 +51,7 @@ XBT_PUBLIC(void) SIMIX_process_set_function(const char* process_host,
                                             double process_kill_time);
 
 /*********************************** Host *************************************/
+XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_dict(void);
 XBT_PUBLIC(smx_host_t) SIMIX_host_get_by_name(const char *name);
 XBT_PUBLIC(smx_host_t) SIMIX_host_self(void);
 XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void);
index b655087..62e1113 100644 (file)
@@ -77,6 +77,25 @@ void SIMIX_host_destroy(void *h)
   return;
 }
 
+/**
+ * \brief Returns a dict of all hosts.
+ *
+ * \return List of all hosts (as a #xbt_dict_t)
+ */
+xbt_dict_t SIMIX_host_get_dict(void)
+{
+  xbt_dict_t host_dict = xbt_dict_new();
+  xbt_lib_cursor_t cursor = NULL;
+  char *name = NULL;
+  void **host = NULL;
+
+  xbt_lib_foreach(host_lib, cursor, name, host){
+         if(host[SIMIX_HOST_LEVEL])
+                 xbt_dict_set(host_dict,name,host[SIMIX_HOST_LEVEL],NULL);
+  }
+  return host_dict;
+}
+
 smx_host_t SIMIX_host_get_by_name(const char *name)
 {
   xbt_assert0(((simix_global != NULL)