Perform factor reduction as a modular step
[lttv.git] / lttv / lttv / sync / sync_chain.c
index be915b08474ba4acba68f2d5e4087e1e9eb3a06e..a34a93b12dbcfe96745db6c10a680dbcc73590de 100644 (file)
@@ -20,6 +20,7 @@
 #endif
 
 #include <errno.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
@@ -29,6 +30,7 @@
 GQueue processingModules= G_QUEUE_INIT;
 GQueue matchingModules= G_QUEUE_INIT;
 GQueue analysisModules= G_QUEUE_INIT;
+GQueue reductionModules= G_QUEUE_INIT;
 GQueue moduleOptions= G_QUEUE_INIT;
 
 
@@ -44,14 +46,21 @@ void printStats(SyncState* const syncState)
        {
                syncState->processingModule->printProcessingStats(syncState);
        }
-       if (syncState->matchingModule->printMatchingStats != NULL)
+       if (syncState->matchingModule != NULL &&
+               syncState->matchingModule->printMatchingStats != NULL)
        {
                syncState->matchingModule->printMatchingStats(syncState);
        }
-       if (syncState->analysisModule->printAnalysisStats != NULL)
+       if (syncState->analysisModule != NULL &&
+               syncState->analysisModule->printAnalysisStats != NULL)
        {
                syncState->analysisModule->printAnalysisStats(syncState);
        }
+       if (syncState->reductionModule != NULL &&
+               syncState->reductionModule->printReductionStats != NULL)
+       {
+               syncState->reductionModule->printReductionStats(syncState);
+       }
 }
 
 
@@ -146,6 +155,29 @@ gint gcfCompareAnalysis(gconstpointer a, gconstpointer b)
 }
 
 
+/*
+ * A GCompareFunc for g_slist_find_custom()
+ *
+ * Args:
+ *   a:            ReductionModule*, element's data
+ *   b:            char*, user data to compare against
+ *
+ * Returns:
+ *   0 if the reduction module a's name is b
+ */
+gint gcfCompareReduction(gconstpointer a, gconstpointer b)
+{
+       const ReductionModule* reductionModule;
+       const char* name;
+
+       reductionModule= (const ReductionModule*) a;
+       name= (const char*) b;
+
+       return strncmp(reductionModule->name, name, strlen(reductionModule->name) +
+               1);
+}
+
+
 /*
  * A GFunc for g_queue_foreach()
  *
@@ -160,3 +192,19 @@ void gfAppendAnalysisName(gpointer data, gpointer user_data)
        g_string_append((GString*) user_data, ((AnalysisModule*) data)->name);
        g_string_append((GString*) user_data, ", ");
 }
+
+
+/*
+ * A GFunc for g_queue_foreach()
+ *
+ * Concatenate reduction module names.
+ *
+ * Args:
+ *   data:         ReductionModule*
+ *   user_data:    GString*, concatenated names
+ */
+void gfAppendReductionName(gpointer data, gpointer user_data)
+{
+       g_string_append((GString*) user_data, ((ReductionModule*) data)->name);
+       g_string_append((GString*) user_data, ", ");
+}
This page took 0.030555 seconds and 4 git commands to generate.