Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add 3 msg functions to get and modify property of an AS or router
authornavarro <navarro@caraja.(none)>
Thu, 6 Sep 2012 13:43:39 +0000 (15:43 +0200)
committernavarro <navarro@caraja.(none)>
Thu, 6 Sep 2012 13:43:39 +0000 (15:43 +0200)
include/msg/msg.h
src/msg/msg_gos.c
src/msg/msg_host.c

index 24bf774..44c79a4 100644 (file)
@@ -81,6 +81,11 @@ XBT_PUBLIC(void) MSG_file_free_stat(s_msg_stat_t *stat);
 
 XBT_PUBLIC(int) MSG_file_unlink(msg_file_t fd);
 
 
 XBT_PUBLIC(int) MSG_file_unlink(msg_file_t fd);
 
+/************************** AS Router handling ************************************/
+XBT_PUBLIC(const char *) MSG_as_router_get_property_value(const char* asr, const char *name);
+XBT_PUBLIC(xbt_dict_t) MSG_as_router_get_properties(const char* asr);
+XBT_PUBLIC(void) MSG_as_router_set_property_value(const char* asr, const char *name, char *value,void_f_pvoid_t free_ctn);
+
 /************************** Host handling ***********************************/
 XBT_PUBLIC(msg_error_t) MSG_host_set_data(msg_host_t host, void *data);
 XBT_PUBLIC(void *) MSG_host_get_data(msg_host_t host);
 /************************** Host handling ***********************************/
 XBT_PUBLIC(msg_error_t) MSG_host_set_data(msg_host_t host, void *data);
 XBT_PUBLIC(void *) MSG_host_get_data(msg_host_t host);
index 473ec7a..13f4bf1 100644 (file)
@@ -813,6 +813,43 @@ const char *MSG_task_get_category (msg_task_t task)
 #endif
 }
 
 #endif
 }
 
+/**
+ * \brief Returns the value of a given AS or router property
+ *
+ * \param asr the name of a router or AS
+ * \param name a property name
+ * \return value of a property (or NULL if property not set)
+ */
+const char *MSG_as_router_get_property_value(const char* asr, const char *name)
+{
+  return xbt_dict_get_or_null(MSG_as_router_get_properties(asr), name);
+}
+
+/**
+ * \brief Returns a xbt_dict_t consisting of the list of properties assigned to
+ * a the AS or router
+ *
+ * \param asr the name of a router or AS
+ * \return a dict containing the properties
+ */
+xbt_dict_t MSG_as_router_get_properties(const char* asr)
+{
+  // FIXME do this function with a simcall
+  return xbt_lib_get_or_null(as_router_lib, asr, ROUTING_PROP_ASR_LEVEL);
+}
+
+/**
+ * \brief Change the value of a given AS or router
+ *
+ * \param asr the name of a router or AS
+ * \param name a property name
+ * \param value what to change the property to
+ * \param free_ctn the freeing function to use to kill the value on need
+ */
+void MSG_as_router_set_property_value(const char* asr, const char *name, char *value,void_f_pvoid_t free_ctn) {
+  xbt_dict_set(MSG_as_router_get_properties(asr), name, value,free_ctn);
+}
+
 #ifdef MSG_USE_DEPRECATED
 /** \ingroup msg_deprecated_functions
  *
 #ifdef MSG_USE_DEPRECATED
 /** \ingroup msg_deprecated_functions
  *
index 53e1ac5..0826998 100644 (file)
@@ -211,7 +211,7 @@ const char *MSG_host_get_property_value(msg_host_t host, const char *name)
 }
 
 /** \ingroup m_host_management
 }
 
 /** \ingroup m_host_management
- * \brief Returns a xbt_dynar_t consisting of the list of properties assigned to this host
+ * \brief Returns a xbt_dict_t consisting of the list of properties assigned to this host
  *
  * \param host a host
  * \return a dict containing the properties
  *
  * \param host a host
  * \return a dict containing the properties