From e62a7964624b47582b69d87dc6740983db5bb3c5 Mon Sep 17 00:00:00 2001 From: compudj Date: Tue, 22 Jun 2004 20:45:48 +0000 Subject: [PATCH] added API for calculators (module which calculate trace information) git-svn-id: http://ltt.polymtl.ca/svn@607 04897980-b3bd-0310-b5e0-8ef037075253 --- .../lttvwindow/lttvwindow/lttvwindowtraces.c | 242 ++++++++++++++++++ .../lttvwindow/lttvwindow/lttvwindowtraces.h | 74 ++++++ 2 files changed, 316 insertions(+) diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c index 3a3666ba..b6136df1 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c @@ -1051,3 +1051,245 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) } } } + + + +/** + * Register the background computation hooks for a specific module. It adds the + * computation hooks to the global attrubutes, under "computation/module name" + * + * @param module_name A GQuark : the name of the module which computes the + * information. + */ +void lttvwindowtraces_register_computation_hooks(LttvAttributeName module_name, + LttvHooks *before_chunk_traceset, + LttvHooks *before_chunk_trace, + LttvHooks *before_chunk_tracefile, + LttvHooks *after_chunk_traceset, + LttvHooks *after_chunk_trace, + LttvHooks *after_chunk_tracefile, + LttvHooks *before_request, + LttvHooks *after_request, + LttvHooks *event_hook, + LttvHooksById *event_hook_by_id) +{ + LttvAttribute *g_attribute = lttv_global_attributes(); + LttvAttribute *attribute; + LttvAttributeValue value; + + g_assert(attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), + LTTV_COMPUTATION))); + + g_assert(attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute), + module_name))); + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_BEFORE_CHUNK_TRACESET, + LTTV_POINTER, + &value)); + *(value.v_pointer) = before_chunk_traceset; + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_BEFORE_CHUNK_TRACE, + LTTV_POINTER, + &value)); + *(value.v_pointer) = before_chunk_trace; + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_BEFORE_CHUNK_TRACEFILE, + LTTV_POINTER, + &value)); + *(value.v_pointer) = before_chunk_tracefile; + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_AFTER_CHUNK_TRACESET, + LTTV_POINTER, + &value)); + *(value.v_pointer) = after_chunk_traceset; + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_AFTER_CHUNK_TRACE, + LTTV_POINTER, + &value)); + *(value.v_pointer) = after_chunk_trace; + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_AFTER_CHUNK_TRACEFILE, + LTTV_POINTER, + &value)); + *(value.v_pointer) = after_chunk_tracefile; + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_BEFORE_REQUEST, + LTTV_POINTER, + &value)); + *(value.v_pointer) = before_request; + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_AFTER_REQUEST, + LTTV_POINTER, + &value)); + *(value.v_pointer) = after_request; + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_EVENT_HOOK, + LTTV_POINTER, + &value)); + *(value.v_pointer) = event_hook; + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_EVENT_HOOK_BY_ID, + LTTV_POINTER, + &value)); + *(value.v_pointer) = event_hook_by_id; + +} + + +/** + * It removes all the requests than can be currently processed by the + * background computation algorithm for all the traces (list_in and list_out). + * + * Leaves the flag to in_progress or none.. depending if current or queue + * + * @param module_name A GQuark : the name of the module which computes the + * information. + */ +void lttvwindowtraces_unregister_requests(LttvAttributeName module_name) +{ + guint i; + + for(i=0;idata; + + if(bg_req->module_name == module_name) { + remove = TRUE; + free_data = TRUE; + } + + /* Go to next */ + if(remove) + { + GSList *remove_iter = iter; + + iter = g_slist_next(iter); + if(free_data) g_free(remove_iter->data); + queue = g_slist_remove_link(queue, remove_iter); + } else { // not remove + iter = g_slist_next(iter); + } + } + + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_REQUESTS_CURRENT, + LTTV_POINTER, + &value)); + current = (GSList*)*(value.v_pointer); + + iter = current; + while(iter != NULL) { + gboolean remove = FALSE; + gboolean free_data = FALSE; + + BackgroundRequest *bg_req = (BackgroundRequest*)iter->data; + + if(bg_req->module_name == module_name) { + remove = TRUE; + free_data = TRUE; + } + + /* Go to next */ + if(remove) + { + GSList *remove_iter = iter; + + iter = g_slist_next(iter); + if(free_data) g_free(remove_iter->data); + current = g_slist_remove_link(current, remove_iter); + } else { // not remove + iter = g_slist_next(iter); + } + } + } +} + + +/** + * Unregister the background computation hooks for a specific module. + * + * It also removes all the requests than can be currently processed by the + * background computation algorithm for all the traces (list_in and list_out). + * + * @param module_name A GQuark : the name of the module which computes the + * information. + */ + +void lttvwindowtraces_unregister_computation_hooks + (LttvAttributeName module_name) +{ + LttvAttribute *g_attribute = lttv_global_attributes(); + LttvAttribute *attribute; + + g_assert(attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), + LTTV_COMPUTATION))); + g_assert(attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute), + module_name))); + + + lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute), + LTTV_EVENT_HOOK_BY_ID); + lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute), + LTTV_EVENT_HOOK); + + lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute), + LTTV_AFTER_REQUEST); + lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute), + LTTV_BEFORE_REQUEST); + + lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute), + LTTV_AFTER_CHUNK_TRACEFILE); + lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute), + LTTV_AFTER_CHUNK_TRACE); + lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute), + LTTV_AFTER_CHUNK_TRACESET); + + lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute), + LTTV_BEFORE_CHUNK_TRACEFILE); + lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute), + LTTV_BEFORE_CHUNK_TRACE); + lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute), + LTTV_BEFORE_CHUNK_TRACESET); + /* finally, remove module name */ + g_assert(attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), + LTTV_COMPUTATION))); + lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute), + module_name); + +} + + diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.h index a7d6d81f..f490995e 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.h +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.h @@ -153,4 +153,78 @@ void lttvwindowtraces_background_notify_current void lttvwindowtraces_background_notify_remove(gpointer owner); +/** + * Tells if the information computed by a module for a trace is ready. + * + * Must be checked before a background processing request. + * + * @param module_name A GQuark : the name of the module which computes the + * information. + * @param trace The trace for which the information is verified. + */ + +gboolean lttvwindowtraces_get_ready(LttvAttributeName module_name, + LttvTrace *trace); + +/** + * Tells if the information computed by a module for a trace is being processed. + * + * Must be checked before a background processing request. + * + * If it is effectively processed, the typical thing to do is to call + * lttvwindowtraces_background_notify_current to be notified when the current + * processing will be over. + * + * @param module_name A GQuark : the name of the module which computes the + * information. + * @param trace The trace for which the information is verified. + */ + +gboolean lttvwindowtraces_get_in_progress(LttvAttributeName module_name, + LttvTrace *trace); + +/** + * Register the background computation hooks for a specific module. It adds the + * computation hooks to the global attrubutes, under "computation/module name" + * + * @param module_name A GQuark : the name of the module which computes the + * information. + */ +void lttvwindowtraces_register_computation_hooks(LttvAttributeName module_name, + LttvHooks *before_chunk_traceset, + LttvHooks *before_chunk_trace, + LttvHooks *before_chunk_tracefile, + LttvHooks *after_chunk_traceset, + LttvHooks *after_chunk_trace, + LttvHooks *after_chunk_tracefile, + LttvHooks *before_request, + LttvHooks *after_request, + LttvHooks *event_hook, + LttvHooksById *event_hook_by_id); +/** + * Unregister the background computation hooks for a specific module. + * + * It also removes all the requests than can be currently processed by the + * background computation algorithm for all the traces (list_in and list_out). + * + * @param module_name A GQuark : the name of the module which computes the + * information. + */ + +void lttvwindowtraces_unregister_computation_hooks + (LttvAttributeName module_name); + + +/** + * It removes all the requests than can be currently processed by the + * background computation algorithm for all the traces (list_in and list_out). + * + * Leaves the flag to in_progress or none.. depending if current or queue + * + * @param module_name A GQuark : the name of the module which computes the + * information. + */ +void lttvwindowtraces_unregister_requests(LttvAttributeName module_name); + + #endif //LTTVWINDOWTRACES_H -- 2.34.1