From eb45199603c7ab5afe3b2a5df3c2bd56254974f8 Mon Sep 17 00:00:00 2001 From: navarro Date: Thu, 6 Sep 2012 15:43:39 +0200 Subject: [PATCH 1/1] Add 3 msg functions to get and modify property of an AS or router --- include/msg/msg.h | 5 +++++ src/msg/msg_gos.c | 37 +++++++++++++++++++++++++++++++++++++ src/msg/msg_host.c | 2 +- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/include/msg/msg.h b/include/msg/msg.h index 24bf774bb5..44c79a4b93 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -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); +/************************** 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); diff --git a/src/msg/msg_gos.c b/src/msg/msg_gos.c index 473ec7a86f..13f4bf12b8 100644 --- a/src/msg/msg_gos.c +++ b/src/msg/msg_gos.c @@ -813,6 +813,43 @@ const char *MSG_task_get_category (msg_task_t task) #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 * diff --git a/src/msg/msg_host.c b/src/msg/msg_host.c index 53e1ac5cae..08269984af 100644 --- a/src/msg/msg_host.c +++ b/src/msg/msg_host.c @@ -211,7 +211,7 @@ const char *MSG_host_get_property_value(msg_host_t host, const char *name) } /** \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 -- 2.20.1